1 / 14

Device Drivers – Digital Voltmeter

Device Drivers – Digital Voltmeter. Analog to Digital Converters. An ANALOG to DIGITAL CONVERTER (ADC) is a device that measures analog signals and convert them to digital (binary) numbers:. Higher Voltage Ref . D9.   . 10-bit ADC. output 10-bit Number sequence. Input Pulse.

salome
Télécharger la présentation

Device Drivers – Digital Voltmeter

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. Device Drivers – Digital Voltmeter Jordan Nash - Microprocessor Course

  2. Analog to Digital Converters An ANALOG to DIGITAL CONVERTER (ADC) is a device that measures analog signals and convert them to digital (binary) numbers: Higher Voltage Ref. D9    10-bit ADC output 10-bit Number sequence Input Pulse Input Lower Voltage Ref. D0 Jordan Nash - Microprocessor Course

  3. ADC on the ATMega128 • The ATMega128 has a built in Analog to Digital Converter • 10 bits of data for each sample • Signals can be digitized from up to 8 inputs • 1 input can be digitized at a time • There is a multiplexer to select which input should be converted Jordan Nash - Microprocessor Course

  4. The ADC Registers I • The 10-bit ADC on Atmega103 receives its inputs from PORTF. • The Reference voltage is controlled by a potentiometer. • The device can be controlled by 4 on board registers: • ADCSR : ADC Status Register • ADMUX : Multiplexer Control • ADCH : Data Register for D9,D8 • ADCL : Data Register for D0-D7 Jordan Nash - Microprocessor Course

  5. ADCMUX –Register Select Channel ADCCSR – ADC Control and Status Register ADCL – Bits 0-7 ADCH – Bits 8-9 Multiplexer to select which channel to digitize ADC: 10 bit Analog to Digital Conversion 8 ADC Input Channels Jordan Nash - Microprocessor Course

  6. The ADCCSR ADEN:ADC Enable - turns on the ADC clock ADSC:Start conversion ADIF:Interrupt flag (gets set during a conversion and gets cleared if you write ‘1’ to it AFTER you have read BOTH data registers) ADIE: Interrupt enable (in the software we do not used interrupts so keep it ‘0’) ADPS0-2 :Three bits that determine the ADC clock prescale (e.q. 3 = 1/8) Jordan Nash - Microprocessor Course

  7. The ADMUX Register The ADC Multiplexer Register ADMUX is used to select a channel to digitise (3 bits for Channel 0-7) : Jordan Nash - Microprocessor Course

  8. The ADCH/ADCL Registers The ADC Data Register ADCL is used for the 8 lower data bits (D7 - D0) : The ADC Data Register ADCH is used for the two highest data bits (D9,D8) : ADCL ADCH Jordan Nash - Microprocessor Course

  9. Task Plan Design and construct a Digital Voltmeter: The Atmega103 on-chip ADCs should be used to digitise the input analog voltages. The LCD should be used to display the voltmeter readings. Switches or a keyboard can be used to tell the Voltmeter to capture data Connect your Voltmeter to the potentiometer and measure the voltage. Calibrate it against a Voltmeter in the Lab. Demonstrate that your device works !!!! Jordan Nash - Microprocessor Course

  10. Conceptual Design We want to construct : Voltage to be measured Connector ATmega103 Board LCD INTERFACE +5 Volts LCD DISPLAY HITACHI LM032XMBL 10K Use ADC0 Analog 10K PORTD Buttons Jordan Nash - Microprocessor Course

  11. Some Important points : The Voltage you are trying to measure must be between 0 – 2.5 Volts The reference voltage of the ADC should not be lower than the voltage you are trying to measure! First you should set the reference voltage at its highest value (4.5 V) using the potentiometer and by measuring it at the Ref. pin of PORTF Jordan Nash - Microprocessor Course

  12. Software Design of the Voltmeter Start First ? Yes Initialize LCD Initialize the ADC No Display the voltage on to the LCD Display a message on the LCD saying that the Voltmeter is ready to make a Measurement and ask the user if he wants to measure a voltage (capture data) Yes Decode the Input and if it is ‘YES’ then digitise a Voltage No Read in Input from PORTD or the Keyboard Jordan Nash - Microprocessor Course

  13. Getting Started Use the user interface you created with the LCD display and the keyboard or the PORTD switches. Read about using the on-board ADC in the ATmeag128 manual. Use the routines in the ADC1.inc program on the web pageas a starting point Jordan Nash - Microprocessor Course

  14. ADC Driver routines .defTempReg =r16 ADCInit: ; ******* ADC Setup Code **** ldiTempReg, $83; ADC Interrupt Disabled, ADC Enable out ADCSR, TempReg; ADC Free Run Mode, Prescaler:CK/8 ret ADCsel: out ADMUX, ADCChannel; Channel Selection ret DCATrig:SBI ADCSR, 6 ; Cause a Conversion rcall DEL600mus IN ADCDL, ADCL ; Read in Low Byte IN ADCDH, ADCH ; Read in High Byte ADCCLR: SBI ADCSR, 4 ; Reset ADIF IN TempReg,ADCSR; Read in Status SBIC ADCSR, 4 ; Wait till the Interrupt flag RJMP ADCCLR ; is cleared RET Jordan Nash - Microprocessor Course

More Related