Simulation & Simulacra

Posted on January 28, 2008


Sorry for the Matrixy title, but… once a geek, always a geek. 🙂

I completed my LUA script that simulates the movement of the motor. Here’s the video.

Fig. 1 – simulation video of the rotating BLDC motor.

I know, it doesn’t look great, and you can’t see shit of the details because the resolution is too low… well, that’s what you get with free blog & video hosting. 😦

The simulation script implements the simple square-wave BLDC control sequence by switching the 3 electric phases on-off in 6 sequential steps, as many times as needed to make a complete rotor turn. You can see the coils being energized, and it is possible to determine their polarity: the red squares are sources (+) of current (out of paper direction), and the blue squares are the sinks (-) of current (into the paper direction). The movie was made with “mencoder“, and the red and blue colors where added in “The GIMP“.

Why did I make this? Because I needed to validate my knowledge of the electric switching control and general motor functioning.

I’ve coded a mutual relationship between Torque and Position:

  1. calculate the torque at the current position;
  2. if the torque pulls ClockWise (CW), rotate 2 degrees CW;
  3. if the torque pulls CounterClockWise (CCW), rotate 2 degrees CCW;
  4. if the torque is insufficient (less than 10Nm either way), switch to next phase step (following the current direction);
  5. goto 1;

Since the BLDC phase switching order is what defines the direction of rotation, this script can make the rotor spin either way, depending only on the initial conditions (initial position angle versus initial chosen phase switching step). If the first torque calculation is positive, it spins CCW, else CW. This is good enough for my simulation needs and yields a nice clean graphic without direction reversions. For example, it demonstrates “experimentally” that the electrical frequency is 7 times greater than the mechanical rotation speed.

Here is the collected data.


Fig. 2 – Torque and Phase Step vs. Rotor Position (rotation simulation).

The graph ends prematurely before reaching 360 degrees (full turn) because FEMM crashed again and I had no more patience to restart at the right place. But the trend is quite homogeneous and predictable. I plotted 2 variables in order to Position Angle:

  • Produced torque.
  • Phase step.

The possible Phase Steps in BLDC control are 6 for each phase. 0 means off, 1 means positive current, -1 means negative current:

  • Phase A time sequence = { 1, 1, 0,-1,-1, 0}
  • Phase B time sequence = {-1, 0, 1, 1, 0,-1}
  • Phase C time sequence = { 0,-1,-1, 0, 1, 1}

This table effectively encodes a 3-phase system of square waves, 120 degrees out of phase between each other.

The torque displayed is the worst-case scenario; it is the actual torque that would develop if the motor was stopped. So if the motor was actually running, the torque would be lower, and so would be the amplitude of the ripple. But what stands out in this graph is the enormous torque ripple that can occur when using BLDC square wave switching… and that’s no good for transportation motors – high torque ripple generates high levels of mechanical stress and vibration noises. So, once again I am most inclined to implement sine-wave control instead of square-wave control.