what's up my friends welcome back in the
past tutorial we have built an
electronic speed control for brushless
motors this is the bolt from that
tutorial and it's based on Arduino this
is an ESC for sensorless brushless
motors so in that video I show you how
to detect the position of the rotor
using the back electro-motive force but
that made the circuit quite complicated
and also the code that I use is not the
best neither so in this tutorial we'll
build another electronic speed control
for brushless motors and also improve
the code so guys here is what we are
going to do I will take a brushless
motor out from an old CD writer one like
this one we will build a circuit to
amplify the signals out from the hall
sensors then we will build the triple
phase bridge and the speed controller
and finally using interruptions will
read the PW input from a radio receiver
and control the speed of the motor with
that signal just as any convention and
the transmit control would do so let's
start it this project is brought to you
by jl c PCB which is a manufacturer of
quick PCB prototypes for more than 10
years and is the site that i use for all
my pc b--'s once design applaud your
Gerber files on the GL c PCB site get a
full review of the PCB select your
desired settings and order the PCB for
amazing prices i've ordered ten of my
prototype PCBs for only $2.00 and
receive those in six days crazy right
so order your quality PCB and make your
projects look a lot more professional
what's up my friends welcome back for
this tutorial I've got a sensor
brushless motor like this one that
already has the sensors amplified and
each of the three sensor outputs here
but unfortunately this motor is too big
and requires a huge amount of current to
spin and while making tests I've only
bought my breadboard but the motor
didn't even spin so I've lowered the
level of this tutorial and went with
this motor this is a brushless triple
faced motor that I've took out from an
OCD writer not all of the CD or DVD
writers use sensors motors but this one
does I take the motor out and take a
first look I open it and as you can see
I have the coils of the motor and three
very small hole sensors that will detect
magnetic fields
each sensor has four pins two for the
positive and negative output and two for
the supply we will have to supply five
volts and ground to each of these
sensors and then we will compare the
negative and positive outputs in order
to get our sensor signal we know that we
have nine poles and that the sensors are
separated 40 degrees one to each other
so it will be very easy to detect the
position of the motor
the first thing to do is to identify the
pins using the multimeter I've managed
to find each pin in this case we first
have the positive and negative outputs
of the whole sensors the positive and
negative supply and each input of the
three coils of the motor but for the
final project I've used this motor from
another CD writer that you can see here
on this PCB and the order of these pins
is different this is the order for this
motor that I've used I've solder some
wires to each of these pins if you buy a
censored motor the whole sensor are
already amplified so when the magnet is
in front of it you will get a low or
high value in this case ground or five
volts as you can see here on my
oscilloscope when I rotate this
commercial censored motor but our whole
sensors have no amplifying circuit so
that's the next thing to do this is the
schematic for the motor we supplied five
volts and ground to the sensors and then
we'll connect each of the negative and
positive outputs of each sensor to a
comparator in this case I will use the
LM 3 - 4 IC since it already has four O
Pam's
each time the positive output from the
whole sensor is higher than the negative
we'll have a high polls at the output so
we can detect positive or negative
magnetic fields I solder everything on a
piece of dual PCB like this one remember
to add a 100 ohms resistor between 5
volts and the hall sensor positive
supply to limit the current
here I have the three inputs for the
motor coils with black wires ground and
five volts supply for the sensors and
each of the sensors amplified outputs I
power the PCB and connect the
oscilloscope to sensor output amb
now I spin the motor and as you can see
we have a square signal for each pin
with one third of phase difference
between each signal now I connect sensor
a and C and as you can see we now have
two turfs phase difference these three
signals will help us know the position
of the rotor okay guys so let's look
once again on how the brushless motor
control will work I suggest you to take
a look on my other tutorial on the
arduino based electronic speed
controller our motor has three coils I
know that inside we can see nine coils
but the truth is that these are three
coils wound it online polls on the
exterior of the motor we have 12 magnets
this motor uses magnetic strip so we can
see the 12 different magnets but there
are 12 different polarity magnets as we
can see here on this other brushless
motor this is the representation of our
motor we have nine poles on the stator
12 magnets on the rotor and three
sensors
since we have three calls we will have
three inputs a B and C so we will need a
triple phase bridge to control this
motor in order to control the rotation
speed we'll have to apply power to these
three inputs in a certain sequence we
start with positive power to the a input
and ground to B we leave the C input
floating with nothing connected to it
that will create a magnetic field in the
a coils that will push the rotor on to
the right and into the big coils that
will drag the rotor to the right as well
since positive with positive are
repelling and negative with positive
will attract but if we don't switch the
inputs the rotation will stop here for
that we switch to the next part of the
sequence we leave be connected to ground
but now we apply positive power to
see input instead of a that will make
the sequel's to direct the positive
magnet even more and if we keep
switching the inputs we can create a for
rotation this is the sequence that we
have to make we enter through a and exit
on B then we enter on C and exit on B
and so on with a total of six different
steps but how do we know when to switch
to the next step well here comes the job
of the sensors so let's place those on
our motor representation right now we
are in the first step of the sequence so
we have negative positive and another
negative magnet in front of the sensors
that will give us a 1 0 1 output we keep
on spinning and the a whole sensor will
now pass to 0 since now we have a
positive magnet in front of it the other
two sensors are still the same so now we
have a 0 0 1 which is the next step of
the sequence during a full rotation
we'll have this sequence of the hall
sensor outputs as in this table here so
all we have to do is to detect these
steps with a microcontroller and control
the triple phase bridge this is the
triple phase bridge schematic on the top
side I've used P MOSFETs and on the
bottom part and channel MOSFET since the
source is connected directly to ground
in the past tutorial of electronic speed
controllers we have used a MOSFET driver
to control the transistors since the
microcontroller works at 5 volts but we
will apply a higher voltage than that to
the MOSFETs I won't use a driver this
time in order to keep it simple and just
understand how this works instead I'll
make my own driver with a BJT and a
pull-up at the gate of each MOSFET when
the top a MOSFET and the bottom B it's
activated current is flowing to a and
exit on the big coil next we activate
the C MOSFET and lift the bottom be
activated so now current is flowing from
C to B and so on as you can see on each
step we control two of the MOSFETs one
from the top part of the bridge
and the other one from the but apart
this is the schematic of my censored
electronic speed controller I mounted on
my breadboard and tested to make the
sensor read and the MOSFETs which I will
use the arduino i connect a BNC sensor
outputs to pin 8 9 and 10 of the arduino
then pin 7 6 5 4 3 and 2 to the 6
MOSFETs of the bridge i connect a
potentiometer to analog input a 3 in
order to control the speed of the motor
hour later supply 12 volts to the main
input rich but we are now ready for the
code so let's take a look i define the
sensor pins as inputs next with these
registers i configure pins 8 9 and 10
to create interrupts so each time one of
these pins will change this state will
go to the interrupt vector here we
detect the sequence and decide the phase
of the rotation depending on the state
of the hall sensors if we have a 1 0 1
we switch to the first step if we have a
0 0 1 2 the second step and so on as in
the table before with a total of 6 steps
easy right so now in the void loop we
create a case that will switch to
MOSFETs on each step of the sequence
depending on what step we are on that
sequence in this case I will use port
manipulation instead of digital right
since that is a lot faster this is one
of the improvements from the other
tutorial using port manipulation it's
way faster than using digital right I
read the potentiometer speed and create
a delay between each step according to
the potentiometer read value mapped with
a value from 1 to 4 thousand
microseconds please read all the
comments in the code in order to
understand more I upload a code and make
sure that all the connections are made I
supply the circuit and as you can see
the brushless motor is now spinning
I connect the probe of my oscilloscope
to one of the MOSFETs gates as you can
see we have a square wave signal but if
I try to slow down the motor with my
hand the weight of the post will
automatically adjust in order to match
the speed of the motor and let's do to
the hall sensor feedback also using the
potentiometer I can set the speed of the
motor by changing the delay between each
step of the sequence but usually
commercial electronic speed controller
use a PWM signal input with a width
range between 1000 and 2000 microseconds
to control the speed so for that in the
code i set pin 11 as the pwm input now
in the interruption vector I detect each
time that that pin changes state and
measure the time between each pose I map
that value to a delay from 3000 to 10
microseconds you are able to make some
tests and change these values according
to your motor now I add another part to
the code so the motor will start
spinning only for values of PWM input
higher than 1070 which is a very common
value now I make the test once again but
now using my radio transmitter and the
PWM receiver so as you can see I can
control the speed and start or stop the
motor with my radio receiver
so the code kind of works I say kind of
because it's not perfect now I use this
final schematic that you could find in
the link below and mount the entire
circuit on this drill PCB and using the
atmega 328 if with the 60 megahertz
crystal oscillator and all the
components that we need to make it work
I also have a 5 volts voltage regulator
for the atmega chip and that will also
supply the op-amp for the motor sensors
I use an external FTDI module i connect
the RX TX & DTR pins and upload the code
the PCB has an input for the PWM signal
from the radio receiver and shares both
5 volts and ground here we have the
output for the 3 calls of the motor and
the input and supply from the Hall
sensors and that's it this
is my prototype of a homemade electronic
speed controller for sensors brushless
motors so guys we control each of the
six transistors of the triple phase
bridge we have a whole sensor feedback
in order to know the rotor position and
adapter speed automatically we have a
PWM input control just as any commercial
electronic speed controller and we have
also looked on how to amplify the hall
sensors so there you go my friends we
have built our homemade electronic speed
controller for sensor ed brushless
motors have in mind that this is just a
prototype it's not very powerful still
have a lot of parts to improve in both
the circuit and the code and is more for
learning purposes anyway I hope that
this tutorial helped you learn a bit
more on how sensors ESDS work and how to
build one if you want to increase the
voltage and power use better components
maybe use IGBTs instead of MOSFETs and
also add some drivers in case you use
MOSFETs always check the data sheets of
each component and see its maximum
values as you have seen at the beginning
using way bigger motors the transistors
only got hot but the motor didn't spin
at all for small motors you could use
bipolar transistors as well and if you
use n channel mosfet for both the upper
part of the bridge and the bottom part
as well which by the way it's not
recommended check the code and change
the output values I say that because in
our case we activate the n-channel
MOSFETs with a digital write low since
we have a BJT transistor as a driver at
his gate and the p-channel MOSFET with a
digital write high so if you use
different MOSFETs you might want to
change these values here in the code
also don't supply power to the circuit
if you're not sure of all the
connections check all the schematics
part list and codes below and more
information on my webpage electronics
come if my videos help you and you would
like to help my projects like this one I
have a patreon campaign the link is down
below as always I would really
appreciate that guys so I hope that you
enjoyed this tutorial if so don't forget
to click the like button
like crazy and share this video with
your friends if you have any question
about this video or any other just leave
it in the comment section below or my
Q&A page also don't forget to subscribe
and watch all of my other great
tutorials and remember if you consider
helping my projects check my patreon
page as well thanks again and see you
later guys
[Music]