Design of a 'Smart Regulator'

Introduction - leading on to Circuits and 'How It Works!'

Some time ago, I embarked upon a study of petrol electric power systems used in 5” and 7.25” locomotives, looking in detail at how they work, and why performance so often falls short of expectations. This work is now almost complete, and thanks to Bob Lilley and Andy Harding, a grand day out was had at Ashton Court on 22nd July 2020. The purpose of the day was to prove in practice an idea that had evolved along the way, a Low Cost Locomotive design. This uses an engine driving a modified vehicle alternator, wired directly to DC traction motors. No heavy traction batteries, and no other motor speed controller are required. Not owning a loco with DC traction motors, the idea was to borrow ‘Michigan’ for the day, disconnect the motors and power them from my test generator set hauled on a following trolley. All present agreed the day was a great success. The theory tested and proved in practice. Using an engine with a rated power of 1.1kW, the configuration was not as powerful as an unmodified Michigan with its 1.6kW engine, but allowing for this, the performance was comparable.

The journey so far. I talked and listened to owners and users of a number of petrol electric locos, and have previously done some work on ‘Michigan’. In systems with small petrol engines driving vehicle alternators the same problems crop up time and again, engine stalls being top of a list of ‘bad behaviours’. It soon became apparent that all these problems stemmed from the same root, that vehicle alternators are not designed for this. They are designed to be small machines strapped to much larger engines, where the engine isn’t going to be affected by any loading imposed upon it by a tiny alternator. This is not the case when using small engines because of the hopelessly mismatched torque characteristics. Engines tend to have a substantially flat torque characteristic over the useable speed range. As rotary power is the product of angular velocity and torque, it follows that in contrast, alternators produce power from high torques at low speeds, and low torques at high speeds.

In addressing this torque mismatch problem, absolutely no time was wasted trying to design a new petrol engine! The only viable proposition was to find a way of moulding alternator torque to suit any small engine we might choose. This, inevitably, means re-designing the alternator to some extent, ensuring engine load torque remains safely below stalling torque.

The alternator regulator is much misunderstood and shrouded in myth. As designed it has one purpose only, which is to maintain a constant output voltage under all circumstances while the engine runs. For a detailed description see ''Making Engine / Alternator Sets Work Nicely Pt 1'' under the 'Vids' tab. This includes a practical experiment proving the regulator is just a voltage operated switch, explains in simple terms how it works, and why this is no good for our purposes. When delivering any level of power, if engine speed falls, load torque is increased as the regulator increases field current in the attempt to maintain output voltage. This rising load torque causes further speed reduction, causing further torque increase, and we see we have have a system almost perfectly designed to stall small engines!

Our engines and alternators can be made to work together nicely by coming up with a more suitable regulator, a ‘Smart Regulator’. At very least a new regulator needs more than just a single ‘voltage’ input, a second input for engine speed is also needed. Then at its simplest, the new regulator could also open the switch whenever engine speed falls below some minimum. This would cut field current to zero, which reduces load torque to almost nothing (that due to friction and fan drag), reduces power output to zero, so averting engine stalls. Taking this idea a stage further, we could write a table (a lookup table) of maximum permissible field currents over a number of engine speeds from zero to max. By making entries easily accessible and changeable, users can make the alternator torque characteristic any shape they want. (This is implemented as a list of percentages relating to engine speeds of 0, 200, 400 … 4200 RPM, easily set via USB from a laptop).

Designing a new regulator brings opportunities to reject other constraints. The output voltage does not have to be ‘fixed’, it could be variable, or fixed at a different voltage. For a system with batteries the voltage will have to be fixed to suit the batteries, but if we chuck out the batteries the voltage could be variable.

Car alternators are designed to be used over speed ranges of maybe six to one. Our small engines are unlikely to have a useful speed range much beyond two to one, so by choosing belts and pulleys to operate alternators towards the high end of the rated speed range, we can, for example, use a 12V alternator to power a 24V system. The system successfully tested at Ashton used a 12V Lucas alternator in a 0 to 28V variable configuration.

Nucleo Control Computer

To provide the ‘intelligence’ needed, the smart regulator was designed around a 32 bit ARM Cortex M4 processor with built in floating point maths co-processor. For under a tenner you can buy one of these on a ‘ST Nucleo L432KC’ development board with USB connection for programming. This was selected. An EEPROM was designed in costing a few pence more. This is to contain any user setup options, including entries for the field current limit lookup table.

