Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simulating Synchronous AC Motor FOC

Status
Not open for further replies.

Element Green

Computer
Dec 17, 2016
3
Hello,

I hope this question concerning implementing an FOC motor controller is appropriate for this forum.

I'm currently working on an open source 3 phase synchronous AC motor controller (hardware and software) using the STM32F303 microcontroller platform. In the interest of having the firmware also be open source, I am creating it from scratch, rather than leveraging existing proprietary motor control libraries.

I think I finally understand Field Oriented Control and have implemented a good bit of the firmware for this. However, I've decided to first do some simulations prior to hooking it up to a real motor. For this purpose I'm utilizing the D3.js Javascript library to plot the various variables involved in FOC in a web browser. However, I'm having difficulty conceptualizing how to simulate a motor. This is the subject of my question.

In the Field Oriented Control algorithm, there are the following measured motor inputs:
Phase A, B, and C instantaneous current measurements (only 2 actually need to be measured, 3rd is inferred from the fact that A + B + C = 0).
Absolute rotor position

In torque control mode there are Torque (q) and Flux (d) reference values, which are utilized by independent PI controllers to maintain the Torque and Flux of the motor.

The final output is 3 phase sine waves with 120 degree phase shifts. This will get fed to an SVPWM stage in the actual firmware, but is omitted in the simulation.

Feeding back the 3 phase output to the measured 3 phase motor current is straightforward enough (just copying the values). I'm stumped on how to simulate the rotation of the motor though. This would seem to require at least the following parameters: motor pole pair count, motor load, current speed of motor.

Given this information, how would I update the motor rotor position input? I would think this would involve calculating the torque, from the amount of current which is being supplied to the motor and the load which must be overcome. The number of pole pairs would determine the degree of rotation for a full cycle.

Any thoughts on this would be greatly appreciated. I can host the simulation on my website, if it would help to have some code to look at, though it is still lacking interactive controls currently.

Best regards,

Element Green
 
Replies continue below

Recommended for you

EG; I think you're missing the keys you need or you'd probably have the rotation part of the simulation falling on your toe. You must completely understand the Clarke and Park transforms as they speak to the rotational positions. Hunt them down and I think you'll see how to proceed.

Keith Cress
kcress -
 
Thank you for the reply Keith.

I am already using the Clarke and Park transforms as well as the inverse of the two.

I agree, it seems like I'm missing something obvious. The current absolute rotor angle is used as an input to the Park and inverse Park transforms. What is still not clicking for me is how to update the motor angle, based on the other parameters. The FOC algorithm is run at regular intervals and in this case I'm running it 10 times a second (slower than real time). I plan on using a time factor which can be used in the simulation (10:1, 100:1, 1000:1, etc) to slow it down in a defined manner.

I've attached the current standalone HTML/Javascript file (should be possible to load it in a web browser from the file system) that I have for the simulation if that would help clarify what it is I'm trying to do. The FOC algorithm is in the evaDriveProcess() function. The last lines of the function show some commented out code relating to updating the motorAngle, which is the last piece I'm trying to solve.

Some notes:
- Using integer fractions instead of floating point to be as close as possible to the final optimized fixed point math firmware.
- When multiplying by fractions, half of the divisor is added to the dividend for integer truncation rounding.
- Using a sin array table with linear interpolation to be as close as possible to the firmware.
- All of the FOC parameters are in the Javascript object called 'drive' at the top of the file.

I was looking at equations for Angular Acceleration which might be on the right track? It seems like updating the motorAngle depends on the torque, load angular mass (drive.motorAngularMass), and accumulated speed (drive.motorSpeed). What I'm still unsure of is how to calculate the instantaneous torque (assuming a 100% efficient motor is this purely a function of the electrical power driving the 3 phases?). With known torque and angular mass it should be possible to calculate the angular acceleration, which can then be used to update the accumulated motorSpeed parameter and thus calculate the absolute rotor position based on the time factor and number of motor pole pairs. Seems like I'm getting closer, could use some hand holding though.

Best regards,

Element Green
 
 http://files.engineering.com/getfile.aspx?folder=9f743644-91d2-4a80-b63c-81832fb8747d&file=EvaDriveSim.html
Status
Not open for further replies.

Part and Inventory Search

Sponsor