0:09
hello and welcome to controllers Tech
0:12
this is the 11th video in the SDM 32 ADC
0:16
series and today we will see the
0:18
differential ADC in SDM 32 differential
0:21
adcs are used in applications requiring
0:24
High Precision noise reduction and
0:27
increased dynamic range today in this
0:30
tutorial we will see how the
0:32
differential ADC can measure the voltage
0:34
difference between the two inputs the
0:37
measured voltage by the ADC will be a
0:40
difference between the voltages on its
0:42
inputs not all the SDM 32 devices
0:46
support differential ADC so I am using
0:49
the h750 based custom development board
0:53
let's take a look at the reference
0:55
Manual of this board open the ADC
0:58
section and go to the different IAL
1:00
inputs part as mentioned here in
1:03
differential mode the analog voltage to
1:06
be converted is basically the difference
1:08
between the voltages on two
1:10
inputs even though the ADC is converting
1:13
the difference between the voltages the
1:15
output data is still unsigned data we
1:19
will see how this works in a while when
1:22
the positive input is equal to vref
1:24
minus or the negative input is equal to
1:27
vref plus the output data is zero
1:30
similarly when the positive input is
1:32
equal to vref Plus or the negative input
1:35
is equal to vref minus the output data
1:38
is maximum here is the formula based on
1:42
which the output data is calculated by
1:45
ADC here you can see the image
1:47
explaining how the output data is
1:50
calculated we saw in the previous video
1:53
that the VRE minus is always connected
1:56
MCU therefore I am taking the vref minus
2:00
to 0o although we can vary vref plus but
2:04
by default it is connected to the 3.3
2:07
Vols when the positive input is equal to
2:09
VRE plus and negative input is equal to
2:12
zero the converted value will be maximum
2:17
65,535 in case of 16bit
2:20
resolution we will write the code in a
2:22
way that the voltage calculated by the
2:24
ADC at this point will be positive 3.3
2:28
Vols when the positive and negative
2:31
inputs become equal the converted value
2:33
will be exactly half the
2:36
maximum the calculated voltage at this
2:40
zero and similarly when the positive
2:43
input is equal to zero and negative
2:45
input is equal to VRE plus the converted
2:48
value will be zero the calculated
2:51
voltage at this point will be -3.3
2:55
Vols differential adcs require specific
2:59
conditions to function
3:01
correctly one of them is that both the
3:03
inputs should be biased at half the
3:07
voltage in other words instead of
3:09
fluctuating around 0 volts the signals
3:13
should be centered around 1.65 volts we
3:17
should also consider the common mode
3:19
voltage this common mode voltage is the
3:22
average voltage of two input signals in
3:25
a differential system this voltage only
3:28
has a small range in d m 32 and you can
3:31
find it in the data sheet of the device
3:34
here you can see the common mode voltage
3:37
varies by only 10% from half the vref
3:40
voltage so if the vref is at 3.3 volts
3:44
the common mode voltage can vary from
3:46
around 1.48 Vol to 1.82 Vols when
3:51
choosing the input voltages on both the
3:53
differential pairs make sure the average
3:56
of both voltages lies within this range
3:59
it does not mean that it will not work
4:01
outside this range rather the result
4:04
outside this range is
4:06
unpredictable in certain cases it might
4:08
work while in other cases it won't we
4:11
will also see this in a while let's
4:14
start the CU ID now I have already
4:18
created a project and here you can see
4:20
the clock is configured to run at
4:24
MHz now let's go to adc1 and I am
4:28
configuring Channel 3 fre in the
4:30
differential mode you can see the pin
4:33
pa6 is configured as the positive input
4:35
pin whereas pa7 is the negative input
4:39
pin let's configure the ADC now I am
4:43
enabling The Continuous conversion mode
4:46
so the next conversion can continue
4:48
after the previous one is
4:51
finished let's enable the ADC Global
4:54
interrupt also all right that is all
4:57
click save to generate the project
4:59
object let's Define a variable to store
5:02
the raw ABC value and the voltage
5:05
variable will store the converted
5:07
voltage inside the main function start
5:10
the ADC in interrupt mode but before
5:14
that let's call the calibration function
5:16
to calibrate the ADC in single-ended
5:19
mode once the ADC finishes the
5:22
conversion an interrupt will trigger and
5:24
the conversion complete call back will
5:26
be called inside this call back we will
5:29
first read the raw ADC value then use
5:33
this value to calculate the
5:35
voltage here I want the voltage range to
5:38
vary from positive 3.3 Vol to -3.3 Vol
5:44
this formula is taken from one of the
5:46
examples provided by the St all right
5:49
that is all let's build and debug the
5:53
project I have added both the variables
5:57
expression I am using the active Pro to
6:00
supply the variable voltages on both the
6:02
inputs here the A1 channel is connected
6:06
to the positive input of the ADC and the
6:08
a z channel is connected to the negative
6:11
input let's run the debugger now let's
6:14
Supply 1.6 volts on both the
6:17
inputs the voltage calculated by the ADC
6:21
is around 0 volt the values are changing
6:24
very fast here let's make some
6:27
modification in the code instead inad of
6:29
doing the calculation in the Callback
6:31
function let's just set the variable is
6:34
done here and later in the while loop we
6:38
will check if this variable is set if it
6:41
is then we will do the calculation here
6:44
itself and provide some delay so that
6:47
the values do not change rapidly all
6:50
right let's debug the project again all
6:54
right the voltage is around zero right
6:57
now now I have increased the positive
6:59
Supply to 1.7 Vol while the negative is
7:03
still 1.6 Vol the voltage variable
7:07
clearly shows the difference in voltage
7:11
Ms now the difference is 200
7:17
M and now we have a difference of 400
7:22
m now I am providing 3 volts to the
7:25
positive Supply and you can see the
7:27
difference is around 1,500 100
7:30
m note that at this point the average
7:33
voltage on both the inputs is around 2.3
7:36
Vols which is outside the common mode
7:39
voltage range hence we are not getting
7:42
accurate data for these
7:44
inputs now the difference should be 1
7:47
volts but we are getting around 1.5 Vols
7:51
the average voltage of inputs is way
7:53
higher than the common mode voltage and
7:56
therefore the value is inaccurate now
7:59
both in puts have the same voltage so
8:01
the difference is zero the average input
8:04
voltage is very close to the common mode
8:06
voltage range hence we are getting
8:09
correct data but it is still not very
8:12
accurate now the difference in the input
8:15
voltage is 1 volt and we are getting
8:17
accurate data the average input voltage
8:21
is also within the common mode voltage
8:24
range so as long as the average input
8:27
voltage is within the common mode
8:30
the ADC will measure the difference in
8:32
the input voltages very
8:34
accurately it still measures the voltage
8:37
outside the common mode voltage range
8:39
but the average input voltage should not
8:41
be too far from the common mode voltage
8:44
range when both the inputs are set to
8:47
zero the average input voltage is too
8:49
far from the common mode voltage
8:52
range hence we are seeing a very
8:55
inaccurate calculated voltage at this
8:57
point let's try to calculate some
9:02
too now the positive input is at 0 volt
9:05
whereas the negative input is at 3.3
9:09
Vol you can see the calculated voltage
9:14
Vol basically the calculated voltage has
9:17
the range from -3.3 Vol to POS 3.3 Vol
9:23
so you saw how the differential ADC
9:25
measures the voltage difference between
9:27
the two inputs we should also take care
9:30
of the common mode voltage range while
9:33
designing the project if you want to
9:36
measure low voltages you can use a
9:38
custom low reference voltage I have
9:41
covered how to do it in the previous
9:43
video itself that is it for the video I
9:47
will make a video in the near future
9:49
covering the application of differential
9:51
ADC where we will measure readings of
9:53
the strain gauge you can download the
9:56
project from the link in the description
9:59
leave comments in case of any doubt keep
10:03
watching and have a nice day ahead