Tags:
create new tag
view all tags

Exercise 8: Switches

Goal:

Switches don’t seem to be very thrilling devices, they are very important in control applications nevertheless. Here we are looking at switches in the wider sense: Relays are considered switches as, with a small signal they can switch a high current. Voltage comparators can act as switches, raising an alarm when a certain voltage level is exceeded. This can be due to high temperature, too much (or too little) light, to big magnetic field etc. Magnetic switches (reed relays) are often used in tachometers especially with bicycle speed meters.

Often the state change of a switched is observed in background and an interrupt is triggered when the change happens, treating the event of state change in an appropriate fashion.

Exercise 1: Switching a LED on/off

Create a circuit which allows you to switch a LED on. The LED is off if the pushbutton switch is not pressed. No program is needed for this.

Then create a circuit in which the LED is normally on but goes off when the button is pressed.

Finally implement a program that sees and displays the state of the LED.

Create a circuit + a program that makes the switch act as an flip flop: When pushed once the LED goes on and it stays on until the button is presses a second time.

Exercise 2: Switch the LED with a magnetic field

Use a sensor that allows you to switch a LED on, when a strong magnetic field is present (the earth magnetic field is always present). Try the same thing with a temperature sensor + comparator. You may have to set the switch threshold in order to make this work.

Exercise 3: Relay

Switch the secondary circuit of a relay which will now light the LED. You can use the 5V power supply for the secondary circuit.

Exercise 4: Pulse sequence

Write a program that reads a pulse sequence from a switch (The user repeatedly pushes and releases the button to create a pulse train). Show the pulse sequence on a plot. Play the pulse sequence on the LED. Use interrupts to implement this.

Exercise 5: Bouncing switches

Often mechanical switches do not change state at once but bounce back and forth for a very short time (some ms). Can you visualize this?

-- Uli Raich - 2017-01-15

Comments

Topic revision: r1 - 2017-01-15 - uli
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback