hi welcome to nor doing a tutorial from Robojax. In this video we are going to see how we can use
the current sensing feature of this Arduino motor shield to measure the current and then
take some action based on the current for the DC motor either tiny or the bigger one
like this you can get the code for this by clicking at the link of the description which
will take you to Robo Jack sought consolation slash or do we know let's get started with us
a separate video explaining how to use this Foley so you can watch the video the link also
will be provided in the description below so in this video I'm not going to cover anything
about how to use this I'm going to go directly with a current same thing so you have to watch
the other video that I've explained everything and I'm just using the feature on top of the
code that I've provided for the introduction of this shield this motor shield has a current
sensing feature and how it works is that this chip needs external resistor so the current
from each channel A or B will pass through those resistor and then we know by Ohm's law that when
I current passes through a resistor the voltage that appears across the resistor corresponds to
the current so we can know the current and this one already has those two resistors here 0.15 ohm
resistors hecha balls who can accept only after 2 amperes per channel so totally 4 ampere so 2
ampere will pass through this resistor and to imperil pass through this resistor but my tests
showed that anything above 1.5 or 1.3 it will heat up significantly so I use it without a fan
the current appears here at the pen for channel a it will be at a 0 and then for channel B would be
for a 1 so you can have 2 separate motors and measure the current separately and take action
separately if you are using the current sensing you can connect it fourth channel a that a 0 is
connected for current sensing and for channel B a 1 is connected for current sensing this a
1 a 1 and 0 so this is for channel a this is for channel B internally connected to measure
the current of the model we can connect it to since 0 and since 1 it should be read at a 0
and a 1 and there are some internal circuitry that I'm gonna show you next which will change
the voltage accordingly so if you have maximum of two amperes you will get maximum of 3.3 volts so
based on that proportionally we have to adjust and do the calculation 10 span of the chip some span
a and since when B this is going to the ground through this 0.15 ohm resistor and this is for
a and from B also it goes to the ground where the 0.15 ohm resistor if we were to just read
current directly we could read the voltage and by Ohm's law you can get the current but here
the sense B and since they are connected Sir Ian says since we are connected through this
op-amp and they are scaling it and it has been amplified here after that it goes to this sense
one understands 0 since 1 and 0 and then since 1 and since 0 are connected to this analog this is a
0 a 1 as you can see this is e 2 a 3 or 4 so this is a 1 a 0 then that's a 1 so we can read that
here I've created this code for calculating the
current the rest of the code is the same except I've just added
zero and then current since be this is append a felling to that this factor so it gives you
2 ampere at 3.3 volts so we are getting a factor two divided by three point three to
get the current we are getting we are using this one another agreed Kalen sense be I'm using the
B I've defined it here current sense a zero and then current sense B this is append a felling to
that so when am using map saying that between 0 and 1024 map it between 0 to 5 because the
analog tents are reading up to 5 volts and the whole thing because it's I've scaled a thousand
that's millivolts I'm dividing it by thousand and then we are getting the current voltage value and
then we are multiplying the current voltage value by the factors that have calculated this
is a value of two divided by three point three so this will print the current for us I've connected
the motor to or do we know I'm going to move it a little away and for you here this is a
current meter or power meter I'm connecting it and in the meantime you will see the current here
so current at the moment zero in the motor
this is the value that I'm leaving one for you
as you can see the value was corresponding to this one with some variation but it was
one point to one point one five one point two so about hundred milli ampere difference this is not
very precise but you can set the current limit for example detecting if the current is above certain
value or below certain value you can take them some action or prevent something let's say the
motor will heat up or the system will heat up or the current goes above they say one point eight
you can shut off for speed this up or slow it down based on sensing the Academy now I've updated the
code so instead of parenting it directly here I am putting it and storing it in a new variable called
current and they're printing it so if you want to take some action based on the current for example
you can set a current if current is larger than 1.25 then you can do some action here for example
you can apply break you can say break and because this is current sensing B I will say we have to
call it we have to add a B here and then also the same variable is here and also we have to
get the current of current B to be safe because if you're measuring to current this should be current
B and then Kevin B so here we can say F current B is bigger than 1.25 then we can say B break 1
1 mean stop apply break or whatever you want so it was just an example you can do the other way
if the current is less than that go with certain speed or the current increases slow down you can
put any of these other value you can put motor speed or whatever you want you can do that and
here I meet at a little fancy for example you when you detect the channel be current if above
1.25 or whatever value you want then first apply brake be comma 1 and then then release the brake
before you start moving and then if the motor was running and CW clockwise now we are going
in the counterclockwise changing direction so all this HAP happens only if the current
is above this value if you are if you want to do for both channels so you must have these two
lines the first line which is this for sale for channel B channel B and for a the same way we
have to read the same thing converted from the password from the digital point to the
many volts and then divided by thousand and then multiplied by the factor and then get the current
on channel a so you have to have this two line for one channel and then these two line for the
other channel and your current for channel B will be this variable and channel a this variable and
here I used it in here for channel B to do all this and you can do the same thing for channel
a thanks for watching this was how to use this or the we know Uno motor shield if you liked
the video please thumb bobbin also subscribe so you can get updates of my upcoming videos