Can this be made into all electric and really fast too?
Here's a quick update on the Electrified Miata. Plans for last week were to investigate how to use the Leaf inverter without faults and then use proportional–integral–derivative controller (PID) to get cruise control working. The Leaf inverter fault was really driving me crazy. The motor was so close to being usable, and yet so far away because it would stop working at unpredictable times. Any type of control that used all the torque commands would cause a fault. I was *this close* to making the decision to buy one of the available 'brain boards' that replace the stock inverters 'brain board'. However, that would add a minimum of $350.00 per motor. Maybe not so much when we're only talking about one motor, but who wants to have only one motor?? Four seems like a more reasonable number to me.
Living in a state of frustration about the inverter faults wasn't healthy for me, or my relationship with my wife. I made a small video demonstrating the problem for the team and asked for their help. I then took the weekend off, hoping that the team's wisdom and the magical superpower of the unconscious brain would have some suggestions. After a restful weekend, I sat at the computer typing in values one by one and happened to find that torque values of 127 worked fine, while 128, 129, 130, 131, would cause the fault, yet, 132, 133, worked fine. What was wrong with those numbers to cause the fault? A nice puzzle! Lucky for us, there was code to talk with a Leaf inverter written in the programming language called 'C' out on the internet. I have written nearly everything in Python, which runs slower than C, but
handles a lot of details for the programmer, making it easier to produce programs. While most of the time, there is an easy translation between the two languages, there are certain details that can cause trouble.
I decided to do a side by side comparison of the output between the C and Python system. Experience told me there were two distinct possibilities where trouble might occur. I used my range of 'good' numbers and 'bad' numbers and compared the output for both the torque command, and the checksum (a way to detect if the data sent from one computer to another is correct).
The torque command is a 16 bit little endian number, so it matters
how the bytes are assembled, especially since Python uses
32/64bit numbers and has no specific 16 bit type.
The check sum value is calculated across 8 bytes of data in the
CAN message using a Cyclic Redundancy Check algorithm using a
Nissan specific polynomial.
The torque command output appeared fine, but the check sum wasn't right for the 'bad' numbers. Wow, that was the best news I'd recently heard. Now I could taste victory. Careful inspection of my code revealed the problem. I had 'less than' numerical comparison, as opposed to 'less than AND equals to'. That had the effect of mostly working, except for certain numbers where the 'AND equals to' case was needed. Oh my goodness. Shouts of joy and engine revving.. Persistence had payed off yet again. Thanks Dad, for teaching me to stick with it.
With the inverter faults gone, I could start to make progress in other areas. I decided to tackle the throttle pedal. The pedal system is made from two parts. The first part, the pedal, translates physical movement into a voltage to be measured. The second part is an Analog to Digital (A/D) chip to translate the pedal voltage to a number that the computer can use. Testing the two components together kind of worked, but the signal was quite noisy and erratic making the result nearly unusable. I blamed the pedal hardware as I had bought the cheapest 'hall effect' pedal I could find for $16. I was now convinced that was too cheap. Sigh. I was just about the buy a mid priced pedal for $90, when the thought occurred to me that I'd better verify the noise was really coming from that pedal. I connected a single cell battery as a noise free source in place of the pedal and discovered the noise was still there. What the heck!?! Reading the specs for the A/D chip closer, I discovered several methods of input to the chip. One was differential input, great for getting rid of noise! With the addition of one wire and changing how the chip took input, the pedal started working with very little noise. Now I could rev the motor via the pedal motion. Thanks to my awesome wife, here's a video of me doing exactly that. She likes to capture the fact that I really do get great joy revving a motor.
As you can see from the video, I have four Pi computers running the system. The
system is designed to be modular, so each component can be checked and implemented on its own, and then plugged in together to add functionality. This
approach was favored by one of my mentors (thanks Dan Perry) and has worked really well for breaking down complex problems in to smaller manageable tasks all cooperating to create the complex system.
I was also able to start on the PID control. PID requires tuning and tuning requires some real time graphing. Real time graphing will require me to dig out some stock market graphing code and adapt that to this motor situation. Whew, I'm tired just thinking about all of that. Real time graphs will have to wait till next week.
In other news, Joe continues to make great progress on BMS re-write. Major infrastructure milestones, like communication, firmware update, and device identification are working. The last infrastructure milestone is the low-power mode. Since the BMS boards are always connected to the battery, it's very important that they use as little power as possible when the car is not being used. After the infrastructure is finished, we can start working on the features, like cell voltage measurements, which are actually less complicated than the infrastructure.
Next week, the plan is to do some clean up, reducing the number of Pi's from 4 to 2, and start looking for a Miata. I'll be needing some actual physical measurements to know where I can fit batteries and what sizes would be ideal. I need more batteries to do full power testing and I don't want to make batteries that I'll have to take apart again when I could have made the batteries the right size the first time. Wish me luck in finding a first 'parts' car that we'll use for a prototype and experiment on. Thanks for reading, and stay healthy!
Bill likes cars that understand the 'go fast now' pedal.