This content details the practical implementation and simulation of a battery thermal management system using an Arduino Uno and Tinkercad, focusing on controlling motor speed based on temperature readings and the critical importance of proper ground connections for voltage referencing.
Mind Map
Click to expand
Click to explore the full interactive mind map • Zoom, pan, and navigate
Right. So we were uh looking at the
motor control aspect in the morning
session. So there was a slight uh
logical thing which got missed. Just let
me go to the PPT. Yes.
So now uh I have told you that the
voltage always requires two terminals.
whether it is measurement for the
purpose of measurement or whether it is
purpose of uh sourcing. So in this
particular case you see the let me use a pen.
So from the microcontroller unit we were
deriving the PWM signal. So this was
coming out of a PWM pin uh input output
pin. So when we are applying this to the
gate of the NM mass, it should be
applied with the reference to the source
terminal. Now the potential is coming
from your microcontroller unit the
signal PWM signal and it is getting
applied to the gate and this application
should be with reference to the gate uh
I mean the source
and ground of your microcontroller unit.
So this is your microcontroller ground.
So this connection until and otherwise
we do that the voltage which is applied
to the gate terminal will not be proper.
So this connection is very important.
Even though we see the diagrams without
this while you are making actual
connections this is one which is uh
absolutely important. Without that you
won't be able to get anything. Now
keeping this fact in mind that voltage
is supposed to be applied with respect
to a reference. So the reference in this
particular case is the ground terminal
of your microcontroller unit. So keeping
this in mind we will go back to our
thinker care and we will see how far our
So once again just for the sake of
recollection I'll explain what we have
done here. This UNO is your
microcontroller unit development board.
You have got yourself a temperature sensor.
sensor.
The temperature sensors output analog
voltage is fed to one of the ADC input
channels, analog input channels. Then we
have a motor. To control this motor, we
have used NMAS power semiconductor
switch. So this particular switch has
three terminals. The control terminal
gate and the power terminals drain and source.
source.
drain and source. So we have made the
connection as per the diagram. So you
can now observe that the microcontroller
signal coming out of PWM pin 3 is being
given to the gate but the reference is
missing. So now what we have to do we
have to give the signal with reference
to the source terminal tied to the same
reference as that of the board's
reference. Now we have the reference
signal ground here. We will connect this
source NMAS source to the ground
terminal of our microcontroller board.
So we will drag it. The connection will
see I'm taking it this way so that you
won't find it difficult
to picture out where it is being
given. In your case, you can take it
across your board also. So just for the
sake of clarity, I have wired like this.
You can drag a wire from this ground
So you can take your time making these
connections. So in the meanwhile just
I'll run the same code what we have been
using in the morning.
So we have declared one of the pin PWM
pins in our program. Then we have used
that particular pin for generating a PWM
signal. So the duty cycle has been given
here PWM pin 100 is the value. So
remember you have to use the value 0 to
255 in this particular second field
second argument.
This is going to control the duty cycle
from 0 to 100%age. So now just directly
I'll click the start button. You'll be
able to see the voltage here. So the
only change what we have made to the
circuit connection what we had in the
morning is your ground connection. So as
we change the
duty cycle you should see a
corresponding change in
the generated voltage also. So you can
try making different values of uh this
uh duty cycle in the range of 0 to 255
and then you can try it in your system.
We will take our own time to finish
this. make sure we have done this
thoroughly. So in the meanwhile, if you
have any questions regarding the
connections or the program aspects, you
Yeah, we are using Tinkercad for these
the voltage across the motor is not
Okay, just a minor variation of around 2 volts.
So you have to remember this is a
software platform. It is not meant to be
perfect. And moreover next thing we are
applying a variable PWM signal to this
masset. So obviously whatever voltage
which is being generated across the
drain and source that will be having ripples.
ripples.
For circuit branch students I think you
should be able to get it. For others you
can just Google voltage ripples of a
power supply. You'll get to know them.
So that high frequency ripple naturally
gives rise to a small variations. So if
we are able to provide the DC supply to
the motor without any from the power
supply any any uh noises any ripples
Let us go through the connections once again.
again.
The motor is the DC motor is being
powered from a 9V power supply.
So the power supply has positive and
negative terminals.
So this motor is a DC motor which
requires a DC supply.
So if you give 9 volts you will see the
motor running at maximum RPM. If you
reduce the voltage to 8 6 4 3 to zero
the speed will start reducing from the
full speed to zero. Now essentially we
have used this semiconductor switch what
is written as NAS on the screen to vary
this voltage and how that is being done
by using the PWM technique. The PWM
pulses are generated by a microcontroller.
microcontroller.
In this case, this ATMA 328 on your
Arduino Uno board.
There are six PWM pins in our
microcontroller on this Uno board. We
are using one among them. So, we have
taken the signal from PWM pin 3 and
connected it to gate. So this pulse is
going to this voltage pulse this voltage
PWM voltage is going to control the
turning on and off of this MOSFET. So in
that process the average voltage
produced across the motor is going to be
controlled. So that is why every time
you make a change to the duty cycle the
runtime of this duty cycle uh this PWM
waveform you will see a different
voltage appearing across your motor
and you will be seeing motor running at
different speed. For instance I'll
reduce this
duty cycle from 190 to 10. You should see
see
a lesser voltage. In this case, see it
is just 330
330
or approximately 350 m volts. And you
have seen that the speed has reduced
drastically. On the other hand, if we
increase it to say 200, we should see a
higher voltage
and the motor running at much higher RPM.
RPM.
So right now after changing the duty
cycle to 200
the speed has changed to 13,000 something.
something.
So give your own set of values in place
of 200 and see how the motor speed
varies and also simultaneously see the
Does it has limits of range and speed?
Of course, every motor is designed for
uh speed range. So these kinds of things
what we get in tinkercad you have to
just you take it as a pinch of salt. So
this is just a simulation platform and
uh this is primarily used for checking
the uh logic provided by the program
rather than the operational I mean
circuit wise operational correctness.
You should use this as a program
development tool primarily.
So what we are observing here is when we
are varying the PWM duty cycle from 0 to
100 the motor speed also is increasing
duty cycle is directly proportional to
the motor speed. So that we have
confirmed it theoretically.
So if you want high fidelity results
then we have to move on to good spice
softares any electrical electronic
related circles they are simulated in
spice environments. So this Tinkercad is
primarily a platform to just get a hang
of the uh aspects related to electrical
coding development which can be meant
Yes, P spice will be good. There is LT
Spice. There is Q Spice also. All of
these are freely available for download
and free for usage. There is no
restrictions on LT Spice or Q Spice. You
can explore any of the open-source SPY softwares.
softwares.
Or if your institution has uh uh
When it comes to circuit simulations,
MATLAB Simulink may not be of that much
help. But still if you configure the
circuit uh element parameters properly
you might end up getting it. So circuit
simulations better to use any kind of
spice software with uh which is giving
So I'll wait for some more time before
So those have finished testing this
particular logic. So now we have just
tested how the PWM pulses variation of
the PWM pulses are making an impact on
the running performance of your motor.
How the speed is varied when the PWM
duty cycle is varied. That we have
tested. Now as a last uh thing we have
to combine variation of the speed with
the temperature that we will do it after
this one task. So those you have
finished this task we are going to
approach the next task to be like this.
So we are going to turn on the built-in
LED or turn it off if at all the
temperature is within the permissible
limit or not. So, the built-in LED is
going to be turned on
when the temperature is sensed to be in
So, basically LED is going to be turned
on or off if at all it is outside the
range or within the range.
So, that is the next task. But before
that, you can finish this circuit
simulation. Then we will pass it on.
We'll do it. We will wait for another 5
minutes. Then we will go to the next testing.
The range we are referring to is the
operational range of lithium-ion
batteries. Lithium ion batteries are
supposed to be operated in the range of
15°C to 35°C to get a good operational
performance and to elaborate the I mean
uh uh to increase the longevity of the
battery. So that is a range we are
So in the meanwhile I'll give you the
Those who have finished this task you
just like the morning session you open
the URL qext.in
And here in enter code you enter small
K, capital K, capital E and H. You will
be able to download the code in your system.
So in this particular case
we are going to combine
two tasks. One is to sense the input
temperature and take a small control decision.
decision.
So you're going to see whether the
temperature is within the range of 15 to 35°C.
35°C.
Then depending upon whether it is inside
the range or outside the range, we are
going to make the LED build built-in LED
You will have a description about this
code. Now the first line what you're
looking into as usual is used to define
the PWM pin. The PWM pin 3 is being used
in our design. Then we have declared
some local variables. In this case, we
have variables like sensor value, ADC
So each and every one of them
corresponds to each stages in the
feedback process.
Momentarily I'll go to the slide. We
will look into the block diagram we have
So the temperature value what we have
is represented as temp in our program
and the transducers output
whatever we have got
that is represented as ADC voltage in
our g. So basically this is the output
of our temperature sensor. Now this ADC
voltage is applied to the input of our
ADC terminal.
The output of this ADC is going to be
the digital data
and that is the ADC value you have seen
in the program. Let us go back to the
program and compile it. I mean compare
it. So once again remember we have
the option to view the temperature as
such in degrees CC
in our program we have the option to see
the voltage corresponding to that
particular temperature current
temperature then we have also the option
to look at the corresponding digital
value of the ADC input.
Let me go back to the program. I mean
You see here this is the temperature
what we have got it from the uh uh
battery pack battery pack temperature.
Then after the sensor has converted the
temperature into ADC voltage that value.
So morning we have done some
characterization isn't it? So based upon
that characterization we have formed a
relation here. So this particular
relation so that ADC voltage we will be
having it in this stored in this
variable. And finally the digital value
corresponding to the analog input of the
ADC analog to digital converter that we
can view it from the sensor value. We
have a provision in our program to know
Yes, I'm back.
Now, we have been discussing about the
code what we have got here.
Now the setup is going to set up the
input and output pins. Obviously this
time we need the use of the built-in
LED. So built-in LED is declared as output
output
and just like before the PDM PWM pin
from where the PWM signals are generated
that is declared as output.
Then the temperature sensors value which
is being sensed by the ADC input
terminal A0 that is declared as input. Then
Right. So this particular line line
number 12 it is for configuring the
serial communication module to have a B
rate of 9,600. And the last line that
you please uh delete it that is a replication.
replication.
So LED built-in it is supposed to be
output. Please delete that one.
Then inside the loop structure, these
statements are going to be executed continuously.
continuously.
So we are going to read the data from
the analog pin. Then store it in the
variable named sensor value.
Then we are processing this sensor
value. Remember the sensor value is
nothing but the integer equivalent
number equivalent of the binary data. So
that particular data is being processed
here in order to convert that into the
voltage reading.
Then once again we are using one more
conversion formula. This formula we have
derived in the morning session. So this
particular relation this particular
relation whatever you have got it after
characterization of the sensor response.
So this particular relation is going to
give you the information about the
actual temperature which is prevalent
inside the battery packs. Now just for
our own reference as a debugging tool as
a debugging uh uh for debugging purposes
we have printed the value of this
temperature on the serial printer. We
will use the serial monitor at the
bottom of the screen, this text screen
later to see the value of the
temperature, current temperature. So
these are debugging tools which will
help us to ensure that we are proceeding
in the correct direction. Now in the
last section of our program, we are
checking whether the temperature is
greater than 15 and also we are checking
whether this temperature is less than
35. We are ensuring that the temperature
is within 15 and 35. If this condition
is true, if the temperature is within 15
and 35, then the built-in LED will be
made high. It will be glowing. If the
temperature is outside this range when
it is less than or equal to 15 or when
it is greater than or equal to 35 then
at that time the built-in LED will be
switched off. So now this is a logic
what we have got here. So you make these
uh programs copy paste the program just
make sure to remove the last line in the
setup. Whatever I have circulated remove
the last line. Once you are done with
it, you can click start simulation.
Then you can vary the temperature to see
how the built-in LED response. You have
to remember this particular logic.
Whatever we are using, it is further one
more step in our code development
process. We are just testing whether we
are able to detect the condition,
whether we are able to see the
temperature range. So this is another
phase of the full code development. So
in this particular case in this phase we
are not bringing the motor control in
picture. All we are dealing with is to
see whether we are able to correctly
sense the temperature to be within the
range or not. So that we are
accomplishing by seeing the status on
the built-in LED.
So once you have made the modifications
for this code, you just click start simulation
simulation
and then as usual
select the temperature sensor.
You will see this slider bar.
That slider bar you can move it left and
right and simultaneously
you can confirm that you are reading the
same temperature through your
microcontroller by looking into the
message on the serial monitor.
Now at the bottom you have the serial
monitor. Click on this button. You will
be able to see the temperature value
So on your screen it should be very
clearly visible when you are doing it on
your system.
So I'll zoom in further.
So here you see 25°C.
A whole number is printed there. The
exact value is being displayed on the
serial monitor. So as you increase the
temperature by moving the slider left or
right, you should be seeing the
corresponding change getting displayed
on the serial monitor. It reads 79 on
the slider bar. The exact reading,
accurate reading is being displayed on
the serial monitor.
Now after having confirmed this, you can
also check whether the built-in LED is
getting turned on or not. As per our
logic, if the temperature is within the
range of 15 to 35, the LED should be
turned on.
As of now, the current temperature is
beyond 35, which means that the LED
should be low. Of course, the LED
is not glowing.
When you once again vary the temperature
and bring it within the range of 2015 to 35,
35,
you will be seeing the LED getting
So feel free to make modifications to
the program anywhere.
You can change this range or you can
have your own logic here.
After checking the correctness of this
particular logic what you have just developed
developed
you can try making other testings here.
So we will wait for some more time so
that everybody can finish then we will
move to the next phase of the complete
code development integration of
So if you have any queries just let me
look into the chat box. If you have any
queries regarding this exercise you can
Okay. You want this to be zoomed out.
You have to keep in mind that the motor
control part we have not brought in picture.
If you have your uh Google account,
the account creation process is going to
just take five or 10 seconds. Even if
not, within 30 40 seconds, you can get
So we'll wait for some more time
so that you can experiment on this
So when you are developing ing your
codes like this.
It is always better to use debugging
tools if you face any issues. So in the
hardware environment you have debugging
tools like this. We can probe the
potential at a particular terminal. You
can visualize the current or for
instance if you want to visualize the
signal PWM signal produced by your uh
microcontroller you can use oscilloscope
So wherever you want to go
just connect this oscilloscope terminals
In addition to the the
the
meter parameters, you can also try this.
So you have to make sure that uh you
select the time divisions according to
Okay. Right now I'm not generating any
PWM pulse. That is why it is coming as plain.
plain.
So if you want to visualize the PWM
signals or similar kind of signals, if
you want to visualize it, use this
debugging tool, the oscilloscope, the multimeter
multimeter
or in the software platform.
You have something called as break points.
You can also use break points at any
particular section.
So that when the code execution reaches
that particular point in the code, the
execution will stop.
When the code execution stops, you will
have a provision to view the contents of
every single register. You can probe the
contents of every register. Thereby you
can confirm that your program is working
properly. So you can use a combination
of these software and hardware debugging
tools to ensure the code development
process or the system development
process is going on in the right direction.
So just a few more minutes and then we
will have a code to check both of these
segments together. So you have to
remember we are developing the full code
step by step. The very first process we
tried to see whether we are able to read
the temperature values.
Then we separately tested whether we are
able to control the speed of the motor.
Now we are about to integrate both of
these things together. So the
requirements we saw in the morning
stated that the coolant circulation need
to be controlled if at all the
temperature is little bit high and the
battery should be isolated absolutely
when the temperature is very high when
it is reaching about to reach critical
limits. So these kinds of requirements
when you're developing rather than
developing the whole system as such as
one single in say one single goal split
that into smaller chunks. So you have to
go for the top to down hierarchy design
approach while you are designing
and while implementing you have to go
from bottom to top design approach that
is exactly you have been doing from the
morning. So these are the individual
small chunks of tasks which need to be
accomplished. Reading temperature,
controlling the motor, isolating the
battery like that you have smaller
tasks. So one by one individually you
test it and then you try to integrate
them. Now having checked the smaller
chunk of measuring the temperature and
the another chunk of measuring the motor
the operation of the motor we are about
to integrate both of these things
together. Now based upon the temperature
our motor should be speed should be
controlled and that is the next logic
which you are going to try. So for those
of you are still experimenting this keep
doing it. We'll uh spend some more time
in the meanwhile for the others who have
completed I'll share you the next set of
So once again I'm going to use Q text
So for retrieing the second code the
code for the overall BTMS process
thermal management process
you can use the code which I have shared
Use the code one capital V small C small K
K
and retrieve the code.
There is no change in the tinkercad
circuit which we have to do. So from now
on whatever
uh modifications which are required it
I'll keep this code for some more time.
Those who have finished the previous task,
task,
use this code for retrieving
the contents program which I have shared
just now.
If you have already accessed it, paste
it in the code block inside your Tinkercad.
Tinkercad.
Start the simulation and see how it
operates. You can also go through the
code. We will have a small discussion
about the code. The current code what I
have showed. We will have a small
discussion on that. Then we will see the
Generally when we are dealing with the
similar kind of specifications we will
just look into the specifications once again.
So the first requirement for our battery
therum management system is to maintain
the temperature between 15°C to 35°C.
So this is achieved by controlling the
amount of coolant flowing through the
cooling tubes.
So when we are trying to control the
amount of coolant circulated through the
cooling tubes usually we will be
employing P controllers. So in this
particular case in our case we have
selected a discrete way of controlling
for the sake of keeping the program
development task easy and that is
exactly what we are seeing as the if
statement logic in the program. Now we
will take some time to evaluate this
code once again. As usual in the
beginning we have declared the PWM pins
and certain variables. the variables
which are meant for storing the
temperature value, ADC value and the
digital value, converter ADC value.
Inside the setup, as usual, you have
declared the built-in LED as output and
the PWM pen as output
and a not analog pin as input. And then
the serial module has been configured
for 9,600 B rate. The last line, delete
After serial begin you have one line
delete that one.
Then coming to the loop section as usual
you have the logic expressions which are
meant to display the values in terms of
voltage and temperature. So we are going
to make use of this because for writing program
program
having the temperature values in degrees
CC that is very much easier that is why
we have not used either the sensor value
or the ADC voltage directly in our if
statement. So our logic is very clear.
The requirement is very clearly stated
that within the range of 30 to uh I mean
20 to
within the range of 20 to 35 15 to 35 I
think we are supposed to control the
So one more change here. So first we
will make sure that uh the coolant there
is no circulation of the coolant
requirement when the temperature is
within permissible limit. So as long as
it is uh from 15 to or less than 20 as
in this case the PWM
duty cycle is going to be zero which
means that the motor is not going to run
and the colon circulation is not going
to happen. And similarly we have
declared defined certain other cases
also. As long as the temperature is
within the range of 20 to 25°C
we are going to have the motor running
at 1/4 of the full speed which means the
circulation will be less slow. The
coolant circulation will be slow and we
increase the coolant circulation a
little bit if at all the temperature is
within the range of 25 to 30
and so on. So if at all the temperature
is much greater than I mean greater than
35 we are going to run the coolant to
its fullest extent. We are going to run
the motor at highest speed. Therefore
the compressor operates at its maximum
speed and circulates the coolant very
fastly so that we can bring the
temperature down quickly. So this is
just a rough logic we have taken. This
logic entirely depends upon how your TL
gives his specification as per the
client's requirement.
So after having developed your
logic like this, you are just simply
going to click on this start button.
So it can take some time to
copy the code from Q text and paste it
here. So ensure the last line in the
setup function is deleted. So inside the
setup function, ensure you have only
The lines to configure the built-in LED,
PWM pin, analog channel A and the serial
communication module for a certain B rate.
So if you have removed that line, you
can try clicking start simulation and
So the core logic which is supposed to
control the coolant flow is written in
the form of if else statements nested if
else if else if statements. So this kind
of programming is not very effective. So
technically speaking when you are
writing C codes and when you have lots
of conditions to test you will be
preferring to use switch case statements
you can alternatively try switch case
statements also. So just to keep the
understanding simpler we have selected
if statement. So the logic goes like
this. When the temperature is less than
20 the motor won't run. When the
temperature is between 20 to 25, the
motor will run at 1/4 speed. And when
the temperature is above 35, the motor
will run at full speed. So this we
should be able to see. I'll also click
start simulation here. So you should be
able to see the motor running at some
speed. As of now the temperature, let us
see what it is. It is 24.
Okay.
small modification and share this code
Please use the new code which I have
shared. Now access it using the code
capital P, capital P, capital G and
I'll switch back to Tinkercad. So once
again to repeat
the new code which you can use for
testing that circuit is can be accessed
So you can feel free to modify and have
your own logic here
or you can keep this conditions very simple.
So if continuous increase in the colon
circulation flow rate is required then
we have to adopt strategies like P controllers.
Now we have integrated both of these
modules in order to keep the coolant
circ circulation variable at a variable
rate. Now that is a first part of the
requirement. Then we did have another
two requirements. If at all the
temperature is beyond
I think 90°C
80°C stop the charging. So we have to
incorporate one more switch
switch
which is controlling the power flow from
the battery
to the load or from the source the
charger to the battery.
The same way we can use a similar kind
of logic to turn on the heater.
If the temperature sensed is below 5°C,
we can use a heater to be turned on and
until reaches 15°C, we can keep this
I'll keep the circuit here and the
program here
free to have your own conditions
inserted as a part of the if loop.
Instead of having uh five four FL
statements or five different conditions,
you can just stick on to two conditions
or three conditions. So feel free to
modify this logic so that you get a hang
You can change the values inside the
Ensure to check the values you have used
Just to keep the uh uh text editor window
window
clearly visible
so that you can see what you are typing if possible the font size also you can
if possible the font size also you can increase.
increase. Now as a take-home exercise you can
Now as a take-home exercise you can consider this you can have this
consider this you can have this add-on logic just the uh circuit aspect
add-on logic just the uh circuit aspect of this
of this task we will look into that. So we have
task we will look into that. So we have to disconnect the battery. So same
to disconnect the battery. So same layout whatever we have seen yesterday
layout whatever we have seen yesterday we will cons consider that. So assuming
we will cons consider that. So assuming that this is your charger
that this is your charger connected to the battery pack.
connected to the battery pack. This is your battery pack.
This is your battery pack. It is connected through a semiconductor
It is connected through a semiconductor switch something like that of your NMAS
switch something like that of your NMAS switch. What you have seen the signal
switch. What you have seen the signal coming to this particular switch the
coming to this particular switch the gate signal. So in the earlier case we
gate signal. So in the earlier case we have used PWM. Now we have given it to
have used PWM. Now we have given it to the NMAS. The similar kind of setup is
the NMAS. The similar kind of setup is what we are talking. So in this case the
what we are talking. So in this case the only change will be if at all the
only change will be if at all the temperature
temperature sensed is greater than 90°C
sensed is greater than 90°C then we have to open this switch. So
then we have to open this switch. So gate signal that is that pin signal will
gate signal that is that pin signal will be producing zero to open this switch
be producing zero to open this switch otherwise the circuit will be
otherwise the circuit will be closed. The gate signal will be one.
So if you have any questions regarding Tinkercad, you customers in the
Tinkercad, you customers in the chat box.
Fine. Keep exploring. Keep experimenting things. Whatever you have learned,
things. Whatever you have learned, experiment it and acquire new skill
experiment it and acquire new skill sets.
sets. All the best for you.
So if you have any technical queries you can post it otherwise we will close
can post it otherwise we will close today's session hopefully. We'll have a
today's session hopefully. We'll have a good sessions
circuit wise there is no change only the uh control requirement side only the
uh control requirement side only the control requirement side we had a little
control requirement side we had a little bit of modifications
bit of modifications Otherwise it is only ch sensing the
Otherwise it is only ch sensing the temperature and then controlling the
temperature and then controlling the coolant controlling the motor speed.
Okay. All the best for your future endeavors.
Click on any text or timestamp to jump to that moment in the video
Share:
Most transcripts ready in under 5 seconds
One-Click Copy125+ LanguagesSearch ContentJump to Timestamps
Paste YouTube URL
Enter any YouTube video link to get the full transcript
Transcript Extraction Form
Most transcripts ready in under 5 seconds
Get Our Chrome Extension
Get transcripts instantly without leaving YouTube. Install our Chrome extension for one-click access to any video's transcript directly on the watch page.