1 / 24

EMS1EP Lecture 9 Analog to Digital Conversion (ADC)

EMS1EP Lecture 9 Analog to Digital Conversion (ADC). Dr. Robert Ross. Revision of Analog and Digital ADC + Quantisation Examples of Analog Inputs Worked examples Minor Project Major Project. Overview (what you should learn today). Analog/Digital. Digital Voltages.

tyra
Download Presentation

EMS1EP Lecture 9 Analog to Digital Conversion (ADC)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EMS1EP Lecture 9Analog to Digital Conversion (ADC) Dr. Robert Ross

  2. Revision of Analog and Digital ADC + Quantisation Examples of Analog Inputs Worked examples Minor Project Major Project Overview (what you should learn today)

  3. Analog/Digital Digital Voltages Control Physical Variable (Sound, light, pressure, temp, ect) DAC Digital to Analog Converter Microcontroller (LArduino) ADC Analog to Digital Converter Physical Variable (Sound, light, pressure, temp, ect) Transducer (Sensor) Actuator Analog Voltages

  4. Analog to Digital Converters (ADC) • Measure an analog value and provide a digital representation of this value • Like a digital multimeter for your microcontroller • Inside the Arduino microcontroller • Several different techniques used (covered in second year microcontrollers)

  5. ADC quantisation • Converting a continuous value into a digital number • Arduino has a 10bit ADC – (210 = 1024 voltage levels) • Value returned in the range of 0-1023 (corresponding to 0-5V) • 5/1023 = 4.89mV/step • Each time you increase the voltage by 4.89mV the digital value should go up 1 step

  6. ADC on the LArduino • LArduino has 4 analog inputs (marked Analog 0-3) • Analog inputs can be connected to all of these inputs at the same time • Can only read one analog input at a time

  7. Using the ADC • Analog pins don’t need to be setup in the setup function • To read an analog value use the analogRead() command. • Syntax: int analogRead(<ADC Pin>); Returns the analog result <ADC Pin>: specifies which ADC pin you wish to read (i.e. Pins 0-4) Typical use: int ADC_Result; ADC_Result = analogRead(2);

  8. Temperature Acceleration Voltage (Variable resistor forms voltage divider) Pressure Light Examples of Analog Inputs

  9. Worked Example: Potentiometer • Interface a potentiometer to an analog input on the Arduino • Every 500ms read the value of the potentiometer and send it via the serial port to the PC • If the value is more than 500 turn ON an LED – else turn off LED

  10. Voltage (Variable resistor forms voltage divider) 5V Pin5 Worked Example: Potentiometer • Circuit Diagram 5V LArduino Board Analog Pin2

  11. Worked Example: Potentiometer int pot1 = 2; int led1 = 5; int ADCValue; void setup() { Serial.begin(<baud rate>); //Setup serial port pinMode(led1, OUTPUT); //Setup LED delay(500); }

  12. Worked Example: Potentiometer void loop() { ADCValue = analogRead(pot1); //Read analog value Serial.print(“ADC Result: “); Serial.println(ADCValue); if(ADCValue > 500){ //Turn LED on digitalWrite(led1,LOW); } else{ //Turn LED off digitalWrite(led1,HIGH); } delay(500); //500ms delay }

  13. Measuring multiple ADCs • Only one ADC can be measured at a time • If more than one need to be measured step through and measure one after another ADCValue1 = analogRead(ADC1); ADCValue2 = analogRead(ADC2); ADCValue3 = analogRead(ADC3);

  14. 5V LArduino Board 5V Analog Pin1 Pin6 Worked example: Light Sensor • Create a ‘garden light sensor’ • A photodiode is used to sample how much light there is and gives an analog voltage output • If the voltage is below a preset threshold then turn on another LED – otherwise turn off the LED 100K

  15. Worked Example: Light Sensor int pd1 = 1; int led1 = 6; void setup() { pinMode(led1, OUTPUT); //Setup LED } void loop() { //You fill in this section }

  16. Minor Project: Level Crossing System • Construction of a train level crossing system • Description – a level crossing system using 1 servo as the boom gate, activated by a debounced switch and with flashing warning lights and a audible buzzer alarm • Deliverables: • Working System for demonstration day • Schematics (completed in Altium) • Code

  17. Minor Project: Level Crossing System • When the switch is pressed (and at some point released): • The boom gate should come down (servo turn 90o) • Two LEDs should alternately flash at 1Hz • A buzzer should be controlled to beep in 0.5 second bursts (use PWM with 50% duty cycle) • The switch is a debounced switch. When the switch is pressed a second time the boom gate should come up, the LEDs should stop flashing and the buzzer should remain silent • See handout for more details • Minor project is to be completed in the lab (may require a small amount of extra outside lab time) • Demonstrations in lab 8

  18. What the minor project should look like

  19. Major Project • Build a robot • Infrared photodiodes on the bottom (allow it to sense light/dark objects • Battery powered • Control algorithms • Applications • Line tracking/following • Staying inside a paddock • Racing

  20. What the major project should look like

  21. Continuous Rotation Servos By default servo motors only have about 180O of motion that they can travel over Servos can be modified for continuous rotation (they can go all the way around) PWM signal controls speed not position of continuous rotation servos Involves: Removing feedback potentiometer (variable resistor) Soldering in resistors Cutting notch out of gears Instruction video will be provided in the labs

  22. Control Algorithms • Three light sensors on the bottom of the robot used to detect the lines • For line following want to keep it close to the middle sensor • Possible readings: • No Sensors (but last seen on S1) • S1 only • S1+S2 • S2 only • S2+S3 • S3 only • No Sensors (but last seen on S3) S1 S2 S3

  23. Control Algorithms • Suggested algorithm is a proportional one • The further away the robot is from the line (S2 only) the larger change in its relative speed between the wheels it should make • Should also give the robot a little forward bias so it keeps moving forward and doesn’t get stuck in tight bends • Can switch between just driving forward and control algorithm • Will need to experiment with different speeds and find a mix between speed and stability • Execution tests will have races with the fastest robots receiving bonus marks (but they must not leave the track)

  24. Many sensors that our microcontroller needs to read are analog An ADC enables the microcontroller to read an analog value and convert it to a digital number Introduction to the minor and major project tasks Summary(What you learnt in this session)

More Related