Making the most of the well resourced and powerful computer, peripherals designed in included an engine interface to measure engine speed, a servo for setting engine speed, voltmeters to measure driver’s control pot, alternator output and field voltages, an isolated ammeter capable of measuring output or battery current, a temperature sensor, a GPS module useful as a ground speedometer, a pressure sensor (possible use for vacuum brakes), with some spare logic inputs and outputs. An analogue PWM (pulse width modulator) subsystem regulates alternator output in the same way as the original regulator, except that this time we can choose the voltage. This also enables the computer to override and limit PWM duty ratio to lower output, to limit torque, so averting stalls. (Photo)

New Smart Regulator lashed up

Software development was made easy by use of the free online development system from This will look quite familiar to users of Arduino, uses worldwide industry standard ‘C’ and ‘C++’ programming language, makes available a huge library of code modules for any device you might think of connecting, with too many useful features to list.

So much for the easy stuff. All the troubles and vexations start and end with the mechanics. To test the theory in practice a test rig was assembled using a Honda GX35 engine coupled inline to a Lucas ACR alternator. After running for probably less than an hour the drive coupling failed. A second attempt was made using a more substantial drive arrangement. This too failed in short time. Having by then deciding this high-revving 35cc engine was far too noisy to make it into any final loco design, a new start was made, a quieter engine was sourced, a Lifan 79cc, and a new test rig built, this time with engine and alternator coupled by drive belt instead of the failed inline configuration used with the Honda. Although more than twice the cylinder capacity, the new engine rated power is only 1.1kW compared to the 1.0kW rating of the Honda. So far this new rig has worked well, but although the alternator doesn’t care about rotational direction, the cooling fan does. On the failed rig rotation was in the ‘correct’ direction for the centrifugal fan to work pulling air through the alternator before casting it far and wide around the pulley. Now rotation is reversed and the fan will have little if any beneficial effect.

New Mk II Test Rig

With the whole system together serious testing could begin. A dummy load was built consisting of a rack of ten, 60W 24V filament lamps, switchable in pairs. A number of ‘Operating Modes’ were coded including an ‘Auto Test’ mode. This runs the engine speed up in small steps measuring voltages, currents, speeds and other parameters at each stage, sending data via USB to a laptop for later spreadsheet analysis. Repeating auto test with different loads helped build a good picture of overall performance. Other modes for ‘fixed’ voltage using voltage change or current load to regulate engine speed are in there, but of more interest for a quick win with an interesting loco project, the ‘variable voltage’ scheme was paid greater attention. In this mode field current is held at zero for low engine speeds to avoid stalling. The driver’s pot is configured for power ‘off’ for the first 10% or so of range and controlling engine speed for higher settings. The smart regulator lookup table is set to give higher output at higher engine speeds. Turn the control up – get more power. It’s that simple.

Day Out at Ashton Court Railway

Preparing for the day out, the generator set was installed in the chassis of the Brushless Brute loco with the driver’s pot and an emergency engine stop switch temporarily clamped to the control panel. On arrival at Ashton this was connected and coupled up to Michigan (Photo), and a number of laps were completed. Having driven locos with batteries and mobility scooter controllers, I find it very dull setting the control to ‘6’ or whatever and then just completing laps with no need to think. The Low Cost Loco design needs to be driven, that is to say the power setting needs to be altered according to track gradients and conditions. More like driving a steam engine, less like a mobility scooter. A driver’s eye view of a lap can be seen in ''Low Cost Loco Test - Bristol - July 2020'' under the 'Vids' tab

Circuits and 'How It Works!'

Smart Regulator

How It Works

The Smart Regulator is designed to replace the regulator fitted to vehicle alternators, to regulate alternator output and to provide a range of new functions. This enables alternators to be driven from small petrol engines without all the problems usually associated with such schemes – stalling, difficult starting and more. By making it a relatively simple matter to tailor alternator load torques to better match engine torque characteristics, systems using a small petrol engine, modified vehicle alternator and Smart Regulator, can all be made to work nicely together.

Systems with or without traction batteries are covered. Systems in which the generator acts as float-charger are ‘fixed’ voltage systems. With no large traction batteries, in systems where the alternator provides all the power required at all times, output voltage does not have to be fixed, but could be ‘variable’.

The schematic is on two sheets. Starting with Sheet 1.

P1 and P2 are the screw terminals connecting all high power circuits. P1,4, net ‘BATT_DYNAMO’ is used with variable voltage systems with no large traction batteries. Here a small battery or dynamo connects providing minimal power for the electronics, along with power for the alternator field winding when output voltages are low. This pin is not connected in systems with traction batteries.

P2,1, net ‘POWER_OUT’ connects to the alternator positive output. This is used by the voltage regulator, and a copy is also read by an internal voltmeter.

P2,2, net ‘FIELD_POS’ connects to one end of the alternator rotor field winding. Internal to the alternator, this may also connect to a rectifier positive output. This connection needs some positive voltage bias for the system to operate. This may be via an ‘ignition’ lamp, or may connect directly to POWER_OUT.

