Post on 21-Jan-2016
description
11
Embedded Systems Programming
Custom sensors for the use with Atmel ATmega8535 microcontrollers
and the Kanda STK200 board
Designed by Richard AnthonyUniversity of Greenwich
2
New sensors for the ATmega8535
Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Light Sensor
Connects to Analogue input ADC7 (pin 7 of Port A)
Reading increases as light intensity increases
3
New sensors for the ATmega8535
Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Floor-Switch Sensor
Connects to Digital input (bit 0 of any port)
When the mat is stepped on, the switch operates
4
New sensors for the ATmega8535
Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Passive Infra-Red (PIR) Sensor
Connects to Digital input (bit 2 of any port)
When a person moves, in detector range, the internal switch operates
5
New sensors for the ATmega8535
Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Magnetic-Switch Sensor
Connects to Digital input (bit 1 of any port)
When the magnet is moved in / out of range, the switch operates
66
New sensors for the ATmega8535
Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Twin Variable Resistor Sensor
Connects to Analogue inputs ADC2 and ADC3(bits 2 and 3 of port A)
Rotating the dials changes the analogue resistance values
77Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Peripherals – Thermistor (2)
Our custom temperature sensor can be connected to bit 6 of port A.
(Must be used on port A because it is an analogue device and needs to be sampled using the ADC).
88Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Peripherals – Thermistor (2)
Digital value (reading most significant 8-bits from 10-bit ADC)
708090
100110120130140150160170180190200210220230240
0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100
Temperature (degrees Celcius)
AD
C o
utpu
t val
ue
Thermistor temperature sensor probe calibration (8-bit values read as ADCH, i.e. most significant 8 bits)
9
Peripherals – Humidity Sensor
Our custom Humidity sensor can be connected to bits 3, 4, 5 of port A (uses all three bits).
(Must be used on port A because it is an analogue device and needs to be sampled using the ADC).
1010Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Peripherals – Sounder
Used in PCs, Christmas cards, alarm clocks ….
Low output current needed - can be driven directly from a parallel port pin.
Our custom sounder device is connected to bit 3 of the port.
You need to configure the pin for output and provide a pulse on the port bit 3.
See the Loudspeaker demonstration project provided.
1111Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Peripherals – Motor with shaft encoder and H/W Interrupt generation
MotorCan be driven via bit 3 of any port (‘1’ provides power to the motor).
Primarily designed for PWM using Timer/Counter0. Timer 0 Output Compare Match Output OC0 is the alternate function of Port B bit 3.
Motor can reach speeds exceeding 100 Revolutions per Second (6,000 RPM).
Motor stalls if driven with a duty cycle less than 29% (approximately 8 RPS).
Shaft EncoderComprises a ‘Slotted-Opto Switch’ (which detects when its light beam is broken) and a rotor with four cut-outs, enabling detection accuracy of ¼ rotation (i.e. 90 degrees).
If measuring rotational speed, four pulses represent 1 revolution.
The output of the Slotted-Opto Switch is connected to bit 2 of any port.
Primarily designed to generate a Hardware Interrupt INT0, which is the alternate function of Port D bit 2.
Peripherals – Motor with shaft encoder and H/W Interrupt generation
1212Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Connections to Port B and Port D
Motor
Rotor
Slotted Opto
Switch
1313Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Peripherals – Motor with shaft encoder and H/W Interrupt generation
Motor
Rotor
Slotted Opto
Switch
Transistor driver
circuit for motor
14Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Peripherals – Shaft encoder
Infrared light beam
IRLED
IRsensitive transistor
(under rotor)
15
There is also a simpler motor rig that does not have the optical feedback system
Details will be added soon
1616Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Digital Signal Processing – D-to-A conversion with a resistor ladder
A simple 8-bit R-2R resistor ladder(connects to any port, uses all 8-bits configured as outputs)
Converts a Digital value in the numerical range 0 – 255 into an Analogue value in the range 0 Volts to 5 Volts
Resistors
8 Analogue outputs, one per stage to
allow experiments
Bit 0
8 bit Digital data input
Bit 7
1717Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Digital Signal Processing – D-to-A conversion with a resistor ladder
Oscilloscope Earth connection
1818Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Digital Signal Processing – D-to-A conversion with a resistor ladder
Oscilloscope Earth connection
19Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Peripherals – Accelerometer and X-Y axis Bar LEDs
20
Peripherals – Accelerometer and X-Y axis Bar LEDs
Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
21Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Output device - SERVO
Converts a control signal from a single digital output port pin into a precise rotational position (angle).
PWM is used to generate the control pulse width in the range 0.5ms – 2.5ms (1.5ms pulse indicates the ”neutral“ / central position).
Rotation: 180 degrees.
22
Peripherals – Servo adapter board
Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
To Microcontroller
port
To Servos
Power (from supply) 5Volt to 6Volt
Ground from supply (0Volt)
23
Peripherals – Servo adapter board
To Servo
Signal (PWM pulse)
Power 5Volt to 6Volt
Ground (0Volt)
Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
24
Peripherals – Servo adapter board
Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Two servos connected, using both Timer1 PWM
channels
25
Peripherals – Servos in use (simple 2-servo robot)
26
Peripherals – InfraRed receiver (RC5 command receiver, as in TV remote controls)
InfraRed receiver
27
RFID reader
Peripherals – Radio Frequency Identification (RFID) reader
“Tag read”Indicator LED
RFID tag
28Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Peripherals – KeypadProvides a simple means of numerical data or control input. The Keypad has 12 buttons arranged in a 4 Row * 3 Column Matrix:
2929
Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
The LCD provides a versatile means of displaying alphanumeric data and messages (such as error codes, status messages, and user instructions).
The LCD can display 2 rows of 16 characters.
LCD display panel
Peripherals – Liquid Crystal Display (LCD)
Embedded Systems Programming II Richard Anthony, Computer Science, The University of Greenwich
Peripherals - Seven Segment display
30