Taking a quick jaunt through the history of electric traction motor control, before the advent of ‘solid state’ electronic switches, controllers may have switched in numbers of high power resistors, or switched motor windings between various configurations. The only methods available involved switching high motor currents, using electro-mechanical contraptions with a significant maintenance overhead.
A milestone breakthrough was the advent of the electronic solid-state switch, thyristors or transistors of various types, considered maintenance free alternatives to electro-mechanical relays and contactors. These could be seen as near drop-in replacements for electro-mechanicals, keeping existing control methods with reduced maintenance costs. But that was just the start.
Using electro-mechanicals, keeping a lid on maintenance costs, it made sense to switch things no more often than strictly necessary. Electronic switches, in contrast, may be put through hundreds or thousands of on-off cycles per second, maintenance free. This opened the way to control methods exploiting a feature of electrical apparatus incorporating coils of wire, inductance. The useful effect of inductance is than when a voltage is switched on, the current starts to flow but takes a finite time to build. Using electronic switches, motor voltages can be switched on and off rapidly. Therefore, we can control the motor current quite smoothly by repeatedly switching the motor between full on and full off in the time it takes for the motor current to change only a little. This comes with another huge advantage, efficiency. We can now control motor current without using big power-wasting resistors.
Early electronic motor controllers built using discrete analogue components demonstrated all these advantages, but like all electronics of the time, could seem a little complex and lacking in flexibility, although systems were becoming more efficient and reliable than anything that came before.
Meanwhile, the semiconductor industry was evolving at a spectacular pace. Particularly for digital systems, 'Moore's Law' observed that performance doubles every two years for the same cost, or cost halves for a given function in the same time. Over twenty years, this is a factor of one thousand, meaning that electronic solutions which once seemed unimaginable may now be practical costing pennies. Chips are now available performing many of the trickier aspects of switch control, all useful in shrinking the complexity, size and cost of motor controllers while building on reliability.
Microcontrollers are today at the core of almost all electronic products and systems. For less than the price of a pint we can, for example, buy a capable 32-bit device bristling with useful built in stuff (memory, timers, comms ports, analogue interfaces and all sorts). These are close to being ‘SoC’ – Systems on a Chip. Indeed we could choose the same device for use in any upcoming design project whether for a mobile phone, washing machine, car window winder, drone, or missile guidance system. With motor control being a popular application, parts of the microcontroller design have been optimised with this in mind. When looking to update an older design, these microcontrollers could be configured to replace quite a lot of the functionality previously implemented using discrete components, significantly reducing complexity.
So that’s how the claim that motor controller design “is so much easier than it used to be” is justified, although we may note we have minimised hardware at the expense of introducing ‘software’, which, it could be argued, is a non-trivial project in itself. This article, however, is about the hardware, so how does this design work?
To begin at the end.
Power is delivered to the motor using MOSFET semiconductor power switches configured in so called half-bridge pairs, a ‘high-side’ switch for connecting one motor lead to the positive side of the battery or power supply, and a ‘low-side’ switch for connecting to the negative side. With both switches ‘off’ the motor lead is unconnected (this is sometimes useful), but to be avoided at all costs is allowing both switches to be ‘on’ together, a condition known as ‘shoot-through’, which expensively short circuits the supply and lets the smoke out.
A perennial design problem was the avoidance of shoot-through, aggravated by the inconvenient truth that in general, semiconductor switches take slightly longer to switch off, than on. This means we had to design circuits to turn one switch off, leave a short but sufficient delay, before turning the other one on. Also, we need different circuitry driving the low-side (simple), and high-side (not so simple), switches. These different circuits inevitably incurred unequal switching delays. Soon gets tricky, but luckily, modern designs can use half-bridge driver chips, which take care of all of this for us (phew!).
Older two-wire DC motors would use two half-bridges, a full bridge of four switches, for full bidirectional control. Such motors have been displaced in manufacturing globally by a number of ‘three phase’ motor designs, being inherently more reliable, more efficient, and cheaper to produce without mechanical carbon brush commutation. Motors with three power connections use three half-bridges, or six switches in a ‘three phase bridge’. This design uses three L6387E half-bridge drivers U2, U3 and U4, each requiring only two capacitors and a diode for a complete interface between the microcontroller (U1) and the MOSFET switches. (Note this chip is good for high voltage designs up to 600V, meaning this design is easily adaptable for large mains powered motors).
To the right of Fig 1, Q1 to Q12 are the MOSFET switches. Each switch is using a parallel pair for higher current handling capacity, hence twelve in total. Just to the left are the three half-bridge drivers, each of which has two inputs connected to outputs from the microcontroller.
Efficient motor control is achieved using PWM (pulse width modulation), a means whereby motor connections are alternately and rapidly switched between the positive and negative sides of the supply. In this design the PWM frequency is about 17KHz. Thanks to motor winding inductance this is fast enough for the motor to “see” only a blurred average voltage, which depends on the ratio of times (pulse widths) switched high and low.
PWM is applied either to the high-side, or to the low-side switches. Traditionally PWM has been applied to the low-side, simply because in older discrete designs this was often easier. Additionally, the voltage needed to drive the low side switches is only a few volts, always readily available from internal low voltage regulators. Not so for the high side switches, which need the control terminal (‘gate’) to rise and fall through the full supply voltage and more to a few volts above that of the supply in order to turn on satisfactorily. This extra voltage is developed and stored in the ‘bootstrap capacitors’ C17-C19. This is the idea of “pulling yourself up by the bootstraps” which works by charging the capacitor through the diode when the low-side switch is ‘on’. Then later with the low-side 'off', when the high-side switch is turned on, the charge on this capacitor is sufficient to drive the MOSFET gate to turn the switch on. This all works very nicely while the bootstrap capacitor gets recharged for long enough, and often enough, and to ensure this it proves advantageous to PWM the high-side. It is no more difficult any more, we simply need to configure the microcontroller for this.
To complete discussion of the power electronics, the negative side of all the low-side switches connect to R7, a 4-terminal current-sense resistor, designed like an ammeter shunt. A few millivolts, proportional to the motor current, will be developed across this which is fed to an amplifier within the microcontroller. The amplified voltage is compared to a preset level under software control such that a variable cycle-by-cycle current limit may be implemented, useful for torque control as well as safety.
The STM32G4 microcontroller is where the magic happens. One of the on-board ‘Advanced Control Timers’ is configured to produce all six output control signals, reducing the rest of the motor controller design to little more than ‘a walk in the park’.
Elsewhere on Fig 1: U10 is the CAN Bus interface. This is used to accept commands from a central control system of some sort somewhere, and to report speed, current, temperature etc back. Any reasonable number of motor controllers may be connected to the same CAN bus, each being uniquely identifiable from a unique ID within the STM32.
The brushless motors used in loco designs are ‘sensored’, with triple Hall effect sensors which together give an indication of instantaneous rotor angle. The wires from these connect to microcontroller inputs using a few resistors, capacitors and diodes to protect against static damage. These sensors are crucial inputs to the six step algorithm, which adds to the impetus to miniaturise the motor controller such that it can be fitted close to the motor so keeping wiring as localised and neat as possible.
Several of the microcontroller analogue-to-digital converter inputs are used to enable measurement of instantaneous phase voltages, supply voltage and current, and switch temperature. Oh, and there’s a potentiometer for those who like that sort of thing.
U5 and U6 provide a buffered UART serial port for test and development, but could be repurposed.
At the bottom of the page – voltage regulators to provide local supplies of +12V for the half-bridge drivers, and +5V and +3.3V for the rest of the electronics.
A 12V fan may be activated (or not) by Q13. This has proved redundant so far as the Baby Deltic loco is concerned, thanks to adoption of a variant of the six step algorithm including “quasi synchronous rectification”, reducing switching losses to negligible levels.
Ever so simple “six step” barely tickles the high performance microcontroller, which has the capacity to run many of the more exotic computation intensive vector control algorithms. It happens that six step is very well suited to tight control at high torques and speeds down to zero and below (recover from rolling back), just what we want for relatively low-tech brute traction.
Although designed for three-phase motors, this design is also good for efficient control of dinosaur two-wire motors.
That’s it for the motor controller hardware. There is also, of course, the software, of which more anon.
EMC26 – Software.
The hardware description covers what’s needed to build an electronic motor controller. An introduction to the software will hopefully provide ideas on how best to use it.
To get the best from modern motors and controllers it might help to consider some new thinking.
Looking back a decade or two, the cost of motors has risen at probably a little over the general rate of inflation due to prices of copper and rare-earth magnets. At the same time the cost of electronics has fallen considerably year-on-year. The balance has shifted. The argument today is to use multiple lower cost controllers to better look after expensive motors.
Consider Fig 2 and Fig 3 above. Many locomotive designs use the model of Fig 2, with one high-power controller feeding all motors. This works well enough while everything is in good order, but there's no way of knowing when something fails, and one failure may bring forward further failures. With no means of monitoring motor conditions, this is an inherently unsafe, or unreliable, design.
While the setup of Fig 3 appears more complex, EMC26 controllers are much smaller and lower cost than one big controller, and the digital loco controller can monitor the state and performance of all motors all of the time. With power electronics removed from the loco controller, this too may be small and low cost.
The EMC26 controls one motor, and will often be sited near to it, possibly at a distance from some higher level controller of all things. Moving away from ‘one controller – many motor’ topologies, power electronics can be sited closer to the area of power consumption with advantage (keeping wiring tidy etc). Considering the motor and its controller as a single entity is useful, a system accepting commands, delivering motion, capable of reporting back.
Any practical number of EMC26/motor units can be looped together using the CAN bus. Units may react to commands addressed to it alone, or to ‘broadcast’ commands to all. Each is able to respond to queries addressed to it, reporting back data such as speed, voltage, current, temperature etc.
Thus the higher level controller is able to know at all times how all motors are performing. For example, in a locomotive with however many motors each driving an axle, at any instant, it’s reasonable to expect all motors to be driven to a similar voltage, to draw a similar current, to be rotating at substantially the same speed, with the controllers at a similar temperature. Detection of any anomaly could be used to trigger an alarm. With this system there’s no excuse for not knowing of problems such as wiring faults, loose drive pinions or broken mechanical drive parts.
Whenever a new motor type has been encountered, essential data about that type has been added to a motor data software library. There is one ‘special’ motor type entry, and that is ‘Not-A-Motor’. This is as part of the design for safety. When power is switched on, the controller comes out of reset and loads ‘Not-A-Motor’ data by default. This data set ensures no type of motor attached may turn. A central controller will be expected to inform each EMC26 of the type and use of motor attached to it. In response the EMC26 ‘sniffs’ the motor connections, and only if it reads believable measurements in line with stated motor type does it then become configured as any kind of motor controller, ‘Ready’ to run. Knowing motor data ensures the motor is never overloaded, never subjected to over-voltage, and never able to draw more than rated current. The motor will never ‘burn out’, being protected from all but external mechanical damage.
A ‘Watchdog Timer’ is part of the safety system. This is a counter that counts down towards zero. It is necessary for the appropriate command to be delivered over CAN bus at least once per second to reload the watchdog. If this should fail, and the watchdog ever counts down to zero, this applies a hard-reset to the EMC26 which will then revert to ‘Not-A-Motor’ and cease to drive any motor. This is one of a number of safety features.
EMC26 users need some means of sending and receiving CAN bus frames using 11 bit ID. A few simple commands are all the user needs to know.
The software programmed into the EMC26 controller will be of no interest to users, but is on github for anyone interested.