Brushed Motor ESC
27 November 2005
This project documents how to build and construct your own Brushed Motor ESC using aMicrochip 12F675 PICand a small number of standard components. Various test systems are also described that allow the investigation of how ESCs function.
The ESC descibed here is primarily for aircraft. There is anassociated projectthat is designed for cars and boats with features that are similar to commercial ESCs for this application.
Important Note
This information is provided on a 'as-is' basis. Model aircraft are not toys. Construction, and use, of this device is at the users own risk.
Most simple PIC programmers do not verify that the device has been programmed correctly by using high and low supply voltages to the PIC. This type of programmer is not normally considered a production environment programmer and there is a risk that the PIC has not been correctly programmed even when the software says it has been.
Background
There are a number of other projects that have been documented for brushed motor ESCs. The good starting point for other ESCs isthis rcgroups thread. The information in theMicrochip AN847is also very useful.
Most of these designs are very similar, the variation between designs is typically in the PIC used to control the ESC, the precise FETs used, and the number of features that the ESC offers. Some variation is also probably due to the availability and cost of parts.
There were two main reasons that I embarked on this project:
· None of these projects used the 12F675, and this PIC has a number of interesting features. The main one is that being a Flash programmable part it makes a good vehicle for testing ideas and permitting the ESC to be reprogrammed and various ideas tested.
· None of the other designs offered exactly what I was looking for and in addition there was a certain challenge in programming a 12F675 to do this task.
Why build your own ESC
Some of the reasons that you may consider using the information here include:
· You may well be able to get the mix of features you want at a reasonable price. Building your own ESC offers opportunity to get exactly what you want.
· Repair of a DIY ESC may be easier (in Australia repair of ESCs is nearly impossible and expensive). For example, if the output FET fails it can be replaced at modest cost.
· It may provide an additional area of interest for those who like to tinker. You may also want to learn how an ESC works.
· If based on a Flash PIC (eg. 12F675) you can modify the ESC software at no cost. This would included modifying the cut-off voltage, brake type, etc. You could even modify the software to have the ESC record information regarding the flight.
· You can pick and choose the output FET for required current level while still getting the same ESC facilities.
Why not to build your own
There are a number of very good reasons why you shouldnotbuild and fly your own ESC. These reasons wouldn't stop you from playing with this idea to learn how it all works.
· Reliability of the BEC (and to some extent the ESC) is an important safety issue. Modern commercial units with all SMT parts have a high mechanical reliability.
· There may be very little financial advantage if you have access to reasonably priced ESCs. Just the time taken to build the ESC is worth something, perhaps you would prefer to spend if flying!
· Purchasing items such as MOSFETs on a one-off basis is relatively expensive. You may also need to select some components for this design based on what is available to you at reasonable cost.
· The DIY ESC is probably going to be heavier than the SMT based commercial ESCs. This design built with standard components weighs approximately 25gms - see below.
What this ESC offers
This ESC design offers the following features:
· Safety startup, requires throttle be off to arm ESC.
· Signal loss stop, stops motor on loss of valid signal.
· Low voltage cutoff, stops motor on low battery voltage.
· Variable rate PWM output to reduce noise a low speeds and increase efficiency at high speeds.
· Programmable throttle response curves with two sample curves.
· Slow start to protect gearboxes (or fast start if desired)
· Brake, either hard or soft (optional).
· Accurate throttle pulse width measurement.
· Accurate software PWM with rates between 7.6kHz and 2kHz.
· 64 motor speeds for smooth speed control.
· Automatic low and high throttle setting.
· Both braking and non-braking zero throttle positions for use in car applications (optional).
· Lost Model Alarm (optional).
· Glitch counter (optional).
· Reverse output (optional).
Low Voltage Cutoff
The ESC monitors the battery supply voltage and turns off the motor when the supply voltage drops below a preset point. The code as supplied operates the cutoff at 6V, this is considered a relatively safe point. The LM2940 BEC will operate down to 5.6V so stopping the motor at 6V leaves some margin for error. Once the cutoff has detected 6V or less the throttle must be reset to idle before the motor will operate.
The ESC checks the battery voltage every time a servo control pulse is received, or about every 20msec. These readings are averaged over 4 consecutive samples to get a more stable battery voltage reading. Under high load conditions it is possible to obtain a very low reading as the FET switches on, the averaging reduces the chance of a false voltage reading triggering the LVC. If desired the sample size can be increased. An alternative would be to increase the filter capacitor on the voltage sense input, however a software solution permits the filtering parameters to be changed without a hardware change.
The ESC can be configured with two different low voltage points. In this mode the GP3 input (jumper W1) selects which cutoff voltage is in effect.
Automatic low and high throttle setting
When the ESC is powered on the throttle is assumed to be in the 'low' position. After power on you must move the throttle to 'high' and then back to 'low'. The ESC will then arm and sound two short 'beeps' via the motor. This feature assumes that the 'high' setting has a longer servo pulse width than the 'low' setting. So Futaba transmitters will still require servo reverse on the throttle channel.
After the 'beeps' have sounded (1.5 seconds) the ESC enters normal operating mode and will wait for 'low' throttle. This means that if the throttle is advanced during the 'beeps' the ESC will not spin up the motor. So throttle should not be advanced until the 'beeps' have finished.
Slow Start
The slow start operates by advancing the throttle 1 step every time the received throttle setting is higher than the current setting. In practice the means that to go from idle to full throttle takes about 1.2sec (64 * 0.02sec). If the received throttle is lower than the current ESC setting the ESC will wait until two consecutive lower throttles and then immediately reduce the throttle to the selected value.
This behaviour stops one faulty receiver pulse from 'blipping' the engine. With slow start a faulty 'low' throttle causes the ESC to have to build up to the correct setting using the slow start, for smooth flight this is to be avoided where possible. A single pulse filter appears to significantly reduce this problem.
If desired the ESC can be constructed with the slow start turned off. In this case the the ESC will raise the throttle immediately a higher throttle setting is received.
Soft Brake
The soft-brake option uses the throttle PWM engine to gradually applying the brake one step every time the idle throttle is received (about every 20ms). This means it takes approximately 1.2sec for the brake to be fully applied. Flight testing shows that this works well with the gearbox not being subject to sudden changes in motor speed.
Brake Enable
The brake enable/disable via a jumper is an option of this ESC software. This is provided mainly to demonstrate that control of the ESC features via a jumper is possible. One possible use of a jumper is for disabling the brake. It may be convienent to disable the brake without changing the PIC in some aircraft or possibly when testing and evaluating the brake.
Programmable Throttle Response Curves
Most standard ESCs convert the throttle setting into PWM rates using a simple linear mapping. So that 50% throttle corresponds to a 50% PWM. However, a 50% PWM rate is actually delivering only 25% of the full power to the motor. This is the standard configuration of this ESC also.
The design of the software for this ESC makes it very easy to alter the mapping from throttle to PWM rate so that 50% throttle corresonds to 50% motor power.
Of course, other throttle response curves are also possible. Because the generation of the PWM engine is performed by a Perl program you do not need to be able to program PIC assembler to try out your own throttle response curves. (You do however need to be able to write Perl code that converts the throttle value between 0 and 1 into a PWM on rate between 0 and 1.)
The throttle response curve also determines when the brake is applied (if the ESC is configured with a brake). This permits applications where some of the throttle positions have the motor off and the brake off, and other positions have the motor off and brake on.
Braking and non-braking zero throttle positions
The ESC supports motor off settings with and without the brake applied. (This may be of use on R/C car applications.)
Typically the throttle at its lowest setting has the motor off and brake on, then as the throttle is increased it changes to motor off and brake off, and then increasing further powers up the motor. When the throttle is reduced from the motor on setting it first enters a region where the motor will coast (ie. motor off and brake off) and then if the throttle is reduced further the brake will then be applied.
Lost Model Alarm
The LMA is triggered by either loss of throttle input from the receiver for more that 10 seconds or the throttle input being set to a sufficiently negative input (ie. the throttle trim moved as low as possible).
Suggested hardware for the alert is a simple Piezo Transducer the ESC will produce the appropriate AC drive for the transducer. Alternaticly a piezo transducer with inbuilt siren can be used and the ESC produces a simple on/off output. Depending on the volume level that you require the piezo can be driven directly from the PIC, or via a buffer transistor from the unregulated battery voltage.
The LMA siren is driven out of the GP1 pin on the PIC with an active high siren signal.
Glitch counter
The glitch counter can be selected as long as there are no other options using the GP3 input (jumper W1) to the PIC.
The glitch counter counts the number of faulty receiver pulses and 'beeps' the count out on either the motor, or piezo sizen if the LMA facility is configured.
· If there have been no glitches a single long beep will sound.
· If there have been more than 99 glitches two long beeps will sound.
· For between 1 and 9 glitches than number of short beeps will sound. For example, 4 glitches will sound four short beeps.
· For between 10 and 99 glitches the LMA will beep out the tens and then the units with a pause between them. A unit of zero is indicated by a long beep. For example, 13 glitches would be 1 short beep, a pause, and then 3 short beeps; 10 glitches would be 1 short beep, a pause, and then 1 long beep.
Reverse Output
The reverse output is available when there is a spare output pin on the PIC. This reverse implementation is a simple reverse function that is designed primarily for cars (or boats). As such the reverse facility should only be enabled with the the car throttle map (THROTTLEMAP = 3).
The reverse output will toggle state when the throttle is held in the brake position for more that 5 seconds. The output can be used to drive a relay, or could be used as a control input to an H-bridge for electronic reverse.
The output signal (GP1) is low (0 volts) for 'forward' and high (+5 volts) for 'reverse'.
Why use the 12F675?
The Microchip 12F675 offers a number of interesting facilities that are used in this design. These facilities permit a much better ESC to be designed than is possible with a 12C5xx PIC, without the complexity of designs using larger PICs.
· Internal 4MHz oscillator. Not having to rely on an external crystal, or similar, for the processor clock keeps the RFI produced by the PIC to a minimum.
· Two timers. The 12F675 has two timers and what is more important one of them is a 16-bit timer with external count enable control. This feature permits accurate timing of the throttle pulse width to within 1usec. In addition the 12F675 offers interrupts on the 8-bit timer that permit accurate software PWM in parallel with other operations.
· A/D Converter. The on chip A/D converter simplified the low voltage cutoff detection.
· Comparator. The 12F675 also offers a comparator that can be used as an inverter when required (and pinout limits permit).
· Flash Programmable. The 12F675 can be reprogrammed and therefore is an excellent PIC for experimenters.
ESC Challenges
There are a number of important challenges in designing an ESC:
· Accurate timing of the throttle control pulse.
· Accurate PWM generation to ensure the motor speed is even.