Digital Electronics
Digital Electronics
Abstract
The amount of time put in to understanding and successfully achieving the aims of this task could not
be foreseen. The task was to build an oscilloscope analogue font end from simple circuit components
and a breadboard. It had to be a two-channel-with-trigger oscilloscope. The inputs of the analogue
front-end circuits needed to be digitized using the MSP432. The MSP432 had to be programmed to
capture samples of the analogue signal for a selected analogue input at a suitable sample rate and send
these over USB to a PC. The samples had to be displayed as a waveform on the PC. Then, a PMW
output and external low-pass filter had to be configured to give a programmable voltage value to a
comparator input on the MSP432. An interrupt service routine had to be written that was triggered
when a selected analogue exceeds the programmable trigger value set with the PWM output.
The solutions involved a potential divider for attenuation. A unity gain buffer and gain op
amp for amplification. These together resulted in a signal between 0-3.3V going into the analogue
input of the MS432. A PWM will be generated and be put through a low pass filter and comparator
to enable and interrupt service routine. The schematic can be seen in the appendix.
Table of contents
SECTION 1 – Input Stage……………………….……………………………………………. page 2
1.1 Attenuation …………………………………………………………………………………………………….. page 2
1.2 Amplifier …………………………………………………………………………………………………………. page 4
1.3 Low Pass Filter ……………………………………………………………………………………………….. page 9
1.4 Comparator ……………………………………………………………………………………………………. page 12
1.5 Interrupt …………………………………………………………………………………………………………. page 13
1|Page
Section 1 – Input Stage
2|Page
In order to attenuate the signal, a potential divider was constructed from two resistors. The values
chosen were one mega ohm and 45.3 kilo ohms. This gives approximately a division factor of 20 (See
appendix).
An offset voltage is used to deal with the negative part of the signal by shifting it up. The R3 and R4
resistors create a low impedance divider to create the offset voltage. The capacitor C1 is used to keep
the signal from varying or floating around. This divider creates a voltage of 1.062 volts to lift the
voltage out of the input divider (see appendix).
The total voltage out of the attenuator will be the voltage out of the input signal dividers added with
voltage out of the low impedance dividers which lifts the voltage. This would mean that a total
voltage of 1.4 volts should be leaving the attenuation stage. However, this was not the case as seen
from the oscilloscope reading below.
The signal is not in the right form. The problem was the 45.7 kilo ohm resistor was actually a 2.2 kilo
ohm resistor. This meant that there was a division factor of about 500. This meant the voltage sat on a
ripple at the capacitor instead of where it was supposed to be leaving the attenuator and was not
producing a large enough waveform. To solve this, four 10 kilo ohm resistors were put in series to
give a total resistance of 40 kilo ohms. The theoretical voltage should now be 1.44V total(See
3|Page
appendix). The actual voltage is approximately 1.44V coming out the attenuator. This should now
give a proper waveform as seen below.
4|Page
The waveform will be measured using the oscilloscope to ensure that the voltage is between 0-3.3V.
Below is the schematic and picture for this circuit along with the waveform.
5|Page
The voltage level is approximately 3.1V, which is in the ideal rangebut high. However, there is not a
proper waveform. There voltage signal appears to be on a ripple again. This becomes especially
problematic when using the MSP432 to take samples of the analogue input using the Energia
software. Below is the Energia sketch used to read 1000 samples from the analogue pin P5.2(A3) on
rail 20, that will print the samples on the Serial Monitor or plotter. The full code can be seen in the
appendix.
This code reads the analogue input A3 and measures the time it takes to get 1000 samples in
microseconds. It does this in a loop and repeats itself every time the values are printed on screen with
a delay of give seconds between loops.
6|Page
This problem was caused by a simple error in circuitry. Below is the Serial Monitor and Serial plotter.
The problem was with the op amps and they were increasing the voltage instead of having a
Gain of one. The voltage in the analogue input is now at 1.21V approximately.
The serial monitor is reading that 20527 microseconds passed too read 1000 samples from the
Analogue input. Below is the serial plotter.
The irregularities of the waveform is some noise being generated somewhere in the circuit. I believe
it is caused by the oscilloscope channel two wir
7|Page
Oscilloscope displaying input signal(otamge) versus the signal gain of one(blue).
8|Page
Section 1.3 Low Pass filter
The low pass filter was made from a 10-kilo ohm resister(R6) and a 4.7 micro farad capacitor(C2). R6
is connected to pin 40 of the msp. An Energia sketch was uploaded to the msp to give a PWM (pulse-
width modulation) output. The Energia sketch can be seen in the appendix. This is the part of the code
which sets the PWM signals.
The cut off frequency of the low pass filter is 3.39 hertz(see appendix for formula). This was
calculated using the cut-off frequency formula. The low pass filter attenuates the PWM signal
converting it nearly to a DC type signal. The output of the low pass filter is the average voltage of the
PWM signal. But the signal has a very tiny ripple. Below is the input PWN signal(orange) and the
output of the low pass filter(purple) displayed using the oscilloscope. This is with a PWM duty cycle
of 80.
9|Page
At a PWM of 0, both signals are low and overlapping.
AT a PWM of 180, the output rises with the rise in the input modulation.
A PWN of 200 shows the output signal rising again with a rise in modulation.
10 | P a g e
These results show that the PWM and the output of the low pass filter are directly proportional. As
PWM rises, so does the output and visa-versa. When the PWM is at zero it is always off, and at 255 it
is always on. The output matches the PWM signal.
11 | P a g e
Section 1.4 Comparator
This is made using the MCP6002 rail-to-rail op amp. This is important so the range of the output
square signal can reach the full range of voltages powering the op amp. The op amp is powered
using the 3.3V supply of the msp. The 3.3V is being used as the reference voltage. If the inverting
input is higher then the non-inverting input, the output will be LOW towards negative supply i.e zero
volts. When the non-inverting signal is higher then the inverting signal, the output will be HIGH
towards the reference voltage. For this to work, the non-inverting and inverting signasl must overlap
as seen below.
The inverting signal is the output of the low pass filter. The non-inverting signal is the signal from the
amplifier with a gain of one. The two input signals overlapped at a PWM of 80. If the PWM is higher
at a value of 120 for example, the comparator does not work properly.
The output of the op amp does not rise and fall with the variation of the inverting and non-inverting
signals. The same happens when the PWM is set below 80 but the output sits above the non-
inverting input. The reason they need to overlap is so the two inputs can be greater and less then
each other in order to get an output. At a PWM of 80, the out of the op amp comparator is this:
12 | P a g e
As the non-inverting input rises, the output signal goes HIGH i.e non-inverting signla greater the
inverting signal. When the input decreases, the output goes LOW i.e inverting signal greater then
non-inverting signal.
This part of the code is the part that prints out the analogue data until the interrupt service routine is
activated and then exited by removing the pin contact.
Once the interrupt service routine is enabled the program will come here.
When the serial monitor is opened, a list of zeros are displayed. This is because the start of the code
sets all analogue outputs to zero as seen here:
13 | P a g e
When the trigger is touched to pin 2.6, the interrupt service is entered for as long as the pin is
touching the trigger. To show the interrupt service routine is entered, the message “In Interrupt” is
displayed on the serial monitor.
14 | P a g e
When the trigger is taken away from the pin, the samples are displayed.
15 | P a g e
Appendix
𝑅2 45.3𝑥103 1
𝑅1+𝑅2
=1𝑥106 +45.3𝑥103 ≅ 20
𝑅4 270
𝑅3+𝑅4
𝑥5𝑉 = (1𝑥10^3+270)x5V = 1.06V
40𝑥103 270
10×( ) + 5×( ) = 1.44V
1𝑥106 +40𝑥103 1𝑥3+270
16 | P a g e
17 | P a g e
1 1
Cut off frequency of low-pass filter: = = 3.39 Hertz
2𝜋𝑅𝐶 2𝜋(10𝑥103 )(4.7𝑥10−6 )
18 | P a g e