Sensing Algorithm using IR Sensor and ADC Soong-sil University. Robotics. 2007. 05. 02. 13 기 정 두 원.

Slides:



Advertisements
Similar presentations
Analog to digital converter
Advertisements

Jordan Barry Victor Brzeski
Mark Neil - Microprocessor Course 1 Device Drivers – Digital Voltmeter.
Programmable Interval Timer
Digital Thermostat and Data Logger Brandon Wagner and David Southwick.
Sistemi Elettronici Programmabili13-1 MULTI OSC + CLOCK FILTER LVD POWER SUPPLY CONTROL 8 BIT CORE ALU PROGRAM MEMORY RAM I2CI2C PORT A SPI PORT B 16-BIT.
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.
Analog to Digital Converter
Lecture 12 Analog to Digital Converters. 2  What is an ADC?  Output vs. input  Input range  Single-ended vs. differential inputs  Output coding:
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.
Kuliah Mikrokontroler AVR ADC AVR Eru©September 2009 PENS.
Microprocessor based Design for Biomedical Applications MBE 3 – MDBA IV : The ATmega8 Basic Features (3)
Data acquisition and manipulation
1 Analog-to-Digital Converter (ADC). 2 ADC Features (1/3) ADC conversion rate 1 MHz and 12-bit resolution – 1µs conversion time at 56 MHz – 1.17µs conversion.
Analog to Digital Converters (ADC)
SPI on the ATmega SS’ line only used in Slave mode SPDR
Railway Foundation Electronic, Electrical and Processor Engineering.
Railway Foundation Electronic, Electrical and Processor Engineering.
Engineering 4862 Microprocessors Lecture 26 Cheng Li EN-4012
Robotics Research Laboratory Louisiana State University.
1.  8051 Timers “count up,” incrementing the Timer’s respective “count register” each time there is a triggering clock pulse. 2  When the “count register”
DATA ACQUISITION Today’s Topics Define DAQ and DAQ systems Signals (digital and analogue types) Transducers Signal Conditioning - Importance of grounding.
ADC & DAC Signal Conversions.
1 4-Integrating Peripherals in Embedded Systems. 2 Introduction Single-purpose processors  Performs specific computation task  Custom single-purpose.
Unit 10.2 Timer Examples. Example – Music Generation Channel 6 – Set up as a timer Output to Generate Square Waves Channel 4 – Set up as a timer Output.
Embedded System Design Laboratory October 11, 2002Stanford University - EE281 Lecture #4#1 Lecture #4 Outline Announcements Project Proposal AVR Processor.
Digital to Analogue Converter
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
SIGMA-DELTA ADC SD16_A Sigma-Delta ADC Shruthi Sujendra.
1 Lab 5: Controls and feedback. 2 Lab 5: Control and Feedback This embedded system uses the Photo sensor to detect the light intensity of the environment.
Robotics Research Laboratory Louisiana State University.
Advanced uC Session Speaker : Chiraag Juvekar Jan 13, 2011 Speaker : Chiraag Juvekar Jan 13, 2011.
Robotics Research Laboratory Louisiana State University.
Data Acquisition ET 228 Chapter 15 Subjects Covered Analog to Digital Converter Characteristics Integrating ADCs Successive Approximation ADCs Flash ADCs.
Suleyman Demirel University CSS340 Microprocessor Systems – Lecture 2 ATMEGA328P ARCHITECTURE ANALOG INPUTS.
The Silicon Laboratories C8051F020
Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 4 Standard Single Purpose Processors: Peripherals.
By James Cockrell and Justin Loveless
Analog to Digital Converter (ADC). Analog to Digital Converters  Microcontroller understands only digital language.  To convert the analog output from.
Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN.
Lab 3: ADC.
Arduino Mega Arduino Mega 2560 Arduino Mega 2560.
Analog to Digital Converter (ADC)
Embedded Systems Design 1 Lecture Set C Interfacing the MCS-51 to: –D/A Converter –A/D Converter.
Analog to Digital Conversion - ADC Mark Neil - Microprocessor Course 1 Device Drivers – Measuring Voltages.
Chapter Microcontroller
2/June/2009LHCb Upgrade1 Single ended ADC Differential ADC –Convert single ended signal to differential (use AD8138 amp) –ASIC differential output ADC.
0808/0809 ADC. Block Diagram ADC ADC0808/ADC Bit μP Compatible A/D Converters with 8-Channel Multiplexer The 8-bit A/D converter uses successive.
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),
One more PIC18F252 example and revision for exam B222L Branislav Vuksanovic, UoP, ECE.
By: Shivanshi pandya(30) Ayushi chourasia (3) Pranavi chhikniwala(6)
1 4-Integrating Peripherals in Embedded Systems. 2 Introduction Single-purpose processors  Performs specific computation task  Custom single-purpose.
Application Case Study Christmas Lights Controller
Servos Elementary Robotics with Servos
Application Case Study Security Camera Controller
Chapter 12: Analog-to-Digital Converter
Analog Comparator An analog comparator is available on pins PE2(AIN0), PE3(AIN1) The comparator operates like any other comparator. -when (+) exceeds (-)
ADC,DAC and sensor interface
4-Integrating Peripherals in Embedded Systems
4-Integrating Peripherals in Embedded Systems
ADC and DAC Programming in AVR
ADC and DAC Data Converter
MSP432™ MCUs Training Part 6: Analog Peripherals
Device Drivers – Digital Voltmeter
ADC and DAC Data Converter
PIC Microcontroller ADC interfacing Prof. Ashvini Kulkarni
Presentation transcript:

