This is my new ESC board that I’ve designed. I’m more than happy and proud of the results.
It works very nice just as I would expect from a commercial ESC. It is made with the
ATmega328 chip and it is programmed in Arduino. Two years back I’ve made my first ESC with
this huge board. This already had some sort of BEMF implemented. Then I’ve made a second
model with PWM input in order to control the speed. Finally, I’ve made this board that
has everything a normal ESC should have. It has a buck converter on board for 5V, PWM
input signal for speed control, USB programming, BEMF detection with very good precision so
it could reach very high speeds and also control the torque and it is programmed in Arduino.
This is total open source and I’ll put the circuit and the code below this video if you
want to make an ESC yourself. I will show you how the circuit works in order to control
the rotation of the motor and detect the BEMF, how I’ve designed the board, how to solder
everything and I’ll also explain the code a little bit. We will also see some test and
results of this new board. I will try to explain all I can about this ESC and about ESCs in
general. For more, please watch my other two videos about ESCs. Before we start, make sure
you hit the like button and the notification bell in order to see my future videos.
Also, thanks to all my PATREONS for the support. So, let’s get started.
What’s up my friends, welcome back. Let’s start by
looking at the main characteristics I wanted for my board. Just as any other ESC, I wanted
to have a voltage regulation circuit. Using this MP23 07 buck converter IC and a few more
components such as the coil, resistors and capacitors, I can get 5V from the main input
of 12V or more. I also wanted to have a USB programmer and I’ve used this CH340 that
will create the serial signals so I could program the chip using the USB cable. The
chip I’ve used is the ATmega328, which is the same microcontroller the Arduino is using.
I also wanted my board to have a PWM input to set the speed just as a commercial speed
controller. So, for that I have these 3 pads with GND, 5V and PWM input and in the code,
I create interruptions and read the PWM signal value in us. I also wanted to have a calibration
mode which is a very common part for ESCs. If you start the ESC and the input is higher
than a certain range, it will enter into configuration mode where you could set the range of the
input PWM. Here is an example. I put throttle joystick in the middle and I connect the radio
receiver. I start the ESC board and the LED is flashing and waiting. I increase throttle
to maximum and just after that I put throttle to minimum. Now the LED is flashing different
and the new range was stored to the EEPROM of the microcontroller. Now I could just increase
throttle and the motor will spin. I also wanted BEMF detection, so the motor will always stay
in sync and also have good torque. Even if I try to stop the motor it will stay synchronized
due to the BEMF read. I do that using some voltage dividers with these resistors and
using the integrated comparator the ATMEGA chip already has on digital pin 6. To control
the motor rotation, I have these MOSFET bridge with 6 transistors. To control the transistors,
I’m using 3 dual drivers, the IR21 01. This board has some small errors but I’ve already
corrected that in the final board. For example, GND was not connected to the buck converter
chip so I had to make that with wires. I also wanted a buzzer but by mistake I’ve connected
this component to a non PWM signal so I now have a LED instead. But in overall the board
turn out great, it is only 60 by 35 mm and I’m sure I could make it even smaller. The
next board will also have the main power tracks exposed so I could fill those with solder
for more current. So, these are the main characteristics of my board. Let’s now see how it works.
Once again, please watch my other ESC video because I share all the details about BEMF,
zero crossing and all you need to understand about sensor-less ESCs. We need this kind
of ESCs to control brushless motors. These motors have a triple phase input and 3 coils
inside, coil A, B and C. We have 3 coils but we could have different amounts of poles,
in this animation I’ve used a motor with 6 poles and 4 permanent magnets. In order
to rotate we have to switch the inputs of these coils in a certain sequence. Usually
we energise 2 coils at the same times so one will push the magnets and the other one will
drag the magnets. In order to make a full cycle, we need 6 steps intervals for our sequence.
We energise coils A and B and we leave C floating and the magnets will make one step. Then we
energise coils A and C and it will make one more step. Then coils B and C till we make
all 6 steps as in this table. The important thing is to know when to switch from one step
to the other. We could use hall effect sensors for that but in this case for a sensor-less
ESC I will use the BEMF or back electromotive force detection. As I said before, on each
step we energise 2 coils and we let one coil floating, that means is not connected to anything.
Rotating a magnet in front of a coil, according to Faraday law, it will induce a current in
that coil, thus we get a voltage drop. We could measure this voltage drop and we will
detect a peak when the magnet is just in the middle of the coil since there is where the
magnetic flux is higher. If we sum all the voltages from all 3 coils together, we get
the common ground, and we compare the floating coil voltage drop with the entire sum, and
by that, we detect when to make the switch to the next step of the sequence. This is
the representation of the BEFM voltage from the coils. We have to make the switch to the
next step exactly when crossing this virtual 0, which is the sum of all 3 coils. That’s
why this method is called zero crossing switch. We cross this zero-line when the BEMF is rising
or falling and in the code, we will have two different detection parts for that. So, all
we have to do is to compare the voltage drop on the floating coil with the sum of all 3
coils and when we detect the 0 cross, we change to the next step of the sequence. To compare
signals, I’ve placed some voltage dividers on my board and I’m using a comparator to
detect the 0 cross. We could use an external comparator, but the best way is to use the
comparator our microcontroller has on pin D6. To energise the coils, I’m using the
MOSFETS controlled with a precise PWM signal. See more about this on my other video. So,
this is my schematic. I have the voltage regulation here, the MOSFET bridge and the drivers here,
the ATmega328 microcontroller, the FTDI programmer, the voltage dividers for the BEMF detection
and some extra connections. I’ve made this layout and remember that this version has
all the errors fixed and some improvements as well. I’ve ordered the board from JLCPCB.
I’ve made the boards with red solder mask and white silklayer. Let’s give them a look.
We’ve already seen all the components we need. We have the MOSFETs here and the triple
phase output on these pads. On the left side we have the buck converter circuit and on
the other side of the board we have the microcontroller, the programmer and USB connector, the MOSFET
drivers and the voltage dividers for the BEMF read. Let’s mount this board. First thing
you have to do is to solder the buck converter circuit and make sure its output will be always
5V. So I solder the MP23 07 buck converter IC, the coil and the resistors and also all
the output capacitors. We need a lot of capacitance at the output since there will be a lot of
voltage peaks when the motor will draw a lot of current. Remember that I had to connect
GND with this wire for now till I received the fixed boards. Now I supply 12V at the
input and test the output to see if it is around 5V. I also change the input and the
output is always 5V so we are good to go. Next, I solder the ATmega chip, the 16MHz
crystal, the R1 resistors and the C2 and C6 capacitor. C6 must be of 100nF for the DTR
pin. Now I connect this external FTDI programmer to the UART pads here to the RX, TX and DTR
pins and also GND and 5V. I upload a test that uses the serial communication and test
if the chip works. If yes, it means we have soldered the chip with no problems. Now I
solder the FTDI programmer and the R18 and R19 resistors. I also solder the USB connector
and after I do this, I upload the same code again but this time, using the USB connector.
If you are able to upload the code, you could keep soldering components. I solder all the
small resistors, capacitors and LEDs following the values in the schematic. Then I solder
all the MOSFET drivers and diodes. On the other side I solder the MOSFETS and the board
is ready. All I have to do is to upload the code and also solder 3 wires to the GND, 5V
and PWM signal pads here. Then I upload the code and connect a brushless motor at the
output. I now connect my PWM radio receiver to the PWM input wires. I start my radio controller
and then I power the ESC board with 12V from my power supply. The ESC turns on and the
LED will blink. Now I increase throttle and the motors starts spinning.
I can reach very high speeds compared with my other versions.
The code is now a lot better.
The BEMF detection is also better
so I can try to stop the motor but it will adapt its speed and always stay synchronised.
The response speed is also very good.
And remember that you could change the
PWM input range only with your radio receiver and the range will be stored to the EEPROM of the microcontroller.
Now I have connected the PWM signals of the DRIVERS to the oscilloscope
just to see the results. As you can see the faster the motors spins, smaller is the time
between the PWM signals. And if I try to slow the motor down, the signals will automatically
synchronise. I now have the motor coils connected to my oscilloscope in order to see the signals
of BEMF. There is a lot of noise but we are close to the BEMF representation we have seen
before in the animation and if I stop the oscilloscope, we can see the signals a lot
better. Now the code is quite long and a bit difficult. But I’ve place a lot of comments
for each part in order for you to understand it better. In the setup void we first make
the configuration, we save the data to the EEPROM, we set the PWM registers configuration
and set the pins to output or input, we detect the PWM input range and store the new values.
Now let’s go at the bottom of the code. This is the interruption vector that reads
the PWM input signal on digital pin D8 and gives the value in us. In the void loop we
detect the range of the PWM input and start or stop the motor rotation according to that.
If the motor is spinning, we first have a short loop to accelerate the motor without
BEMF. Then we use the BEMF functions to maintain the speed. Remember we have 6 steps for our
sequence. Here we change the BEMF detection for rising or falling on each coil. This will
change the input of the comparator on pin D6, and by that we can compare all the coils
and change the step of our sequence. Finally, we have 6 more functions that will set the
pins to HIGH or LOW, to PWM or not PWM depending on which step of the sequence we are. A high
B low, A high, C low, B high, C low and so on. Download the code and read all the comments.
Upload it to your board and give it a test. In my opinion, the results are quite good
and close enough to a commercial ESC. This was a long project, I had a lot of errors
but I’ve learned a lot making this board and I hope you do the same. Using the same
schematic but with bigger MOSFETS, bigger tracks and more capacitors, you could create
the same ESC but for bigger motors and customize your speed and BEMF detection. Feel free to
download the board, part list, schematic and code from below and make the same ESC yourself.
Consider supporting my work on PATREON so I could make more future boards. I hope that
you’ve liked this project. If so don’t forget to click the like button like crazy
and share the video with your friends. If you have any question about this video or
any other, just leave it in the comment section below or on my Q&A page. Also, don’t forget
to subscribe and watch all of my other great tutorials. Remember, if you consider helping
my projects check my Patreon page as well. Thanks again and see you later guys.