1 / 15

CSC-2700 – (3) Introduction to Robotics

CSC-2700 – (3) Introduction to Robotics. Robotics Research Laboratory Louisiana State University. What we learned in last class. DC Motor Controller (TB6612FNG). MOSFET-based H-bridges Metal–Oxide–Semiconductor Field-Effect Transistor. H- Bridge. Simple DC-motor control program.

cleo
Download Presentation

CSC-2700 – (3) Introduction to Robotics

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. CSC-2700 – (3) Introduction to Robotics Robotics Research Laboratory Louisiana State University

  2. What we learned in last class DC Motor Controller (TB6612FNG) MOSFET-based H-bridges Metal–Oxide–Semiconductor Field-Effect Transistor

  3. H- Bridge

  4. Simple DC-motor control program • int main(void){ • InitHardware(); • // ----------- PWM setting -------------// • ICR3 = 40000u; // input capture registor --> pulse cycle every 40 milli seconds • TCNT3 = 0; // interupt flag registor • // Set the WGM mode & prescalar for oscillating timer ( TCCR3A & TCCR3B : Timer control registors) • TCCR3A = ( 1 << WGM31 ) | ( 0 << WGM30 ) | ( 1 << COM3A1 ) | ( 1 << COM3B1 ) | ( 1 << COM3C1 ); • TCCR3B = ( 1 << WGM33 ) | ( 1 << WGM32 ) | TIMER3_CLOCK_SEL_DIV_8; • DDRE |= (( 1 << 3 ) | ( 1 << 4 ) | ( 1 << 5 )); // I/O control registor (PWM pins as outputs) • MC_HI(STANBY); MC_LO(LEFT0); MC_LO(LEFT1); MC_LO(RIGHT0); MC_LO(RIGHT1); • int speed = 1000; • int delay = 100; • while (1){ • MC_LO(LEFT0);MC_HI(LEFT1); • OCR3A = speed; • ms_spin(delay); • MC_HI(LEFT0);MC_LOW(LEFT1); • speed += 1000; • if (speed > 40000){ • speed = 1000; • } • } • }

  5. Analog to Digital (ADC, A/D or A to D) • Converting a continuous quantity to a discrete time digital representation • 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. • The reverse operation is performed by a digital-to-analog converter (DAC).

  6. Resolution • The number of discrete values it can produce over the range of analog values. • Usually stored electronically in binary form • The numberof discrete values available, or "levels", is a power of two. (ex) 8bits  Range from 0 to 255 • where n is the ADC's resolution in bits V ref-High - V ref-Low Resolution = 2n

  7. ADC in ATMega128 (1) • ATMega128 ADC has 10 bits resolution • What is the range? • Has 8 channels through a multiplexer • 8 pins on PORTF • Need to set PORTF as input without pull-up • How to set this 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

  8. ADC in ATMega128 (2) • Can be configured in several different ways • Single-ended� mode : the analog voltages presented on the ADC channels are compared to ground. • There are several selectable voltage references, which determine the range of the ADC conversion. (ex) AVCC • Free-running mode (update continuously) or only one conversion.

  9. Standard Unit of measurement for Electrical current, voltage, and resistance • Interrelation among voltage, current, and resistance E = IR , I = E / R , or R = E / I

  10. Voltage Divider I = E / R 10 mA = 5 V / 500 Ω 0V drop = 10 mA x 0 Ω 5 V R1 = 100 Ω + 4 V 1V drop = 10 mA x 100 Ω 5 V - R2 = 400 Ω 0 V 4V drop = 10 mA x 400 Ω First calculate current ( I ) by using E / R (5 / 500 = 0.01) Then calculate voltage drop at each point based on Ohm’s Law E = I x R (R1 = 0.01 * 100 , R2 = 0.01 * 400)

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

  12. Connecting Sensors

  13. A2D function 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

  14. Send A2D values through UART • Config.h • Set : #define CFG_USE_UART0 1 • Hardware.h • Set : #define UART0_BAUD_RATE 57600 • 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

  15. Connection configuration for UART • 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 : 57600

More Related