Sensing Algorithm using IR Sensor and ADC Soong-sil University. Robotics 기 정 두 원.

Index Infrared Sensor 1 Design Sensor Circuits 2 ADC with the Atmega128 3 Sensing Algorithm 4

Infrared Sensor 적외선 ? 파장이 가시광선 보다 길고 전파보다 짧은 전자파 일종 일정 주파수의 빛을 발산 및 받아들이는 소자.( 발광, 수광 ) 발광부에서 나온 적외선이 물체에 반사되어 수광부에 얼마나 많은 양 이 들어오느냐에 따라서 수광부에 들어오는 전압의 양이 변화. ( 색에 따라 빛의 반사 정도 다름 ) 수광소자는 빛 에너지를 전기 에너지로 바꿔주는 역할. 발광수광

Infrared Sensor Photo Diode. – 접합용량이 작으므로 읍답특성이 좋음. – 역바이스를 걸면 응답특성이 향상. – 출력 신호가 매우 낮음. Photo Transistor. –TR 의 베이스에 포토 다이오드 부착 한 형태 – 온도 보상에는 베이스가 부착된 포토 TR 사용. – 베이스가 부착된 포토 TR 은 광전류의 직진성을 개선. – 출력 전류가 크다.

Infrared Sensor IR Sensor formation. In phase with input signal High ouput power signal Out of pahse with input signal Low output power signal

Sensor Circuits Always give and take the signals. Simple Circuit design. Apply a low electric current. Intensity of light is relative to a current.

Sensor Circuits High-Pass Filter Voltage 비교용 조절을 통해 출력을 High,Low 조절 비교방식의 회로 디자인

Sensor Circuits 광량식 방식의 회로 디자인

Features of the AD system for the or 10-bit resolution 8 bit => 2 8 = 256 output states, so resolution of V FSR /2 8 = 1 part in 256 of V FSR (V REF ) 10 bit => 2 10 = 1024 output states, so resolution of V FSR /2 10 = 1 part in 1024 of (V REF ) 8 channel MUX => 8 single-ended (i.e. referenced to GND) voltage inputs on PORTF 16 combinations of differential inputs –Two (ADC1, ADC0 and ADC3, ADC2) have a programmable gain stage with 1X, 10X, or 200X gain selectable 1X or 10X can expect 8 bit resolution 200X 7-bit resolution –Seven differential channels share ADC1 as the common negative terminal (ADC0-ADC1) Input voltage range is 0 V – V CC V REF can be internal (either 2.56 V or AVCC) or externally supplied Interrupt on ADC conversion complete

