Sunday, December 4, 2011

First Sensorless FOC Test Drive

Having done enough computational optimization of the flux observer math and tested the sensorless sine commutation with no load, the next obvious step was to test drive it on Pneu Scooter:


Well, no, the next obvious step would have been to run it under load with the Hall effect sensors but collect data from the flux observer in parallel to ensure that it is working. But I guess I skipped over that step.

As you can see in the video, the open-loop flux observer appears to work very well at low speeds. There is no start-up ramp in the code right now; I just nudge the scooter very slightly forward and it picks up commutation right away. It's able to find the position of the rotor at speeds down to 50rpm, which is less than 5% of the maximum speed. Here's a slice of data from one of these low-speed runs, showing the flux observer speed estimate matching up with the Hall effect sensor speed in the range of 50-400rpm:


Here's the comparison of estimated rotor electrical angles for the same data range:


The 1:1 correlation is not as tight as that of the no-load test. The additional noise is most likely caused by the current sensors, and is a target for improvement. The current sensors on this particular controller have always been noisy. When I was in Singapore last year, I confirmed that the source of noise was the PWM. I later added better filtering and that made the sensors much more usable.  But one thing I've wanted to try for a while is more intelligent ADC sampling, where the ADC is triggered in the middle of a PWM pulse, away from the noisy transitions:


In order to do this on 3ph v3.1, I will need to mess with the timers a bit. Each of the three phases of PWM are controlled by different timers (for very good reasons, I assure you). So before I can have them trigger the ADC, I will need to synchronize them and change the PWMs to be center-timed, all things the 1072-page STM32F103 reference manual ensures me are possible.

Current sensor noise isn't the only problem left to solve, though. Somehow, the flux observer works very well at low speed, where sensorless routines are supposed to struggle, but it fails at high speeds, where they should do well thanks to the large back EMF. The speed at which this happens, under no-load operation, is strongly dependent on the low-pass filter time constant I use for integrating V-IR. (I swear this low-pass filter is evil.)

During the process of tweaking the low-pass filter time constant, I was able to bump up the speed of the flux estimator. But this time when it failed at the higher speed, it took out one phase worth of MOSFETs with it. So I'll have to replace the whole IXYS GWM100-01X1 module and/or switch to the spare controller. That gives me an opportunity to implement a few other improvements:
  • Center-timed PWM with clean ADC triggering, as discussed above. I may even try to use the Direct
    Memory Access (DMA) to fully automate the ADC and save processor time.

  • Faster fast loop. I don't want the fast loop and the ADC sampling to run into each other, so I will put the entire fast loop at PWM frequency, as it was on 3ph v2.1. The timer interrupt will trigger the ADC, then the End-of-Conversion interrupt will trigger the fast loop.

  • Fast-loop current fault protection. If any phase current measurement exceeds some threshold, it will trigger gate driver shutdown in the fast loop, within 64μs. This might help protect the MOSFETs from destruction in the (likely/certain) event of commutation failure.

  • More data. I would like to transmit some of the intermediate variables in the flux estimator so I can maybe see more clearly why it fails at high speed.
Hopefully with all these changes, testing will go more smoothly this week.

3 comments:

  1. Gday,

    I have been messing about with FOC on a freescale 56F8037. Recently, when things were working ok, I managed to fry the last of my amplifiers. So, while Im waiting to accumulate cash to build more, I have been working on the data visualisation side of things. I have this 8037 running on mainly fixed point code, as described in the freescale app notes and I have written some code that successfully turns this into real, useful values on the PC side of things.
    I would really like to start graphing some of this data out (ie, realtime phase currents, PWM ratios, rotor position etc) and was wondering what software you use to plot your graphs? Do you graph in real time, or have you been gathering the data and plotting it later?
    Thanks for your great blog too!

    Laurence M (from Australia)

    ReplyDelete
  2. Hi Laurence,

    Thanks!

    For the visualization, I wrote a VB .NET dashboard that shows data in real-time (numeric and two plots) and logs it to a comma-delimited text file. I can read this file later using MATLAB and make plots like the ones in this post.

    The data is transmitted from the motor controller over a serial port at an adjustable rate, up to about 100Hz. So, not fast enough to plot phase current waveforms. But, the data is still useful when cross-plotted (against rotor postion, for example) since it is sampled synchronously in the controller.

    ReplyDelete
  3. Now that it works, you should try converting a power tool from a brushed to brushless motor, and see if you can make it work, just for the heck of it. A circular saw, or something.

    ReplyDelete