* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Slide 1
History of electric power transmission wikipedia , lookup
Current source wikipedia , lookup
Resistive opto-isolator wikipedia , lookup
Stray voltage wikipedia , lookup
Television standards conversion wikipedia , lookup
Immunity-aware programming wikipedia , lookup
Switched-mode power supply wikipedia , lookup
Power MOSFET wikipedia , lookup
Variable-frequency drive wikipedia , lookup
Time-to-digital converter wikipedia , lookup
Voltage optimisation wikipedia , lookup
Power electronics wikipedia , lookup
Buck converter wikipedia , lookup
Alternating current wikipedia , lookup
Integrating ADC wikipedia , lookup
Pulse-width modulation wikipedia , lookup
Mains electricity wikipedia , lookup
Robotics Research Laboratory Louisiana State University DC Motor Controller (TB6612FNG) MOSFET-based H-bridges Metal–Oxide–Semiconductor Field-Effect Transistor 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; } } } 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). The number of discrete values it can produce over the range of analog values. ◦ Usually stored electronically in binary form ◦ The number of discrete values available, or "levels", is a power of two. (ex) 8bits Range from 0 to 255 Resolution = V ref-High - V ref-Low 2n ◦ where n is the ADC's resolution in bits 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 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. Quantity Symbol Unit of measurement Unit of Abbreviation Current I Ampere (“Amp”) A Voltage V or E Volt V Resistance R Ohm Ω E = IR , I = E / R , or R = E / I I= E/R + 5V 0V drop = 10 mA x 0 Ω 4V 1V drop = 10 mA x 100 Ω R1 = 100 Ω 5V - 10 mA = 5 V / 500 Ω R2 = 400 Ω 0V 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=IxR (R1 = 0.01 * 100 , R2 = 0.01 * 400) 5V + S1 = 0 ~ 20000 Ω Connect to ADC 5V - 0V drop = Xi mA x 0 Ω X V drop = Xi mA x S1 Ω R2 = 1000 Ω 0V X v+ restV drop = Xi mA x 1000Ω 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 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__ ) #else #endif u0 = fdevopen( UART0_PutCharStdio, UART0_GetCharStdio ); u0 = fdevopen( UART0_PutCharStdio, UART0_GetCharStdio, 0 ); ◦ Send values using fprintf(u0,”your message %d”, variable); /home/csc2700/csc2700/40-ADC-02 Our programmer has 2 serial port ◦ ttyACM0 : ISP programming port ◦ ttyACM1 : UART serial port Wire connection ◦ PE0 ◦ PE1 ◦ GND Yellow wire Green wire Black wire Open Gtk-term ◦ Set port : /dev/ttyACM1 ◦ Speed : 57600