4. Simple Circuits, Switching, and Logic
4.1. Purpose
Basic concepts in producing inputs and outputs for connection to an embedded system are introduced. Inputs are demonstrated with switches (pushbutton and slide switches), with various combinations producing specific logic outputs. Outputs are are displayed using LEDs.
4.2. Hardware and Tools
[USB Test Device]: ADALM2000, Analog Discovery, or a multimeter (multimeters available in classroom)
Breadboard (provided in parts bag)
Components (provided in parts bag):
2x Pushbuttons
1x Slide Switch
1x LEDs
1x BiColor LED (BiLED)
Various Resistors (1x 330Ω,2x 1kΩ)
Wire (available in classroom)
4.3. Description
The basic building blocks for any embedded system are the Inputs, Outputs, and the Processing. For this class, the Processing block will always be the MSP432P401R microcontroller and we will use various Inputs and Outputs. For example, a simple system might be represented by the schematic below, where there are three inputs: PB1, PB2, and SS1 (two pushbuttons and a slide switch), and two outputs: LED1 and BiLED1 (an LED and a BiColor LED).
In this activity, we look closer at the Inputs and Outputs to hopefully understand the pieces a little better and also to build an understanding of why Processing is so useful in an embedded system as opposed to building “dumb” circuits.
4.4. Instructions
For all questions below, you may answer them on either a piece of paper or in a computer document.
4.4.1. Inputs
We will first explore inputs as generated by pushbuttons. These inputs are known as Digital inputs as they can only produce one of two states: True or False. As a note, you might also see True represented as High (HI) or 1. Similarly, False can also be referred to as Low (LO) or 0.
A pushbutton serves to either connect (close) or disconnect (open) an electrical circuit. Let’s consider the circuit as described below (left), where a pushbutton can connect the Input line to Ground (GND). There is a distinct problem with this circuit which we will explore in the first task; which should be clear from the lecture.
Warning
Note that no power supply is used for the circuit below; only ground and an input channel.
Testing the basic pushbutton circuit. You may skip this task if the problem with the above circuit is already clear to you.
Build the above pushbutton circuit and connect the Oscilloscope lines from your USB Oscilloscope to the points as indicated on schematic on the right. Note: If using a multimeter, the CH1- would be the COM or GND (usually black lead) connection whereas the CH1+ is the V connection (usually red lead).
Turn on the oscilloscope and configure the window such that you can clearly see the measured voltage waveform.
Press and release the pushbutton.
Did you notice any change in the output? Specifically, did you see a significant voltage level change?
Would this circuit be useful as an input to a system?
Now let’s look at a slightly different circuit:
Add the resistor and 3.3V connection as shown in the circuit above. For the ADALM2000 and Analog Discovery boards, don’t forget to enable your 3.3V supply!
Press and release the push button.
Did you notice any change in the output? Specifically, did you see a significant voltage level change?
Would this circuit be useful as an input to a system?
Complete the truth table below with either True and False or 1 and 0:
Pushbutton State
“Input” Value
Pressed
Released
Now lets switch the components around. Build the circuit below and answer the questions above again.
You should have noticed that one of the circuits built in steps 2 and 3 produced an inverted response to the pushbutton press. Why?
Let’s try a more complicated circuit with a slide switch. Build the circuit in the figure below. You’ll need both your oscilloscope channels to test this one, one for Input_1 and the other for Input_2.
Complete the truth table for this circuit. Assume that the slide switch On value is when it passes the 5V connection.
PB1
PB2
SS1
Input_1
Input_2
Released
Released
Off
Pressed
Released
Off
Released
Pressed
Off
Pressed
Pressed
Off
Released
Released
On
Pressed
Released
On
Released
Pressed
On
Pressed
Pressed
On
While this “complex” circuit above demonstrates the possibilities for building logic with switches (and in the same vein, transistors), the usefulness of such a structure is reduced when using a microcontroller. Assuming you have three independent inputs within a program,
PB1
,PB2
, andSS1
, which are all independent of each other, what is the effective binary (Boolean) logic commands that could be used to generate the equivalent value for variableInput_2
in terms of AND (&
), OR (|
), and NOT (~
) operations?
4.4.2. Outputs
Similar to the pushbuttons and slide switch providing a digital input to a microcontroller, the microcontroller can also provide a digital output for applications including control, communication, user interfaces, etc. For this activity, we’ll consider an LED and a BiColor LED (BiLED).
Modify the last build schematic by adding in a single LED and BiLED as shown.
Take a picture of your final circuit and submit with your answers to the above questions and completed tables to the corresponding Gradescope assignment.
This final circuit is effectively a “dumb” circuit that could be replaced by the first schematic contained on this page; however, in using the microcontroller, it is also possible to make quick and easy changes to the final truth table through code alone, as opposed to rebuilding the circuit for each desired instance. That is, a simple software edit is all that is needed as opposed to a physical hardware reconfiguration.