Robotics Research Laboratory Louisiana State University.

Slides:



Advertisements
Similar presentations
Mark Neil - Microprocessor Course 1 Device Drivers – Digital Voltmeter.
Advertisements

The 8051 Microcontroller Chapter 5 SERIAL PORT OPERATION.
Analog to Digital Conversion
Analog/Digital Subsystem
Analog Comparator Positive input chooses bet. PB2 and Bandgap Reference. Negative input chooses bet. PB3 and the 8 inputs of the A/D. ACME= Analog Comparator.
Robotics Research Laboratory Louisiana State University.
1 Lab2: A/D Converter. 2 This circuit connects a variable voltage to an A/D port on the AVR mcu. Your software running on the AVR mcu will read the digital.
Explain the introduction to ADC, ADC characteristics, Programming ADC using PIC18, Introduction to DAC and DAC interfacing with PIC18.
Mark Neil - Microprocessor Course 1 Timers and Interrupts.
Intro to AVR ATtiny2313 CS423 Dick Steflik. AVR ATtiny2313.
Technion-Israel Institute of Technology Electrical Engineering Department High Speed Digital Systems Laboratory Project subject: wireless biofeedback system.
Butterfly I/O Ports CS-212 Dick Steflik. I/O for our labs To get data into and out of our Butterfly its a little trickier than using printf and scanf.
Railway Foundation Electronic, Electrical and Processor Engineering.
AVR Programming CS-212 Dick Steflik. ATmega328P I/O for our labs To get data into and out of our Arduino its a little trickier than using printf and.
Railway Foundation Electronic, Electrical and Processor Engineering.
Robotics Research Laboratory Louisiana State University.
The 8051 Microcontroller and Embedded Systems
Robotics Research Laboratory Louisiana State University.
Programming 8-bit PIC Microcontrollers in C Martin Bates Elsevier 2008.
V 0.91 Polled IO versus Interrupt Driven IO Polled Input/Output (IO) – processor continually checks IO device to see if it is ready for data transfer –Inefficient,
EE 446 Project Assignment Top Design Sensor Components Pin Assignment and Configuration Completed Physical Setup Project Tasks.
A Few Words From Dilbert
1 ARM University Program Copyright © ARM Ltd 2013 General Purpose I/O.
Embedded System Design Laboratory October 11, 2002Stanford University - EE281 Lecture #4#1 Lecture #4 Outline Announcements Project Proposal AVR Processor.
ELE2MIC Lecture 21 The AVR Sleep Modes ATMEGA128’s Analog to Digital Converter –Features –Block Diagram –Clock Source –Input Sources –Interrupts –BandGap.
RS232 #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7
بسمه تعالي AVR Microcontrollers. The ATmega8 Basic Features -1.
MICROCONTROLLER SYSTEMS Part 1. Figure 1.1Elements of a digital controller CPU Central Processing Unit Input Peripherals Output Peripherals ROM Read Only.
Atmel Atmega128 Overview ALU Particulars RISC Architecture 133, Mostly single cycle instructions 2 Address instructions (opcode, Rs, Rd, offset) 32x8 Register.
Robotics Research Laboratory Louisiana State University.
AVR Programming: Interrupts September 17, What are interrupts? An asynchronous signal indicating the need for an event to be handled A synchronous.
ATtiny23131 A SEMINAR ON AVR MICROCONTROLLER ATtiny2313.
Suleyman Demirel University CSS340 Microprocessor Systems – Lecture 2 ATMEGA328P ARCHITECTURE ANALOG INPUTS.
Interrupt. incoming Lab. Interrupt an asynchronous signal indicating the need for attention hardware interrupt/software interrupt call “interrupt service.
INTERFACING THE ADS1210 CONVERTER WITH AN ATmega8535 MICROCONTROLLER Author: Eng. Magnelli Luca.
智慧電子應用設計導論(1/3) Arduino MEGA 2560
Timers and Interrupts Mark Neil - Microprocessor Course.
Analog to Digital Converter (ADC). Analog to Digital Converters  Microcontroller understands only digital language.  To convert the analog output from.
CSCI1600: Embedded and Real Time Software Lecture 16: Advanced Programming with I/O Steven Reiss, Fall 2015.
Lab 3: ADC.
Computer Science Summer term 2012 Final Project Team 2.
Analog to Digital Converter (ADC)
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
Analog to Digital Conversion - ADC Mark Neil - Microprocessor Course 1 Device Drivers – Measuring Voltages.
INTERNET OF EVERYTHING SDU 2016 Week 4. Simple Digital and Analog Inputs  The Arduino’s ability to sense digital and analog inputs allows it to respond.
CS-280 Dr. Mark L. Hornick 1 Sequential Execution Normally, CPU sequentially executes instructions in a program Subroutine calls are synchronous to the.
Microcontroller basics Embedded systems for mortals.
Microcontroller basics Embedded systems for mortals.
Sensing Algorithm using IR Sensor and ADC Soong-sil University. Robotics 기 정 두 원.
1 Lab 4: D/A Converter Lab 4: D/A Converter This is a simple resistive network for a D/A converter Port 1, Port 0 are digital inputs ==> 00 (minimum),
1. PIC ADC  PIC18F877 has 8 analog input channels i.e. port A pins(RA0 to RA5) and port E pins(RE1 and RE2). These pins are used as Analog input pins.
Application Case Study Christmas Lights Controller
Arduino.
Assist. Prof. Rassim Suliyev - SDU 2017
Embedded Systems Programming
Environment Temperature Monitor
C. K. Pithawalla College of Engineering and Technology, Surat
68HC11 Interrupts & Resets.
Analog Comparator An analog comparator is available on pins PE2(AIN0), PE3(AIN1) The comparator operates like any other comparator. -when (+) exceeds (-)
Table 2. Microcontroller pin description[5]
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
Interrupt Source: under
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
The Arduino Microcontroller: Atmel AVR Atmega 328
ATmega103 Timer0 and Interrupts
ADC and DAC Programming in AVR
8051 Micro Controller.
Interrupt Chapter 10.
Device Drivers – Digital Voltmeter
Introduction to Arduino
Presentation transcript:

