Download as pdf or txt
Download as pdf or txt
You are on page 1of 32

HSI255

WEEK 2
EMBEDDED SYSTEMS
WHAT ARE THEY?

Wikipedia:

“An embedded system is a computer system—a combination of a computer processor,


computer memory, and input/output peripheral devices—that has a dedicated function
within a larger mechanical or electronic system. It is embedded as part of a complete
device often including electrical or electronic hardware and mechanical parts.”

https://en.wikipedia.org/wiki/Embedded_system
EXAMPLES

https://www.electronicshub.org/embedded-system-real-time-applications/
CAN YOU THINK OF SOME OTHERS?
LABJACK
WHAT IS A DAQ?
• DAQ – Data Acquisition Device
• A device that is used to collect physical information and make it usable for a
digital device (a computer).
• In other words, takes analog signals and makes them digital.

https://www.omega.ca/en/resources/daq-systems
ANALOG VS DIGITAL

• Analog signals are continuous with an


infinite amount of steps.
• Digital signals are not continuous. There
are discrete steps. Binary – on or off.
• DAQs convert analog signals (physical)
into digital signals so computers can
understand them.

https://runwayaudio.com
RESOLUTION

• Analog voltage ranges map to a


digital representation.
• I.e., 8-bit, 12-bit, 16-bit.
• The higher the bitrate, the more
accurate the representation (but the
more data it takes).
NORMAL STATES
NORMAL STATE

• Embedded systems have one or more inputs and one or more outputs.
• Inputs are READ.
• Outputs are SET.
NORMAL STATE

• Recall:
• Inputs are READ.
• Outputs are SET.
• As inputs are READ, we are looking for a change in state before we do
something.
• We need to know the normal state of an input before we can do something
with it.
SWITCHES
INPUT OR OUTPUT?

• Switches are inputs!


• Allow us to interact with our projects (and beyond).
• Turn an analog signal (physical force) into a digital one (off or on).
TYPES

• Method of actuation.
• Number of contacts.
• Number of poles and throws.
TYPES

https://www.allaboutcircuits.com/textbook/digital/chpt-4/switch-types/
SPST
SPST
OUR SWITCH - SPST

• We only use one type in this course: single-


pole, single-throw, toggle-type with
momentary operation.

From datasheet:
OTHER SWITCHES
SWITCH CIRCUITS

• To use switches as an input, we need VS and GND.


• We need to read the voltage to check if the switch has been pressed.
• What channel to use?
• What are we missing in the circuit?
SWITCH CIRCUITS
Pull-up resistor Pull-down resistor

Switch S2 Closed

Switch S1 Closed
SWITCH CIRCUITS

• Switch circuit on the left is in a pull-down


configuration.
• Switch circuit on the right is in a pull-up
configuration.
• Always place your HSI255 switches over
the divider of your breadboard as you
will otherwise run out of space for
jumper wires.
PULL-UP/PULL-DOWN

• Pull-up and pull-down resistors do two things:


• Protect the channel being read.
• Provide a FIRM high or low reading (no floating values).
WHILE LOOPS
WHILE LOOPS

• A while loop is used to repeatedly execute a statement/block of statements


as long as a condition is TRUE (non-zero).

while(condition)
{
statements;
update expression;
}
WHILE LOOPS WITH LABJACK

• A lot of what we do with DAQs and microcontrollers is done repeatedly for


either a set period of time, indefinitely, or until some other condition is met.
• While loops are perfect for that.
• A while loop will repeatedly execute a statement/block of statements as long
as the given condition is TRUE (non-zero).
WHILE LOOP WITH LABJACK

• Determine your exit condition:


• “Kill-switch” (pushbutton has been pressed)
• After some time has passed (more on this in a later lecture).
• An event has occurred a certain number of times.
• Can combine multiple events (two pushbuttons are pressed) using && or ||

• Once you know your exit condition, you can build your while loop.
• Start with pseudocode! Writing it out in plain English makes it easier to later
fill in the LabJack sequences.
PUTTING IT TOGETHER
PSEUDOCODE

• Determine normal states for inputs.


• Determine what output values do something.
• Determine what series of events will make the output happen.
LET’S TRY IT!

• Two circuits:
• Switch on AIN1 in pull-down configuration.
• LED ON when DAC1 is high.
• Program description:
• Program starts with LED off. LED turns on when pushbutton is pressed. LED turns off when
user pressed a button and program ends.
LABJACK PROGRAMMING

You might also like