This content explains the implementation of a Battery Management System (BMS) for over-voltage protection using embedded controllers, focusing on sensor integration, microcontroller selection, and practical simulation techniques.
Mind Map
Click to expand
Click to explore the full interactive mind map • Zoom, pan, and navigate
recently
school Please
>> Just be before we proceed forward we
will try to have quick recollection
about what we have been discussing in
the morning session. So we were
primarily talking about the
implementation of some of the BMS uh
aspects using embedded controllers. So
we saw there are some key functions
which are supposed to be performed by
BMS that starts from monitoring and goes
all the way to control and
communication. When it comes to
monitoring we need the information about
three key parameters current voltage and
temperature. So when it comes to
measuring each and every one of these
parameters we will be requiring sensors.
So this is where we had a lengthy kind
of discussion. So we were talking about
different kinds of voltage sensors and
then we were saying how to use this
information provided by the voltage
sensors uh in order to control or in
order to communicate this information to
the next system.
So with that uh recollection we will
come to
the implementation aspect. So we have
fixed our objective to uh develop a
embedded controller with of course
necessary input outputs in order to
protect our lithium battery cell from
over voltage. So the key components
which will help us to protect our
lithium cell they are MOSFETs. It is for
the purpose of isolating the cell from
the charger. The DVS diode which is for
suppressing the transients. It is to
safeguard our lithium cell from
transient voltages. And finally the last
defense the fuse. In order to isolate
totally these things fuse once it blows
you know it has to be replaced manually
physically it has to be replaced. That
is the last line of the difference. So
these are the three components. So we
are going to just try to write a program
which will activate a MOSFET and uh in
that way it will try to protect uh or it
will try to isolate the cell which is
fully charged to 4.1 volts from the
source. So the information what we are
going to require is the cell voltage at
this particular case. So we are going to
employ ADC analog to digital converter.
So we are going to assume that we have
employed mega 328
microcontroller which has inbuilt peripheral
peripheral
like ADCs, interrupts, timers, serial
communication module in addition to others.
others.
So looking into the data sheet you just
to try to figure out some of the
essential parameters of these uh these
uh uh ADCs. So the morning visa there
are primarily uh three to four
parameters which we have to pay
attention to which we have to give our
primary focus. One is about the
resolution. The second one is about the
conversion time. The third one primarily
is about the range of voltage which we
can sense and finally of course
secondary information. It is also about
the number of different analog signals
that we can sample. We can sense by
using these ADCs. So these are the
primary things which we are going to
make use of it right now. Now,
Now,
so before I proceed any further, I
thought we will have a little bit of uh
little bit of uh kind of how to say
exactly not interactive session, kind of
like interesting session. So these are
uh some of the
embedded controllers which are used in
the automotive ind industry. Some of
them some of them for different purposes
there are some of them are listed. So
what we will try to do is we will try to
figure out whether an ADZ is present in
these embedded controllers. These we can
call it as microcontroller units also in
these controllers. And if at all the ADC
is present we will try to see whether
this ADC is an 8 bit ADC or a 10 bit ADC
or what is the resolution of this ADC.
Then in addition to that we will also
try to find out the range or any other
parameters. So what we will try to do is
try to look into the data sheet of these
controllers one by one. So one of them
we will do it together and the other two
you can try it on your own on your uh
phone or computer. So take for instance
this is a microcontroller unit
manufactured by and marketed by SD micro
electronics SPC series. It goes on to
have this part number. So every single
electronic component will have a part
number like this. So this is a part
number which we are supposed to use to
identify the data sheet and then to use
that data sheet to know more about the
device. So we have to remember that for
a design engineer any design engineer
data sheets are the best friends. So we
have to use data sheets. We should never
underestimate the use of these data
sheets. So we will try to just uh check
this data sheet and then
we will see whether we can identify
>> Yes, just a minute.
Yes, I come out of the full screen mode.
Now we will select
this part number
we can find out the data sheet of this
particular microcontroller unit. So
probably when you are giving the search
query you can add it with the data sheet
also. As of now I have just simply given
it like this because already I have all
the results here.
So there is a little bit of lag in the
visuals what you're seeing. Yeah, by now
yes you have got it. So once we have
identified the part number we try to you
can take this data sheet from any source
either from the manufacturer's website
or from the suppliers website the
vendor's website. I have gone into this
mouser electronics website. So this is
one of the vendors online vendors where
usually you can get these kinds of
electronic and some of the mechanical
components. So this is a website which
I'm going to use to download a data
sheet. I think I already have the data
sheet downloaded. Yes, it is here.
So the data sheet which I have
downloaded using the part number is what
Yes. So this particular data sheet if
you look into it to transfer 165 pages.
So it is going to be
kind of uh uh kind of a time consuming
task especially if you are interested
only in using some of the aspects of
this microcontroller then you have to go
through the scout through the entire
data sheet in order to find out that
particular single information. As of now
we are interested in knowing whether
there is an ADC if there is ADC what is
the resolution of the ADC present in
this particular microcontroller unit. So
we will use this this particular data sheet
sheet
instead of uh manually scavenging going
through what we are going to do is we
are going to use a generative agent just
like everybody I'm also fond of uh
this chat GPD.
So now we are going to load this PDF
file. Let us see whether We can give a
query which pro provides us a fruitful result.
Since I know that there is a JDZ present
here, I'm going to give uh query
directly like this. Find out the resolution
of the ADC.
Let us see whether we are able to get
any useful results. I think you are
unable to see my screen.
So I have given a query. So this
document your agent is going through it
and then it has produced a result.
Instead of going through the entire
hundreds of pages of documents around
150 160 plus pages we have just found out
out
the information very quickly like this.
So if you have very little information
which you need from the data sheet
sometimes you can try giving a query
like this make use of these agents in a
useful manner protective manner so that
you can [clears throat]
you can save time.
Now what you can try doing it is you can
try opening up your own favorite uh
generative agents chargemini
or any one of these and then try to
figure out the ADC resolution present in
this infinium microcontroller unit and
the NXP microcontroller unit.
So the part number you have to type it.
Of course it is a very lengthy part number.
Open your favorite uh
Then type in the part number
just like as you observed earlier.
Download the data sheet of this
microcontroller unit. Infinium and NXP microcontrollers.
microcontrollers.
Then these data sheet feed into your
agents attach that file.
Then simply give a query to tell you
what the resolution of the ADC is.
Already we have found that uh the SD
micro electronics MCU it is having 12
bit resolution.
So like that try to find out
the resolution of the Infinian microcontroller
microcontroller
Take your time. Just get yourself used
to that. If you have been using Chad GPD
or Gemini or Purple purpose, try this also.
It will take a couple of minutes then we
will proceed to the next one. You need
to find out the ADZ resolution of this
Infinian microcontroller unit and the
Even without attaching the file, you
still will be able to get the answer
provided if you mention the part number
very clearly.
You can try in both ways. One by
attaching the data sheet, then asking
your agent to tell you the resolution of
Take your time. Just try it. Just
practice it once.
If you're using your phone to observe
the session, you can directly give a
query instead of downloading attaching.
Just type the part number and you can
give a query to
ask it to specify the resolution of this
Infinian RX core microcontrollers and
Yes, that's right. It's 12 bits for
ADC resolution is 12 bits.
That's correct. For infin core MCUs, it
>> Yes, of course. Yes. Yes. For NXP
>> Yeah. 12 bits for all. That's right.
>> That's right.
>> That's right.
>> So, hope all of you are able to give
these kinds of to get answers.
So these kinds of generative agents
sometimes come in very handy very handy
to uh get uh manufacturers data sheet
informations like this instead of
scoring through lots and lots of pages
we can quickly identify it but it is
always a good practice to go back and
crossverify these results provided we
have time we are assuming these agents
are good enough in doing its job so
there is nothing wrong in
crossverifying also
Okay. Now we have observed that these
kinds of automotive MCEs they are using
it is looks like it is a default uh
resolution 12 bits sometimes very
specifically where it is used in battery
packs you might see 16 bit ADCs also now
these kinds of microcontrollers we have
come to conclusion that they are having
12 bit resolution. So with this 12 bit
resolution, what is the accuracy with
which we can measure the voltage? That
is the next thing we are going to figure
it out
with the 12 bit ADC. We are going to see
what is the
resolution the minimum wtage which we
can measure with 12 bits. That is what
we are going to look into. So these 12
bits means we are going to have two
power 12 states.
Which means that we can identify the
different portion of the analog signal
and represent it as two power 12
different states two power different 12
different magnitudes. So that is going
to be a precursor for us to find out the
accuracy I mean the uh smaller amount of
voltage changes which we can measure.
Now we use this particular term two
power 12 along with the ADC's input
wtage. So let us say these MCUs are
having ADCs which can accept voltages in
the range of 0 to 5 volts. So take this
maximum figure five and then divide it
by 2 power 12. So this 2^ 12 2 is 1k. So
obviously this should be 4k. 4k in the
sense four kilo bits not bits in the
sense uh states so this is binary k what
I'm referring to 4096
so 5 divided by 4096 whatever value
which you are getting that is going to
be the accuracy with which you will be
able to measure this 5 volt can one of
you do this computation and give the answer
answer I
I
think already some of you yeah many of
you have got it correct Right. So you
got this value of 0 0
somewhere around 1 m volts. Looks like
yes it's around 1.22 m volts. So this
1.22 m volts is the smallest voltage
change which we can measure with these
12 bit ADCs. Which means that we will
have very high accuracy. We can measure
wtages of changes 4.001
to 4.00 0002.
So it is 1 m volt variations that we
will be able to keep track of. This
small variations we can keep track of by
using the 12 bit ADCs.
This is more than sufficient for most of
the cases. 1 molt accuracy is more than
sufficient for most of the cases. So in
our case we will take for instance we
are supposed to determine whether the
cell voltage has reached [clears throat]
4.1 from whatever the lowest voltage
which we have taken the cutff voltage we
have taken it as 3.0. So from there when
the voltage is increasing we need to
monitor whether it has reached 4.1. So
it might reach 3.9
then 4.0 then 4.1. Right now the
accuracy which we are expecting is 100 m
volt. This accuracy which we need for
giving over voltage protection for our
lithium cell. So looking at the
requirement the 100 m volt and looking
at the
resolution what we have the accuracy
what we have 1.2 2 m volts we can very
easily come to a conclusion that the 12
bit ADC is more than sufficient for us
to incorporate in this situation in this
situation where you're going to use your
embedded controller for giving over
voltage protection. So having made a
decision like this you can proceed
further. So these are some of the
preliminary design aspects what you have
right.
Now, briefly we will deviate from the
theoretical discussions. So, you have
now figured out that uh uh the voltage
change which you need to monitor or
which you need to keep track of is a
minimum of 100 millolts. So once it
reaches 4.1 then you have to enable the
switch which is isolating it. So you
have uh charger circuit, you have the
semiconductor switch and you have your cell
cell
and this semiconductor switch should be
issued with a signal to open the moment
the voltage reaches the moment wtage
So what we are going to do we are going
to use a voltage sensor connect it
across the cell. This particular voltage
sensor is going to give us a
This analog voltage is later going to be
fed to an ADC. In this case, it is a 12
bit ADC. So you are going to have 12 bit
informations here with number 0 to 11.
So you have to keep in mind that these
ADCs are actually peripherals of our
microcontroller unit. Now these 12 bit
informations are stored in a memory location.
location.
This memory location's data content is
taken and processed by our CPU based
upon the program information what you
have stored in your flash memory. Then
it takes a decision to
issue a signal
issue a signal to keep the switch closed
or keep the switch open. So basically
the circuit diagram will be something
like this.
You have a source, you have a switch,
you have a cell. Then from this point
forward, from this point forward,
everything else is about data
collection, storage, processing and
decision making to open or close this
switch. Now looking at the process which
is going through you can write your
pseudo code that is your algorithm you
can write it simply like this you can
say collect data read the ADC value. So
you are writing a code to control ADC
alone. So we will stick on to the
instructions or the algorithmic part
which is related to the microcontroller
alone. So first step is going to be data collection.
collection.
Second stage is going to be data
processing. So in this case the
objective is very simple. If the voltage
is 4.1 or more than 4.1 if it is more
than 4.1 volt
volt
which voltage the ADC voltage we will
call this as ADC voltage VA ADC. If the
voltage is more than 4.1 then what
should be done? The switch the
semiconductor switch it should be of else
else
if it is less than 4.1 or even equal to
4.1 the switch will be on and it'll be
connecting the battery cell to the
charger. So looks very simple. So
whatever programming languages which you
can use you can use it. Whatever
programming mode you can use, you can
use it. Microcontrollers you can use it.
any different ids you can use it.
Finally, the objective is to realize
this particular algorithm. Now when it
comes to writing a program, you have two
different choices. In order to program
your microcontroller, control your CPU,
you have two different choices. One is
to program your microcontroller in the
so-called assembly language
that is mid-level language. This is
called as assembly language program. You
don't have to do worry too much about
this. So unless and otherwise we have a
kind of uh requirement that we need to
control the resource usage very
precisely we won't be selecting assembly
language program. So the next one is the
So where you will be writing your
instructions to control the
microcontrollers using C language
sometimes used to be C++ also and
nowadays you may be looking into
microython also. So these are the ones
which are used to program embedded
controllers. So embedded C is popular,
C, C++ is popular. We will stick on to
that. And there is another variety where
you go for graphical programming languages.
So the first two they are called as
textual programming languages where you
have to handcode it
textual programs.
The other one is a graphical program. So
these graphical programs they do have
their advantages and there are some
limitations too. So you will have all
the operations which are required to
build the logic a logic like this
whatever you have seen here these kinds
of logics in order to build this logic
you have blocks graphical elements. So
these elements will be assembled
whatever which is required that will be
dragged dropped assembled in a
particular order then they will be
interconnected in order to realize these
algorithms. That is how these graphical
programming languages do function. We
will have a short demo of these
graphical programming language based
embedded controller development in one
of the forthcoming classes before
Friday. Just a brief demo of that we
will have it until then we will be
sticking on to these kinds of textual
mode of programming. Now assumes
assuming that we are going to use embed
at C you're going to code this algorithm
using your embedded C. So you can use
inbuilt functions if inbuilt libraries
are available or you can build your own
libraries and use the functions from
that libraries in order to read and
perform these kinds of operations.
So with that note we will shift our
we will try to uh just to see just to
keep things a little bit more uh
uh uh hands-on we will just try this. So
yesterday I was mentioning that we will be
using online platforms to test some of
these algorithms. Since Ardino is a
favorite choice of everybody, we will
try to go for that.
So if you have a laptop with you, you
can try this or you can try it later also.
also.
So just to try googling Tinkercad
there are plenty of platforms which are
available. We have selected AutoCAD's
Tinkercad platform for doing this. So
Tinkercad is a free platform where you
can do certain
operations including testing of circuit
simulation of circuit. So we are going
So as when you open Tinkercad
you will have the welcome screen where
if you have already an account you can login
login
So if you have already an account you
can login
or you can click on sign up.
For those who have your Google Gmail
account, you can do it very easily.
Click on login
and then you can as of now you can use
personal accounts
and then click sign in with Google. Once
again let me repeat. So after we have
then click on personal accounts
that you are able to log in or sign up
with your Google account, we'll proceed forward.
I have linked Tinker Tinkercad account
with the Gmail account. So, it has gone
So, those who are new to this
environment, you can just explore. You
have an option to do 3D CAD designs of
course simple designs. Then you have an
option to go for circuit simulation
also. This is the section which we are
So once we have got this
It should open up a screen like this
where you have different set of elements
which are available for simulation on
And you have certain run options
including code development here on the
Let me just click on the code button.
As of now we have not included
everything. Just for uh demo sake I'll
place a UNO board.
Now we will click on the code button.
you are able to see the program
development environment in a different way.
way.
So this is called as blockly environment.
environment. Blockly.
Blockly.
So you might have seen it this kind of
blockly environment with some other
tools also. So these kinds of blocks
enable us to develop logic. So this is
one of the graphical programming
interfaces which I was mentioning
earlier about. You just drag drop build
drag and drop the building I mean
building blocks and then you connect.
This is one way of doing it. There are
other ways which we can do it just like
your uh matlab simulink. Hope all of you
have used to simulink or your xcos in
silab environment.
So just like we have embedded coder in
our matlab environment we have similar
kind of tools which helps us to do
embedded coding by using graphical
programming environments.
Now as of now we will close this code
button. But before that I'll show you
one more thing. So when you click on
this pulld down menu which says blocks
you will be able to see different
variants of it. Blocks or text or
combination of block and text. So text
is the place where we get to enter the
instructions you give to
microcontrollers in the form of program
lines codes. On the other hand, these
are the blocks which helps us to build our
our
circuits. Now, let me just click on
blocks plus text. You'll be able to see
whatever code which has been generated
by this block.
So, if you don't want any block, you can
you can add it back to this. So see the
moment I have dropped this block we got
one more line added to the code. So if I
delete it immediately the code gets
updated. So this kind of block based
program development embedded program
development it might be helpful one when
the complexity of the program is
minimal. So when it is increasing
obviously you have to go for text based
setup. So this is only for uh getting a
hang of it. Some of us may not be
exposed to do programming environment.
It might be if you are not too much into
embedded coding then to start with this
option using blockly might be the best
uh choice
or else if the program is if you are
well versed with Coding C++ coding you
can directly jump on to textbased
now we don't have to develop even if I
select the text based
code development. We don't have to write
all of these things from scratch.
You can use once again your generative agents.
agents.
You would have heard the term wipe
coding. You can exactly do wipe coding
also. You just give appropriate prompts,
develop your code, copy paste it, then
fine-tune the code. That's what wipe
coders do, isn't it? the skeleton what
you need that you take it from the agent
then you make sure it fits your
requirement you can exactly do that in
fact many of the companies they are
encouraging this practice if you have
read the article news article a couple
of days ago Nvidia's CEO he has insisted
that everybody 100% employees they
should be using a agents for code
development all of them he wants them to
be white coders so it is there is nothing
nothing
in uh taking the code and modifying it
according to your agents. So there are
plenty of code development platforms
like IBM granite.
Once you get into a company environment
where these development process are
going on, you will be starting to use
one of these agents as per the company
policies. I mean what kind of agents
they are using you also will be using.
So you can get started uh maybe earlier.
it. Now maybe when you have time after
these online sessions are over you can
even practice it. Now what we are going
to do is we are just going to get hangs
and hang on this particular environment
by using some readymade circuits which
So once again I'll come to the top right
corner the place where it says components.
components.
We will click on it. You will be able to
see two categories. One which says
components and the other one which says status.
So in this status you have different
categories basic Arduino different
categories are there. So actually these
are the readym made circuit which are
all already available with the quotes.
Whereas on the other hand the components
helps you to select the different kinds
of components which you wish to add to
your circuit and simulate. Plenty of
them are there. Normally whatever we use
you have
almost everything starting from the
active components to I mean passive
components to active components to IC
based solutions you have everything and
you do have your favorite
board also here.
So we will try to just uh see some of
the basic circuits for those who have
not explored this. We will just try to
do this others you can also try to mimic it.
it.
So now I'm coming to starters category
basics section.
So here we are able to see some circuits.
circuits.
So we will take the simplest of ones.
So now in this particular circuit
diagram we are able to see
a battery cell connected to a LED
So essentially when we start the simulation
simulation
we should see the LED glowing.
The current flows from the positive
terminal of the battery goes through the
current emitting resistor into the LED
and the LED starts glowing. The current
return backs to the negative terminal.
This is one way of doing it. Now when
you have the programmable logic to be
incorporated that is when you start
adding controllers. So in this
particular case we have access to only
the Arda board controllers. So we will be
be
let me erase all these
and let me take
another model the one which will be
So when we use select the category
Ardino under status you will be able to
see a bunch of circuit
try to find out the circute which helps
you to read analog values.
So I'm going to select one of these the
one which says analog input that will
give us an idea about how to develop our
Now in this particular circuit we have a
potential meter which can be varied from
the left end to right end. The value of
the potential meter is maximum is 250
kiloohm variable resistor. The potential
meter is used there.
The [clears throat] extreme ends, the
right side and left side ends, they are
connected to 5 volts
The center terminal
it is connected to one of the analog ports.
Now when we vary this particular knob,
it simulates the behavior of of a
Just I'll click on start simulation
so that I can show you that we are able
to vary the part
Just uh let me check the chat window if
Yes, we can add any required number of components
components
and once again these kinds of platforms
will be just a starters to start testing
our logic basic logic definitely we can
use it to test instead of uh using our
uh hardware to implement and test it. We
We can get this in Arduino starter. I
presume you're asking whether we can use
Ardino. Yes, we can definitely use Ardinos.
Ardinos.
Yes, it is something like a drag and
drop environment. Graphical programming environments.
basics of embedded it will take a very
long time as I told you earlier you can
be a wide coder just you have to be
familiar with the syntax and of course
the hardware for instance this
particular ATMA 328 what are the
facilities features it has we have to
check the data sheet we have to get to
know that once we are done it is more
than sufficient we don't have to write
the code starting from scratch you can
take it from your coding agents then we
can modify it according to your needs
that is more than sufficient
Now just to see what is the range of
voltage that we are having across this
green colored terminal wire terminal and
the black one we will just make use of a
multimeter. We will connect the positive
terminal of the multimeter
to a not that is analog input terminal
and the negative terminal
we will connect it to the ground. So
essentially what we are doing we are
trying to measure the potential
difference across the potential meter
terminals the center potential meter
terminals with respect to the reference.
Now I'm going to click simulation. Since
it is exactly
in the middle, the arm is exactly the
knob is enter exactly and in the middle
and we have to think where all these are
ideal cases of elements which we are
looking into. So these are just
kickstarters whatever issues which may
crop up when we are actually building
the circuit that we have to sort it out
when we are implementing it.
So now I'll just change the knob to the
left side and right side. So we can come
to a conclusion. So if I move the knob
to the extreme right it is zero
resistance. If you move the knob to the extreme
extreme
left then it is a full resistance
maximum resistance we get to see the 5
vol terminals there. I mean 5 volt uh
potential there.
Now this is a basic setup. we are going
to make use of or you are going to make
use of in order to
test your over voltage program. I'll
just to show what are the elements which
are required. You can write it later.
Now this particular code this particular
circuit comes in with the default code
since this is a example diagram they
have attached the necessary logic also
here. We will go through the logic which
is used for
this particular case. We have a forward block.
block.
So this far block is synonymous to the
loop structure.
Unlike conventional C programs in our
Ardino ID we tend to use these functions
in a different way. You are aware of it
those who have used Ardino. Normal C++
programs always they start with the main
functionality and you have studied that
there should be at least one main
function. So all these things are taken
care in this ID. So you simply you end
up using the functions as per your
needs. So this setup function just runs
once that is why you call it as setup.
It is for initializing. So similar kind
of functions you will be writing for
other types of microcontrollers also. So
when you venture into say uh uh maybe TI
microcontrollers or maybe STM
microcontrollers, you will be ending up
using the ids which uses the
conventional program flow. You'll be
starting from the declaration section,
global declaration section, linking
section, global declarations, then
moving on to function declaration, main
function, all these things you'll be
seeing it. This environment is a little
bit different but not all together.
Okay. Now coming back to analysis of the
logic. So in this particular case the
analog channel has been declared as an
input. Obviously it should be and then
the built-in LED used for conveying a
status it is declared as output. Once
that is done the loop structure the loop function
function
it helps us to execute a set of
statements a logic continuously again
and again. So in this case we have to
read the value of analog port then make
a decision about what to do with that
value. So that operation is what you see
both in the blockly environment and in
the code environment read the value just
write a status it goes on like this. So
if at all you want to modify the logic
if at all the analog voltage is less
than or equal to three then maybe turn
off the LED. If it is no turn on the LED
you just will be using if construct
something like this you will be just
putting [clears throat]
you cannot edit the text programs and at
this particular environment you have to
select the text mode of editing only
then you'll be able to make changes. So
in this particular blocks plus text mode
you can edit only these blocks.
So if at all you are using the text mode
directly you can write the if statements
here after reading. If at all the sensor
value is less than three, enable the
LEDs. Write the status high to built-in
LED. Else write the status low. You can
try doing this. So this is a way the
program has been built here in this
case. So maybe after today's class you
can try modifying this code so that when
the potential across this potentiometer
at this analog zero terminal a not
terminal when it is less than three the
built-in LED is switched off when it is
more than three or equal to three the
built-in LED is turned on now we will
come to the next aspect actually we are
interested in over voltage protection so
in order to mimic this particular
algorithm we are going to make use of
the potential divider concept. So we are
going to have two resistors in order to
create a potential difference and just
to mimic the mimic the
cell lithium ion cell we have taken a 9V cell.
Just a minute. Let me
just one minute. Let me mirror it. Yes,
battery.
Then we will tap the potential across
the lower resistance. Just for a moment
I'll go back to the PPT in order to show
you the circuit diagram what we have
So now we have the resistive dividers
here. So by carefully selecting the
resistors R1 and R2, we will be able to
control the output voltage coming out of
here. Now we'll just try to make some
computations based upon the uh the based
upon the voltage source which you have
seen that is a 9V battery which you have
seen. Okay. So here you have a 9V
battery. We cannot feed this 9 volt
directly to your ADC terminal. You have
This is at the most 5 volt. So we have
to select these two resistors R1 and R2
appropriately so that the output wtage
doesn't go beyond 5 volts. When the
input is 9 volts, you should have 5
volts. So the relation which you need to
use we have seen it in the morning
right? V is equal to
R the same formula you rearrange the
terms you will get R2
into the input voltage the normal
potential divider formula. So once you
have written this kind of relation you
just pick out the value of one of these
very easy value. We have selected 1
kiloohm resistance for this R2.
So we know what V not is. It is supposed
to be 9 volt. We know what V
sorry V is
5 vol. V is supposed to be 9 W. R1 we
have selected. So obviously we will be
able to know the unknown parameter
So R2 is what we have assumed
R2. So with this information see whether
you can find out the required value of
There is a simpler way of doing it also.
You just see the ratio of uh the output
and input wtage 9 by 5. This is
somewhere around 1 point something isn't
it? So this ratio 1 something. So this
ratio also can be used directly to
usage. The best way is to go for using
this formula so that we won't have any
confusions. This always will be kind of
just to try to compute what the R1 value
is and try to post it in the uh chat box.
So the value required value for R1 is
800 ohm.8 kiloohm.
kiloohm.
Now let us see we will simulate this
behavior. This is supposed to be 800 ohm
and this is supposed to be 1 kiloohm. So
this 9 volt should be stepped down and
across these terminals we should be able
to see 5 volts. Now we will use a EDA
tool electronic design automation tool
in this case that Tinkercad to verify
this. Once we have verified that the
voltage across these terminal two
terminals this across this V out
terminal is going to be within safe
magnitude we can directly connect this
to a ADC only after having made these
calculations arrow calculations you are
required to connect the potential the we
out potential to your ADC terminals. So
you have to give some room also. You
have to give room some room for excess
voltages too. So okay take a safe
voltage after having computed R1 R2
values. Select standard voltage. For
instance you may not have a standard
resistance of 800 ohm. So you have to
pick up a value which is closer to the
standard values. Or the other option is
to go for a potential meter here. So in
order to adjust it and bring it to the
required voltage even though we are
having the availability of 1 kiloohm it
will be having a tolerance band it'll be
having plus or minus 5% sometimes 10%.
So instead of 1 kiloohm it might end up
giving you just 900 ohm or it might be
more than 1 kiloohm. So you have to
measure it and then you have to ensure
that the voltage across these two
terminals is not going beyond 5 volts.
What is the time? It is 3:00. Shall we
take a break
for 10 minutes
or shall we continue and finish it by 3:30?
>> It's okay. We will take a break for 10
minutes. Uh we will start it by 35.
Shall we? Okay. Whatever you say it is okay.
Okay, then we will continue. Maybe we
will wind up without a break. We will
wind up a little bit earlier.
>> All right. Uh
yes, I I'll try to I'll try to finish it earlier.
earlier.
Maybe rest of the discussions we can
continue on the next class. Now we have
finalized the values of R1, R2.
Practically after you have procured
these components, it is the system
design engineer's duty. It is the duty
to check what the actual values of R1,
R2 are and then make sure the voltage
produced by these potential dividers are
within safe limits. So we will just try
to ensure what voltage we are getting by
going back to that simulation environment.
environment.
Now I'll come back to
this uh
So we have two resistors already built there.
there.
We will take one multimeter.
We will try to measure the potential
between the
resistor terminals
Right. And then we will adjust the values.
values.
So I think you have uh told me that this
or8 kiloohms
and the bottom one we have assumed it to
be 1 kiloohm. It is already 1 kiloohm.
Right. Start the simulation. Check what
voltage you are getting it there. Since
it is a theoretical resistor. So those
values there are no deviations exact 800
ohm and 1 kiloohms you're able to obtain
it. So that is why naturally you are
getting exactly 5 volts practical cases
it definitely won't be like this and
most of the practical times you will be
required to add in some extra elements
also. So they see the amount of
complexity which are involved when it
comes to implementation of the
theoretical concepts you have studied
and this is the simplest circuit.
Morning when we were discussing we
mentioned that this is one of the
simplest methods to measure voltages
even though it has certain limitations
this simplest circuit itself is having
these many things to focus upon. So
naturally when you go for higher uh end
or sophisticated senses there will be
little bit more extra things extra
attention which you have to give. Now
what you can try later after uh uh
today's session is that you can you can
try to I'll erase this uh multimeter.
Stop the simulation. I'll remove this
multimeter so that the figure will be clear.
clear.
connect the voltage
voltage
across the R2 resistor to
to
one of the available ADC channels.
that you always give the
signal to the analog pins with respect
to the ground. Remember this is a
potential what you are trying to
measure. potentials are always measured
with respect to with respect to uh uh
another terminal with respect to a
reference I should say that is a correct
word with respect to a reference you
measure the potential at some point so
in this particular case we measure the
potential at terminal two of the
resistor with respect to terminal one of
this resistor to put it in another way
from the microcontrollers perspective we
measure or we give the voltage at ify
So ensure this particular thing is not
missed when you are using ADCs.
Even though we see that there are six
ADC channels, this 328 says there are
eight ADCs, two of them are not
buffered. So primarily six is what you
will see for these kinds of 328
microcontrollers atal microcontrollers,
microchip microcontrollers.
So when you are providing the signal
make sure you provide it with respect to
a reference and here also there is one
more point which you can keep in mind if
at all you're going to go as a design
engineer with respect to these things.
So for all of these channels starting
from A to A5 the six ADC channels there
is only one reference the ground
reference which means that any noise in
any one of these channels A to A5 it is
going to be common to the other channels
also which means that the noises which
are getting generated from some signal
and being fed to one of the analog
inputs they will kind of affect the
signals present on the other even though
those sources are not having any error I
mean any noises it also will be getting
affected. So in these kind of cases we
go for a kind of arrangement called as
differential arrangement where each and
every single analog channel has its own
reference. So in that case a not will
have its own reference ground. A1 will
have its own ground. Both of the grounds
will be different. So that kind of
arrangement is referred as differential
arrangement. So if at all the fidelity
of the measurements which you want to
take is requirement is high then you
have to think about differential
measurement. Alternatively if the
microcontroller doesn't provide these
kinds of differential analog inputs. You
can always go for external circuit which provide these kinds of noise filtering
provide these kinds of noise filtering or noise reduction or perhaps signal
or noise reduction or perhaps signal conditioning. Then you can feed the
conditioning. Then you can feed the signal noise free signals or noise
signal noise free signals or noise reduced signals to your analog things.
reduced signals to your analog things. Now on you have wired it this way your
Now on you have wired it this way your code is still going to remain the same.
code is still going to remain the same. Read the sensor value. Then if the
Read the sensor value. Then if the sensor value is less than three, you're
sensor value is less than three, you're going to turn on the inbuilt LED. Uh
going to turn on the inbuilt LED. Uh turn off the inbuilt LED. If it is
turn off the inbuilt LED. If it is greater than three, it is going to be
greater than three, it is going to be turned on.
turned on. greater than or equal to three voltage
greater than or equal to three voltage at A5 LED built-in LED is going to be
at A5 LED built-in LED is going to be turned on. Other times it is going to be
turned on. Other times it is going to be turned off. Now once you have wired all
turned off. Now once you have wired all these things and made the coding
these things and made the coding requirements you are free to use your
requirements you are free to use your generative agents to get this code. Just
generative agents to get this code. Just make sure you give a proper prompt.
make sure you give a proper prompt. Select
Select text in the edit mode.
text in the edit mode. Paste your code here.
Paste your code here. Then before you start clicking start
Then before you start clicking start simulation,
simulation, you have to make sure that you adjust
you have to make sure that you adjust the resistor values
the resistor values so that you get a voltage different
so that you get a voltage different voltage across this A5.
So when you increase the R1 resistance the one on the top
obviously the drop in the second resistance is going to be less and it is
resistance is going to be less and it is going to be vice versa. So increase or
going to be vice versa. So increase or decrease this resistance
decrease this resistance maybe I'll show you that too. So we will
maybe I'll show you that too. So we will just add a multimeter to crossverify
just add a multimeter to crossverify that.
that. The positive terminal once again we will
The positive terminal once again we will connect it to
connect it to this end of the resistor
this end of the resistor and the negative terminal of the
and the negative terminal of the multimeter we will connect to
multimeter we will connect to the opposite end. So now remember we
the opposite end. So now remember we have given 800 and 1 kiloohm. 800 ohm 1
have given 800 and 1 kiloohm. 800 ohm 1 kiloohm with this one we are supposed to
kiloohm with this one we are supposed to get 5 volts fair enough we are getting
get 5 volts fair enough we are getting it now when you are testing your program
it now when you are testing your program you can just play with the values in
you can just play with the values in order to create a different condition so
order to create a different condition so we have reduced the resistance of the
we have reduced the resistance of the top resistance so naturally you see it
top resistance so naturally you see it increases if you try doing this in the
increases if you try doing this in the practical circuit if you give 8 volts to
practical circuit if you give 8 volts to your analog pin you'll end up damaging
your analog pin you'll end up damaging the microcontroller this is only for
the microcontroller this is only for testing your program
testing your program and now increase the
resistance of R1. Naturally, there should be a lesser voltage drop. It is 1
should be a lesser voltage drop. It is 1 volt. So, set it at 1 volts. You will
volt. So, set it at 1 volts. You will see that the built-in LED as per your
see that the built-in LED as per your program. The program has not been
program. The program has not been modified. It is some other program which
modified. It is some other program which is running now. So, when it is less than
is running now. So, when it is less than three, the LED will remain off. When the
three, the LED will remain off. When the voltage is more than three, the LED
voltage is more than three, the LED should be turned on. So this is going to
should be turned on. So this is going to be the core logic which you are going to
be the core logic which you are going to later use for the over voltage circuit.
later use for the over voltage circuit. So there is a potential divider. This
So there is a potential divider. This battery will be replaced by your cell
battery will be replaced by your cell voltage the cell terminals. Whatever
voltage the cell terminals. Whatever connections which you are supposed to
connections which you are supposed to make that you will be making it from the
make that you will be making it from the lower resistor to the ADC terminal and
lower resistor to the ADC terminal and ground and one of the GPIO pins you can
ground and one of the GPIO pins you can use it for taking the signal and giving
use it for taking the signal and giving it to the disconnecting MOSFET.
Try it tomorrow when you come you will have uh
tomorrow when you come you will have uh a solution of this. I hope all of you
a solution of this. I hope all of you will be able to very easily do it.
will be able to very easily do it. Now that is about the max or voltage
Now that is about the max or voltage protection implementation. So we have
protection implementation. So we have done it in a very simple way. Our
done it in a very simple way. Our objective was to test the signal
objective was to test the signal conditioning network. I mean the voltage
conditioning network. I mean the voltage sensor part the potential divider in
sensor part the potential divider in this case. Then the second objective was
this case. Then the second objective was to check the embedded program how far
to check the embedded program how far your embedded controller will work
your embedded controller will work effectively. That is what we were trying
effectively. That is what we were trying to see.
>> Okay. Now briefly we will look into the different kinds of current sensors and
different kinds of current sensors and uh uh we will call it a day afterwards.
uh uh we will call it a day afterwards. Tomorrow we will discuss the design of
Tomorrow we will discuss the design of one of these current uh sensors. We will
one of these current uh sensors. We will take the simplest one. Just like we have
take the simplest one. Just like we have taken potential dividers, we will take
taken potential dividers, we will take the shunt resistor for sensing currents.
the shunt resistor for sensing currents. These are the simplest ones available.
These are the simplest ones available. Of course, they come up with some
Of course, they come up with some trade-offs, some limitations. But this
trade-offs, some limitations. But this is for now it should uh do its purpose
is for now it should uh do its purpose of uh developing your embedded logic.
of uh developing your embedded logic. Now we have different varieties of
Now we have different varieties of current sensors available. Some of them
current sensors available. Some of them are listed here. The first three are the
are listed here. The first three are the common ones which we come across very
common ones which we come across very easily uh or very frequently I should
easily uh or very frequently I should say. The shunt resistor current sensor
say. The shunt resistor current sensor which actually uses a resistor in series
which actually uses a resistor in series and then the drop which is created
and then the drop which is created across this resistor when a current is
across this resistor when a current is flowing through is used to measure the
flowing through is used to measure the current flowing through it. The second
current flowing through it. The second one is your favorite hall effect sensor
one is your favorite hall effect sensor whatever we have seen in the morning but
whatever we have seen in the morning but this is going to work in the open loop
this is going to work in the open loop fashion not like the one we have seen in
fashion not like the one we have seen in the morning closed loop fashion and the
the morning closed loop fashion and the third one is the standard current
third one is the standard current transformer just like a potential
transformer just like a potential transformer you can employ current
transformer you can employ current transformer in order to measure the
transformer in order to measure the current and these are the industrial
current and these are the industrial level sensors which are usually used
level sensors which are usually used flux gate current sensor and magneto
flux gate current sensor and magneto resisttor
resisttor sensors and out of these flux gate
sensors and out of these flux gate current sensors are widely being
current sensors are widely being employed because it's advantage. If
employed because it's advantage. If you're interested you can uh learn more
you're interested you can uh learn more on this. You should of course know more
on this. You should of course know more on these flux gate sensors because very
on these flux gate sensors because very often you'll be seeing these sensors in
often you'll be seeing these sensors in almost every uh every uh industry level
almost every uh every uh industry level application circuits.
Okay. So what happens uh in the case of a shant resistor based uh current
a shant resistor based uh current sensing method is we insert a series
sensing method is we insert a series resistance with the load and the source.
resistance with the load and the source. So here is your source which is feeding
So here is your source which is feeding the load in series to this load and
the load in series to this load and source. We introduce a series
source. We introduce a series resistance. So we know according to
resistance. So we know according to Ohm's law that whatever voltage which is
Ohm's law that whatever voltage which is developed across this resistor should be
developed across this resistor should be proportional to the current flowing
proportional to the current flowing through it. So if the current is more
through it. So if the current is more naturally the voltage should be more. If
naturally the voltage should be more. If the current is less the voltage also
the current is less the voltage also should be less resistor remaining
should be less resistor remaining constant. So this is a proportional
constant. So this is a proportional relation what we have. Now after having
relation what we have. Now after having converted this current to voltage all we
converted this current to voltage all we have to do is measure the voltage like
have to do is measure the voltage like this.
This is the simplest of all current sensing methods available. Now when we
sensing methods available. Now when we are doing it, there are certain things
are doing it, there are certain things you have to keep in mind. As usual,
you have to keep in mind. As usual, these kinds of uh resistance values,
these kinds of uh resistance values, they are prone to time decay. Over a
they are prone to time decay. Over a period of time, the resistance values
period of time, the resistance values changes. That is one aspect. The second
changes. That is one aspect. The second is the amount of power dissipated in
is the amount of power dissipated in these kinds of resistances.
these kinds of resistances. >> [cough and clears throat]
>> [cough and clears throat] >> The dissipated power which usually is
>> The dissipated power which usually is expressed as I² R that losses has to be
expressed as I² R that losses has to be reduced kept as minimal as possible when
reduced kept as minimal as possible when it comes to measurement of current using
it comes to measurement of current using shunt resistor kind of sensors.
So this is one other major aspect which need to be kept in mind when you are
need to be kept in mind when you are using shunt resistors for measurement of
using shunt resistors for measurement of current. So once you have measured the
current. So once you have measured the current using this and converted into
current using this and converted into voltage you will be having further
voltage you will be having further requirements. So before you feed them to
requirements. So before you feed them to the microcontrollers
the microcontrollers which are having this ADC as a part of
which are having this ADC as a part of it
it you need to isolate them for the purpose
you need to isolate them for the purpose of safety.
of safety. So morning we were talking about assil
So morning we were talking about assil standards isn't it automotive
standards isn't it automotive level standards. So there are five
level standards. So there are five levels depending upon where you are
levels depending upon where you are employing them depending upon whether
employing them depending upon whether the level which is required is A B C D
the level which is required is A B C D or uh any of those things uh five levels
or uh any of those things uh five levels I think I have written only five of four
I think I have written only five of four of them you
of them you erase
So this one we will call it as no no levels.
levels. So here no safety related aspects are
So here no safety related aspects are immaterial that we will call it as the
immaterial that we will call it as the first level right. So depending upon the
first level right. So depending upon the kind of asel level which you want you
kind of asel level which you want you have to make sure that you are using
have to make sure that you are using additional elements in addition to this
additional elements in addition to this that is mandatory. If you are going to
that is mandatory. If you are going to use these kinds of current sensing
use these kinds of current sensing resistor say to measure the DC bus
resistor say to measure the DC bus current or the traction inverter load
current or the traction inverter load current, you have to make sure you go
current, you have to make sure you go for the uh higher level of safety maybe
for the uh higher level of safety maybe to the category level of uh CR D.
to the category level of uh CR D. That is another aspect. Second aspect
That is another aspect. Second aspect and the third aspect is that
and the third aspect is that the third aspect is that if you look at
the third aspect is that if you look at this circuit
this circuit this particular terminal it is actually
this particular terminal it is actually floating
floating this is supposed to be the reference if
this is supposed to be the reference if it is something like a ground then this
it is something like a ground then this particular opamp amp up a amplifier it
particular opamp amp up a amplifier it will not have much of a problem. So the
will not have much of a problem. So the voltage in this particular case is
voltage in this particular case is measured with respect to a floating
measured with respect to a floating terminal. This is going to be another
terminal. This is going to be another bottleneck. So we can try employing
bottleneck. So we can try employing circuit what you see on the left
circuit what you see on the left something like this. This is another way
something like this. This is another way better way or the best way is to have a
better way or the best way is to have a kind of move on to the next level of
kind of move on to the next level of current sensors.
current sensors. So we have seen three issues. All these
So we have seen three issues. All these three major issues should be kept in
three major issues should be kept in mind while you are designing it. One is
mind while you are designing it. One is about the change in resistance, the time
about the change in resistance, the time deck factor about the resistance, the
deck factor about the resistance, the electrical isolation and the floating uh
electrical isolation and the floating uh aspect of the second node if it is going
aspect of the second node if it is going to create any trouble better to avoid
to create any trouble better to avoid this kind of configuration. So this is
this kind of configuration. So this is about the first type of
about the first type of current sensing mechanism. The second is
current sensing mechanism. The second is of course the hall effect based sensors.
of course the hall effect based sensors. By using the all effect you can measure
By using the all effect you can measure the current the flux which is being
the current the flux which is being produced by the uh sensing element it is
produced by the uh sensing element it is going to be proportional to the amount
going to be proportional to the amount of current flowing through it. So this
of current flowing through it. So this flux in fact is going to end up
flux in fact is going to end up generating a hall voltage amplifying
generating a hall voltage amplifying this voltage. You will be able to get an
this voltage. You will be able to get an idea about the current flowing through
idea about the current flowing through it. So it is similar to that of the
it. So it is similar to that of the circuit what we have seen in the
circuit what we have seen in the morning. And the third one is your
morning. And the third one is your current transformer. It is also having a
current transformer. It is also having a similar kind of operational principle.
similar kind of operational principle. The current flowing through the
The current flowing through the conductor produces a magnetic field.
conductor produces a magnetic field. This is being picked up by the secondary
This is being picked up by the secondary coil and then it is being used to uh uh
coil and then it is being used to uh uh by the ADCs in order to convert it to
by the ADCs in order to convert it to voltage and thereby measure the current.
voltage and thereby measure the current. Naturally these kinds of current
Naturally these kinds of current transformers you have to keep in mind
transformers you have to keep in mind they can be employed only when the
they can be employed only when the current flowing through is AC. Unlike
current flowing through is AC. Unlike your holof based sensors, this CT has
your holof based sensors, this CT has limitations. It can be used only for
limitations. It can be used only for measuring AC current. So you can figure
measuring AC current. So you can figure out we were looking into the application
out we were looking into the application use cases of the voltage sensors in the
use cases of the voltage sensors in the morning. Similar kind of application use
morning. Similar kind of application use cases you have to think about it in
cases you have to think about it in these current sensor category also.
Yes, with that uh note we will end up the theoretical discussions of current
the theoretical discussions of current sensors. We will continue further with
sensors. We will continue further with the design of uh uh
the design of uh uh shunt resistor based current sensor and
shunt resistor based current sensor and we will use it for
we will use it for core current protection. Once this is
core current protection. Once this is done we will briefly look into thermal
done we will briefly look into thermal protection. Then we will directly jump
protection. Then we will directly jump on to
on to the constant current constant voltage
the constant current constant voltage based control methods balancing methods.
based control methods balancing methods. How to use this is the primary part of
How to use this is the primary part of sensing the basic parameters. Once we
sensing the basic parameters. Once we can have an idea about these battery
can have an idea about these battery parameters, the algorithm which is used
parameters, the algorithm which is used for doing all these things like cell
for doing all these things like cell balancing or perhaps SOC prediction, it
balancing or perhaps SOC prediction, it is just uh programming part alone. You
is just uh programming part alone. You have uh proven algorithms. You just have
have uh proven algorithms. You just have to use these algorithms to write a code
to use these algorithms to write a code which processes the sensor values and
which processes the sensor values and takes appropriate decisions that we will
takes appropriate decisions that we will see in the forthcoming projects.
see in the forthcoming projects. Maybe by before tomorrow you can try
Maybe by before tomorrow you can try that Tinkercad circuit which is meant
that Tinkercad circuit which is meant for voltage protection. If you have any
for voltage protection. If you have any questions regarding that we will take it
questions regarding that we will take it up in the next session.
If you have any queries you can post it on the chat box.
on the chat box. I'll be here for another uh five six
I'll be here for another uh five six minutes then we will wind up the
minutes then we will wind up the session.
Okay, thank you all of you. Hope you don't have any queries. If you do have
don't have any queries. If you do have any queries, you can take it. We can
any queries, you can take it. We can take it up in the next session.
The type of code which you have used is the one which is compatible with what I
the one which is compatible with what I already know. It is C++ based code.
Yes. Thank you. Bye. You will see in the next class
if possible if you have time try that tinkercad circuit.
tinkercad circuit. We will see that uh similar kind of
We will see that uh similar kind of thing in the next case.
Tinkercad and Sim link I don't think it is compatible
with Simink. You can always use the embedded coder block in order to
embedded coder block in order to implement similar kind of things. You
implement similar kind of things. You can actually run HIL loops with that
can actually run HIL loops with that hardware in loop uh systems along with
hardware in loop uh systems along with the Simink's
the Simink's embedded coder plot. that is still
embedded coder plot. that is still positive.
Yeah. The task is this tinkercad circuit using the tinkercad default example
using the tinkercad default example problem in order to build over voltage
problem in order to build over voltage protection algorithm. It is just
protection algorithm. It is just algorithm. You can try that one or uh if
algorithm. You can try that one or uh if possible I'll bring up a solution and
possible I'll bring up a solution and I'll show you a demo tomorrow. You can
I'll show you a demo tomorrow. You can also try it in your laptop or in your
also try it in your laptop or in your system.
Okay, thank you all of you. See you tomorrow.
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.