background image

   Example Code

 Coded for the CCS PCM C-Compiler and used in the PIC16F877 

//////////////////////////////////////////////////////////////////////////////////////////////////////
////

//// 

//// 

AIRSDEM.C for the PIC16F877 

//// 

////

//// 

/// 

Analog Infra-Red Range-finding System (AIRRS) 

//// 

//// 

Demo Program 

//// 

////

//// 

////

HVW Technologies, March 2000 

//// 

 ///    

http://www.HVWTech.com 

//// 

////

//// 

////         Program uses A/D Channel 1 (pin 3) to read the AIRRS 

//// 

////         module output(blue wire). Sends analog value to Matrix

//// 

////          Orbital LCD module on port b5 (pin 38) at 19200 baud.

//// 

////

//// 

////

          Coded for the CCS PCM C-Compiler 

//// 

////

////

///////////////////////////////////////////////////////////////////////////////////////////////////// 
#include <1 6 F877.h> 

//Include Standard CCS header file 

#fuses xt,nowdt,noprotect 

//Configuration bits specific to demo board used 

#use delay(clock=4000000) 

//Oscillator = 4 MHZ 

#use rs232(baud=19200, xmit=pin_b5, rcv=pin_b4,invert) 

//Remove 'invert' option if using MAX232 or similar 
//When communicating to the Matrix Orbital LCD

long value; 

//Define variable Long integer 

Main() 
{
setup_ADC_ports(ALL_Analog); 

//Setup all analog pins as only analog 

setup_ADC(ADC_CLOCK_INTERNAL);  //Configure D converter to use internal oscillator 
set_ADC_CHANNEL(1); 

//Set pin_A1 to measure analog voltage 

While(TRUE) 


delay_ms(500);  

//Pause for 0.5 seconds for LCD to update 

value=READ_ADC(); 

//Take analog and wait for conversion 

putc(0xfe); 

//Command Prefix

putc('X'); 

//Clear Screen Command 

printf("Analog= %Lu",value); 

//Formatted printing of Analog result 

}

   Technical Support

Technical support is available if you are having problems. If you need help, 
please provide as much detailed information as possible. 

Phone: (403) 730-8603  (Monday - Friday 9am – 5pm Mountain time) 

E-mail: [email protected]

Содержание GP2Y0A02YK0F

Страница 1: ...A02YK0F Sensor Analog Infra Red Ranging Sensor The GP2Y0A02YK0F is a well proven robust sensor that uses angle of reflection to measure distances It s not fooled by bright light or different coloured targets Simple to use analog 0 to 2 5V output Small 4 5 x 2 2 x 1 9 cm Connects directly to any microcontroller with A D 20 cm to 150 cm 8 to 79 range ...

Страница 2: ...graph at the end of this document but is no wider than 5 cm 2 5 cm either side of centre when measuring at the maximum range Connecting to the AIRRS A custom cable assembly is included with the AIRRS kit The miniature connector is keyed so that it may only be inserted one way The following table shows the necessary connections Table 1 GP2Y0A02YK0F Pinout Pin Symbol Wire Colour Connect To 1 Vcc Red...

Страница 3: ...034 15 2 797 2 852 2 840 2 830 20 2 590 2 634 2 606 2 610 25 2 327 2 372 2 350 2 350 30 2 036 2 087 2 067 2 063 35 1 777 1 831 1 810 1 806 40 1 555 1 607 1 587 1 583 45 1 384 1 442 1 406 1 411 50 1 253 1 292 1 274 1 273 55 1 118 1 179 1 164 1 154 60 1 024 1 081 1 047 1 051 65 0 952 1 005 0 971 0 976 70 0 876 0 932 0 902 0 903 75 0 822 0 868 0 847 0 846 80 0 752 0 799 0 789 0 780 85 0 687 0 761 0 7...

Страница 4: ... 0 0 5 1 0 1 5 2 0 2 5 3 0 0 20 40 60 80 100 120 140 160 180 200 Distance cm Sensor Output Voltage GP2Y AVG y 57 653x 0 9891 0 0 0 5 1 0 1 5 2 0 2 5 3 0 3 5 4 0 4 5 0 20 40 60 80 100 120 140 160 180 200 Distance cm Sensor Output Voltage GP2Y AVG Power GP2Y AVG www solarbotics com 4 AIRRS Manual v1 7 ...

Страница 5: ... controls have shown that even with 2 or 3 remotes pointed at the GP2Y the unit still functions normally Laser Light Tests with a laser pointer had results similar to the flashlight only a beam aimed straight into the sensor s receiver would cause a false reading If the beam comes from even a few degrees off center it has no effect How Does it Work Figure 1 shows how the GP2Y uses an array of phot...

Страница 6: ...he PSD as a resistor with a large number of taps wires coming out at various points along the resistor When light hits the PSD it hits one of the taps and causes current to flow out each end of the resistor forming a voltage divider As an object moves closer or farther from the sensor incoming light hits a different tap causing the current coming out each end of the resistor to change These curren...

Страница 7: ...b4 invert Remove invert option if using MAX232 or similar When communicating to the Matrix Orbital LCD long value Define variable Long integer Main setup_ADC_ports ALL_Analog Setup all analog pins as only analog setup_ADC ADC_CLOCK_INTERNAL Configure D converter to use internal oscillator set_ADC_CHANNEL 1 Set pin_A1 to measure analog voltage While TRUE delay_ms 500 Pause for 0 5 seconds for LCD t...

Страница 8: ...trollers FPGA Development Kits IR Sensors Robotics Kits Part Compilers Instructional Books PIC Programmers Gifts Toys Proto Boards Tools and test equipment Plus Proven and very reliable object sensor Simple 5V Connection Analog signal easily processed by any microcontroller s A2D pin Solarbotics Ltd Calgary Alberta T2E 6M6 Canada 3740D 11A Street NE Suite 101 Toll Free 1 866 276 2687 International...

Отзывы: