EE 22442 - Embedded Systems Fall 2015 Chapter Eight: The human and physical interfaces EE 22442 - Embedded Systems Fall 2015 Belal H. Sababha, Ph.D. Assistant Professor of Electrical & Computer Engineering Computer Engineering Department King Abdullah II Faculty of Engineering Princess Sumaya University for Technology Amman, 11941, Jordan Phone: +962-6-535-9949 ext. 222 Email: b.sababha@psut.edu.jo Web: http://www.psut.edu.jo/sites/bsababha
Introduction In this chapter we will learn about: Human interfacing needs and some simple means of meeting these. Some simple example sensors. Some ways of interfacing between sensor signals and the microcontroller. Some simple example actuators. Some ways of interfacing between the microcontroller and the actuator.
Human physical interfaces
Human physical interfaces 2
The keypad
Reading a Keypad
LED displays
Multiplexing of digits
//Live Demo: Display a counter from 0 to 9 on a Single 7 Segment incremented every 1 sec unsigned char tick=0; unsigned char i; unsigned char mysevenseg[10]={0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F}; interrupt(){ // TMR0 overflow interrupt occurs every 32ms tick++; //increment tick evey 32ms if(tick==33){ // this condition is true every almost 1 second i++; // counter incremented every 1 second if(i==10) i=0; tick=0; } INTCON = INTCON & 0xFB; // clear the interrupt flag void main() { TRISD = 0x00; //PORTD connected to the 7 segment OPTION_REG = 0x07; // Osc clock/4, prescale of 256 TMR0 = 0; INTCON = 0xA0; // Global Interrupt Enable and Local Enable the TMR0 Overflow Interrupt while(1){ PORTD=mysevenseg[i];
unsigned char tick, i, qq, rr; unsigned char sevenseg[10]={0xBF, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x67}; interrupt(){ //TMR0 interrupt increments tick every 32 ms tick++; if(tick==33){ i++; //increment counter every 1 second if(i==100) i=0; qq=i/10; // split i into two separate digits rr=i%10; tick=0; }//if INTCON = INTCON & 0xFB; //clear T0IF flag }//interrupt void main() { TRISD= 0x00; PORTD=0x00; ADCON1= 0x06; //PORTA is Digital TRISA = 0x00; // PORTA output, PORTA is used to enable the required 7 segment display to do time multiplexing OPTION_REG= 0x07; //osc clock select, with prescaler of 256 TMR0=0x00; INTCON = 0xA0; //Global Interrupt Enable, Local TMR0 Overflow Interrupt Enable while(1){ if(TMR0&0x40){ PORTA=0x02; // enable the 10’s seven segment PORTD=sevenseg[qq]; else{ PORTA=0x01;// enable the 1’s seven segment PORTD=sevenseg[rr]; }//else }//while }//main //Live Demo: Display a counter from 0 to 99 on a multiple 7 Segments incremented every 1 sec
Some simple sensors The microswitch Light-dependent resistors Optical object sensing Ultrasonic object sensor Hall effect sensor Temperature Sensor
The microswitch
Light-dependent resistors (LDR)
Optical object sensing Infrared reflective sensor Infrared reflective sensor 1.6V 0.1mA
Optical object sensing Rangefinder IR sensor Measuring range: 10-80 cm Current consumption: 30mA typical Includes 10" 3-wire cable Supply voltage: 4.5 - 5.5 V
Ultrasonic object sensor e.g XL-MaxSonar®-EZ™ Sensor Line Component Overview Resolution of 1 cm 10Hz reading rate Read from all 3 sensor outputs: Analog Voltage, Serial, Pulse Width Virtually no dead zone, objects closer than 20 cm range as 20 cm Maximum Range of 765 cm (300 inches) or 1068 cm (420 inches) Operates from 3.3-5.5V Low 3.4mA current requirement Small, light weight module Designed for easy integration into your project or product Operational Temperature from -40˚C to +70˚C (-40˚F to +160˚F) Real-time automatic calibration (voltage, humidity, ambient noise) Firmware filtering for better noise tolerance and clutter rejection 200,000+ Hours Mean Time Between Failure Retail Price Range: $29.95-$54.95
Hall effect sensor
Temperature Sensor Microchip - MCP9700/9700A Typical Applications • Hard Disk Drives and Other PC Peripherals • Entertainment Systems • Home Appliance • Office Equipment • Battery Packs and Portable Equipment • General Purpose Temperature Monitoring
Ensuring legal logic levels and input protection
Switch debouncing Reading Switches Polling Use interrupt to read switches
Actuators: motors and servos Brushed DC Motors Brushless DC Motors Stepper Motors Servo Motors
Motors Brushed DC Motor Brushless DC Motor Stepper Motor
Servo Motors Angular positioning: the ‘servo’
Interfacing to actuators Simple DC switching Reversible switching: the H-bridge
Simple DC switching
Reversible switching: the H-bridge