Bug

Bug

Tuesday, September 27, 2011

Debugging

I'm still working through debugging everything. I found wiring errors in my control box, some wired to the wrong locations and a couple of missing wires to the deadtime control chip.
Once I got the wiring all fixed I ran some tests, these tested inputs and outputs to make sure they functioned correctly. I also tested all the interrupts in my motor control firmwire, the timed interrupts and the external interrupts.
Motor control uses center or symmetric PWM, this is different from the normal edge aligned PWM and prevents all the outputs switching on simultaneously, it staggers them instead. I had previously written to the authors of the leaflabs compiler and they had given me instructions on how to modify the compiler so it does center aligned PWM. Unfortunately the compiler has been updated a number of times since the end of last year, I dug through the new files and managed to figure out myself how to make the modifications. I confirmed this via a high speed oscilloscope.
I had to understand how the deadtime generator worked for my start routines and regen braking routines to work. I again used a high speed PC based oscilloscope to analyse the signals. It behaves as expected.

One of the biggest headaches I've had and the hardest thing to write is all the different driving states and how the motor knows where it is and where its going. This is everything from standstill, to initial acceleration, switch to closed loop control, regen braking, coasting, and stopping.
I had originally done this via many IF statements inside functions triggered by hall sensor interrupts and a timed 10hz interrupt which handles reading the throttle and enable etc. However it became very difficult to manage and draw out in a block diagram.
I decided to re-write these parts again, I made up state matrixes in excel and then used case statements in my functions to switch between cases. It is now clearer and more manageable.
Next I'm working on checking the closed loop functions, there are many parameter in there that are missing, I've ported my code to arduino to do this as its easier to debug via the serial port.
There is also a new arduino out this year with ARM:

http://arduino.cc/blog/2011/09/17/arduino-launches-new-products-in-maker-faire/

It uses a 96Mhz ARM microcontroller, faster than the Maple I am using. The arduino compiler is very similar to Leaflabs so it should be very easy to port my code to Arduino. I'm sticking with the Maple for now as I am far along and the Arduino Due is bigger and won't fit in my control box. Its also very new and the compiler may have errors and items like symmetric PWM might be impossible or difficult to implement on such a new product.
I can see the new Arduino with my 3 phase open source motor control firmware becoming quite popular, all it needs is an open source IGBT or FET driver stage and motor control should become much easier and cheaper!

No comments:

Post a Comment