P2,3, net ‘FIELD’ connects to the other rotor field terminal. Mosfet Q1 switches power to the field winding.

P2,4, net ‘ENGINE_SWITCH’ is the magneto output of the engine. Shorting this to ground is used to stop the engine. In the Smart Regulator this signal provides two functions; a signal used by the controller to measure engine speed, and to provide bias to enable U5, a high efficiency switch mode power supply used to power all internal electronics. R16 passes a tiny sniff of magneto signal which is clipped to levels allowable to the controller by diodes Z1 and D4. R2 passes the result to a microcontroller pin for speed measurement. R30 and D5 pass positive current peaks charging C11. This goes to one end of P4, a 3 pin jumper plug. In normal use, a jumper connects pins 1 and 2 passing ‘MAGNETO_RECT’ to U5 enable input, scaled by resistors R6 and R22. When the engine stops, C11 is discharged through R6 R22 and U5 is disabled. This is sufficient to power down the whole system, meaning no external On/Off switch is required. We have Auto Powerdown. U5 takes an input voltage between 10 and 64 volts and delivers a single +5 volt output at up to 1 amp. For details see MAX5035BUSA data sheet.

Q5 and Q6 are used as switches. When the system is powered, mosfets Q8 and Q9 both conduct. These provide bias to turn on Q5 and Q6. When the system is powered down, Q8 and Q9 switch off, removing bias from Q5 and Q6 switching them both off. This removes the otherwise tiny load that feedback and voltage sense circuits would impose on any batteries – all part of the auto powerdown scheme.

U4 is a clever pulse width modulator used to drive the field switching mosfet Q1. Net PWM_OSC_IN is a pwm signal from the microcontroller, the duty ratio of this determines the maximum duty ratio of the output. By varying this the microcontroller can impose limits on output pwm and so limit field current and hence alternator load torque. This is at the heart of making it all work nicely. A sample of final pwm output is taken back to the controller via R26, this is readable by the programme code. Maximum output voltage is set by potential divider R9 R10 R14 R15 such that 1.65 volts is established on net ‘FB’ at full output voltage. This matches the maximum voltage value set by the microcontroller on net ‘PWM_REF’. The microcontroller can set ‘PWM_REF’ at any voltage from 0 to 1.65 volts giving software the ability to override to reduce output voltage. For a full understanding of this section see MCP1630 data sheet.

Sheet 2.

U3 is a Hall effect ammeter device, capable of reading currents up to 37 amp. The schematic shows how it is wired, the analogue output net ‘AMM_IN’ goes to an ‘AnalogIn’ pin of the microcontroller for reading. Use of the ammeter is optional, it may measure alternator or battery current and the two power terminals are galvanically isolated from the rest of the circuit.

U2 is the 24LC64 EEPROM. This is to contain all ‘user setup’ stuff, including a lookup table to match alternator and engine torque characteristics. Connector ‘I2C’ gives access to the I2C bus used by U2. This may be useful for connecting other sensors (temperature, pressure etc).

Connector ‘POT’ is for the loco driver’s speed control potentiometer. For systems using an additional traction motor speed controller, this will connect in parallel with the control lead to that. R27, Z2, R23 and C3 provide limited protection and limiting before connecting the microcontroller AnalogIn ‘DRIVER_POT’.

U1 is the ST Nucleo L432KC computer board. Connector ‘COM’ is a serial port which may be used to connect a GPS module.

U6 is an amplifier, bringing to 0 to 3.3V signal ‘A_OUT’ up to 0 to 5V. In fully ‘proactive control’ systems, U6 output feeds forward to an external traction motor speed controller. In this mode, the signal from DRIVER_POT is process with other signals in an attempt to optimise power use.

The circuitry comprising C25, R41, D8, D9, C24 etc through to Q4 and Q3 form some ‘belt and braces’ for those of a nervous disposition. In normal operation the controller outputs a constant 500Hz square wave signal on ‘CHARGE_PUMP’. This pumps pulses of charge into C24 which, after a few cycles, will have charged sufficiently to make U7 output fall from +3.3V to 0 volts. This turns off mosfet switches Q3 and Q4. Should the charge pump signal stop due to computer crash or deliberate software action, C24 discharges via R40, taking U7 output high. This turns on Q3 shorting its input to ground so forcing U6 output to 0V Likewise Q4 shorts the REF input of U4 to ground so forcing shutdown of the alternator field current.

Data Sheets

24LC64 eeprom

ACS709 Hall effect ammeter

Power supply

Op amp

PWM controller

Gerber files to produce PCB here.

Software will be made available on Contact Jon ffi.