Robotics Research Laboratory Louisiana State University

 Analog to Digital (ADC, A/D or A to D) ◦ Converting an analog voltage to a digital value that can be used by a microcontroller. ◦ There are many sources of analog signals to be measured such as light intensity, temperature, distance, position, etc.  ATMega128 ADC has 10 bits resolution (0~1024) ◦ Has 8 channels through a multiplexer ◦ 8 pins on PORTF ◦ Need to set PORTF as input without pull-up ◦ Has own power supply (labeled AVCC) ◦ Allows measuring voltages from 0 to 5 volts with a resolution of 5/1024 volts, or 4.88 mV

S1 = 0 ~ Ω R2 = 1000 Ω V X V drop = Xi mA x S1 Ω X v+ restV drop = Xi mA x 1000Ω 0V drop = Xi mA x 0 Ω 5 V Connect to ADC 0 V Resistance value of S1(IR sensor) can be changed by sensing

uint16_t a2d_10( uint8_t Channel ){ // Select the channel in a manner which leaves REFS0 and REFS1 un touched. ADMUX = ( ADMUX & (( 1 << REFS1 ) | ( 1 << REFS0 ))) | Channel; // Start the conversion ADCSR = ADCSR | ( 1 << ADSC ); // Wait for it to complete while ( ADCSR & ( 1 << ADSC )); return ADC; // ADC defined at avr/iom128.h ( special function register: SFR_IO16) } // a2d_10 /home/csc2700/csc2700/40-ADC-01

 Our programmer has 2 serial port ◦ ttyACM0 : ISP programming port ◦ ttyACM1 : UART serial port  Wire connection ◦ PE0  Yellow wire ◦ PE1  Green wire ◦ GND  Black wire  Open Gtk-term ◦ Set port : /dev/ttyACM1 ◦ Speed: for ttyACM for Bluetooth connection

 Config.h ◦ Set : #define CFG_USE_UART0 1  Hardware.h ◦ Set : #define UART0_BAUD_RATE57600  ADC_test.c ◦ Add : #include "UART.h” ◦ Create file pointer : FILE *u0;// for UART0 ◦ Open u0  if defined( __AVR_LIBC_VERSION__ )  u0 = fdevopen( UART0_PutCharStdio, UART0_GetCharStdio );  #else  u0 = fdevopen( UART0_PutCharStdio, UART0_GetCharStdio, 0 );  #endif ◦ Send values using fprintf(u0,”your message %d”, variable) ; /home/csc2700/csc2700/40-ADC-02

 Check the UART buffer first ◦ int UART0_IsCharAvailable()  Read a character from UART buffer ◦ int UART0_GetChar() int counter; char tmpChar; While(1){ if ( UART0_IsCharAvailable() ) { tmpChar = UART0_GetChar(); if ( tmpChar == ‘s'){ // start moving }else if ( tmpChar == ‘c'){ // clear counter }else if ( tmpChar == ‘r’){// report counter number }

 Make a led0 on when ‘0’ message is received from UART  Make a led0 off when button0 is pressed  Make a led1 on when ‘1’ message is received from UART  Make a led1 off when button1 is pressed  Send “!!!good bye!!!” message to UART tx when “bye” message is received from UART rx

photo IR Temperature GAS Acceleration Humidity Sonar

 Internal Interrupt ◦ Timer interrupt ◦ Counter interrupt  External Interrupt  INT0 = SCL [PD0]  INT1 = SDA [PD1]  INT2 = RXD1 [PD2]  INT3 = TXD1 [PD3]  INT4 = OC3B [PE4]  INT5 = OC3C [PE5]  INT6= T3[PE6]  INT7= ICP3 [PE7]  RESET= RESET [RESET]  SPI, UART, etc

Main program Interrupt service routine Interrupt occur Interrupt Register Bit check Interrupt Trigger check Save Main program PC at stack Jump to Triggered Interrupt Vector Execute Interrupt Service Routine Load PC from Stack then, return to Main program

1) Falling edge2) Rising edge 3) Low level High: + 4 V Low: 0.9 V

ISCn1ISCn0Trigger Signal 00The low level of INTn 01Reserved 10The falling edge of INTn 11The rising edge of INTn // Grab the rising edge. EICRB |= (( 1 << ISC71 )|( 1 << ISC70 )|( 1 << ISC61 )|( 1 << ISC60 )); // External interrupt control register B EIFR = (( 1 << INTF7 ) | ( 1 << INTF6 )); // External interrup flag register EIMSK |= (( 1 << INT7 ) | ( 1 << INT6 )); // External interrup mask register DDRE &= ~(( 1 << 6 ) | ( 1 << 7 )); // PE6 & PE7 set input PORTE |= (( 1 << 6 ) | ( 1 << 7 )); // pullup for input sei(); // set interrupt cli();// unset interrupt

int leftCounter = 0; int prevLeft = 0; int runFlag = 0; long cnt = ; main(1){ // Grab the rising edge. EICRB |= (( 1 << ISC71 )|( 1 << ISC70 )|( 1 << ISC61 )|( 1 << ISC60 )) // External interrupt control register B EIFR = (( 1 << INTF7 ) | ( 1 << INTF6 )); // External interrup flag register EIMSK |= (( 1 << INT7 ) | ( 1 << INT6 )); // External interrup mask register while(1){ if (leftCounter != prevLeft){ prevLeft = leftCounter; PIN(LED,1,SET_TOGGLE); } while (cnt-- > 0){ } cnt = ; } // interrupt service routine for int6 SIGNAL(SIG_INTERRUPT6){ leftCounter++; PIN(LED,0,SET_TOGGLE); } // SIG_INTERRUPT6

 Make a counter for the optical switches on wheels  Make a clear the counter when ‘c’ message is received from UART  Make a report the counter when ‘r’ message is received from UART  Make a robot move forward when ‘s’ message is received from UART until the counter value is 90