Procedure to Initialize ADC Set up ADCSRA and ADMUX: 1. Turn on the ADC (ADEN=1) 2. Choose single-conversion or free-run (ADFR=0 means single conversion) 3. Clock prescaler (selects system clock divider. Smaller divider => faster but less accurate conversion 4. Choose the voltage reference by selecting proper bits, in location 7 and 6 of ADMUX 5. Choose left or right adjustment of result (in ADMUX register, ADLAR=0 for right adjust) 6. Choose the AD channel to convert (in ADMUX, MUX bits)

Procedure to Do a Conversion 1. Start a conversion by writing a 1 to ADC Status and Control Register, bit 6 (ADSC) 2. Wait until conversion is complete a. Can monitor bit 6 (ADSC). It will stay as 1 until conversion completes, or b. Generate an interrupt Bit 4 (ADIF) of ADSC will be set when the conversion is complete To use interrupts must: o Set bit 3 (ADIE) of ADCSRA and o Enable global interrupts: o Define an interrupt handling routine. o Make sure to #include

Procedure to Do a Conversion 3. Read data from ADC Data register: ADCL first, then ADCH (if 10 bit desired) a. Note that access to the ADC data register is blocked until both ADCL and ADCH are read. Once ADCH is read, the ADC data register can be updated. b. ADLAR=0 (right shifted) c. ADLAR=1 (left-shifted)

ADC Code Example #define Counter_Max // 16bit Overflow spot #define Period_1ms_count 16 // 1.02ms(1024us) #define pulse 3 // 0.19ms( 192us) #pragma vector = TIMER3_OVF_vect __interrupt void TIMER3_OVR_interrupt(void){ static unsigned char counter_flag = 1 ; static unsigned char counter = 0; if(counter_flag) { TCNT3H = (unsigned char)(((Counter_Max - pulse) >> 8 ) & 0x00FF); TCNT3L = (unsigned char)((Counter_Max - pulse) & 0x00FF); if(++counter>7) counter=0; PORTA=(1<<counter); counter_flag=0; } else { TCNT3H = (unsigned char)(((Counter_Max - (Period_1ms_count - pulse)) >> 8 ) & 0x00FF); TCNT3L = (unsigned char)((Counter_Max - (Period_1ms_count - pulse)) & 0x00FF); PORTA = 0x00; ADMUX = 0x20 + counter; ADCSR |= 0x40; // ADC start conversion counter_flag=1; } #pragma vector=ADC_vect __interrupt void ADC_conversion_done(void) { unsigned char temp; temp=ADCL; temp=ADCH; Sensor_ADC_result[ADMUX-0x20] = temp; }

Sensing Algorithm 비교식 – 위치 값 정확. 노이즈에 강하다. – 처리 데이터 수가 적어서, 계산량이 적다. – 하드웨어적인 방법과 소프트 웨어적인 방법 ( 회로에서 H,L 값을 입력 받 는 방법, ADC 에 변환된 값을 코딩을 통해 H,L 판단하는 방법 ) – 자유 곡률에서 부드러운 주행 힘듦. 광량식 – 데이터가 세밀하고 양이 많아 계산량이 많음. – 정밀한 제어가 가능. – 자유곡률에서 부드러운 주행 가능.

Sensing Algorithm - 비교식 ON-OFF 방식 1 – 회로에서 ON-OFF 방식으로 출력 –PORT A 를 통해 전체 입력을 받음. 프로그래밍 간단 int Get_Position(void) { int sum_position=0, flag=0; if(PINA0==1){sum_position +=10; flag++;} else if(PINA1==1){sum_position +=20; flag++;} else if(PINA2==1){sum_position +=30; flag++;} …. else if(FINA7==1){sum_position +=80; flag++;} return(sum_position/flag – 45) }

Sensing Algorithm - 정규화 센서값 정규화 – 여러가지 이유로 센서의 최대값과 최소값이 각 센서마다 틀리다. – 검정색판과 흰색 라인 위에서 센서값의 최대, 최소값을 구해 저장 Min Max 정규화 값 (8 비트 ) 센서 값 정규화 된 값 = ( 센서값 -Min)*255/(Max-Min)

Sensing Algorithm – Example Code unsigned char Sensor_ADC_max[8] = {0,0,0,0,0,0,0,0}, Sensor_ADC_threshold[8]; unsigned char Sensor_ADC_min[8] = {255,255,255,255,255,255,255,255}; void Sensor_Get_Min (void) { BYTE i; for(i=0;i<8;i++){ if(Sensor_ADC_result[i] < Sensor_ADC_min[i]){ Sensor_ADC_min[i] = Sensor_ADC_result[i]; } } void Sensor_Get_Max (void) { BYTE i; for(i=0;i<8;i++){ if(Sensor_ADC_result[i] > Sensor_ADC_max[i]){ Sensor_ADC_max[i] = Sensor_ADC_result[i]; } } void Sensor_Get_Threshold(void){ int i=0; for(i=0; i<8;i++) {Sensor_ADC_threshold[i] = (Sensor_ADC_max[i] - Sensor_ADC_min[i])>>3;} }

Sensing Algorithm - 비교식 ON-OFF 방식 2 –ADC 값과 Threshold 값을 가지고 On-Off 판단 – 흰색이면 최대값을 갖을 것이고, 검정색이면 최소값을 갖게 될것. –Threshold 값 보다 크면 흰색 라인, 작으면 검정색으로 인식 int Get_Position(void) { int sum_position=0, flag=0; for(int i=0; i<8 ; i++){ if(Sensor_ADC_result[i] > Sensor_ADC_threshold[i]){ sum_position += Sensor_Importance[i]; flag++; } return(sum_position/flag – 45); }

Sensing Algorithm - 광량식 광량식 – 센서 배치 문제 ( 두개의 센서가 라인의 어느 위치에 있느냐 ) – 짝수개의 수광부 센서 사용 하는 것이 쉽다. – 센서 사이의 값들을 선형적으로 만드는게 중요 – 각 센서에 가중치를 두어 위치파악 최대값 센서값 최소값 X10 X2 X2 X10

Sensing Algorithm – Example Code int Get_Position (void){ int temp_position=0; int i; unsigned char temp_value[6]; for(i=0; i<6;i++) { if (Sensor_ADC_result[i] > Sensor_ADC_max[i]) temp_value[i]=Sensor_ADC_max[i]; else if (Sensor_ADC_result[i] < Sensor_ADC_min[i]) temp_value[i]=Sensor_ADC_min[i]; else temp_value[i] = (Sensor_ADC_result[i] - Sensor_ADC_min[i]); } temp_position -= (temp_value[0]<<7) / Sensor_ADC_threshold[0]; temp_position -= (temp_value[1]<<4) / Sensor_ADC_threshold[1]; temp_position -= (temp_value[2]<<2) / Sensor_ADC_threshold[2]; temp_position += (temp_value[3]<<2) / Sensor_ADC_threshold[3]; temp_position += (temp_value[4]<<4) / Sensor_ADC_threshold[4]; temp_position += (temp_value[5]<<7) / Sensor_ADC_threshold[5]; return(temp_position); }

Sensing Algorithm – 비교식 + 광량식 비교식 + 광량식 –On-Off 로 라인 위에 있는 센서들을 인식 – 실제 라인에 있는 센서들의 ADC 값들만을 가지고 위치 구함 – 유효한 센서의 ADC 값을 계산하므로 계산량이 줄어든다.