|
|
View previous topic :: View next topic |
Author |
Message |
weg22
Joined: 08 Jul 2005 Posts: 91
|
Help with GP2D12.c driver |
Posted: Wed Nov 15, 2006 5:05 pm |
|
|
Hi all,
I previously posted a message on how to read a voltage value with the A/D pin on a PIC18F8722:
http://www.ccsinfo.com/forum/viewtopic.php?t=28884
In the meantime, I came across a driver for the for the IR sensor I am using (different model, but exactly the same output -> 0.5-2.8 volts). I incorporated that into my code and also changed the LEFT_ADC_CHANNEL value to 0, but I'm still not getting the expected value. With a range of 0.5-2.8 volts, I'm expecting digital values from 26-143...but I'm actually seeing around 190-220. If anyone could offer advice, I'd appreciate it. Maybe the ADC just isn't working on my PIC?
Code: |
#include <18F8722.h>
#device adc=8
#include <stdlib.h>
#include <math.h>
#fuses HS,NOWDT,NOPROTECT,PUT,NOLVP
#use delay(clock=10000000)
#use rs232(baud=9600, xmit=PIN_G1, rcv=PIN_G2, stream=PC)
#include <GP2D12.c>
main()
{
int value=0;
init_objectSensors();
while(1)
{
value = read_leftObjectSensor();
fprintf(PC, "%u\r\n", value);
}
} // end of main |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Nov 15, 2006 5:27 pm |
|
|
You didn't have to start a whole new thread. If you add a post to an
existing thread, it will be "bumped" to the top of the list. Everyone will
see it.
Quote: | In the meantime, I came across a driver for the for the IR sensor |
You're referring to this CCS driver:
c:\program files\picc\drivers\gp2d12.c
The CCS driver defaults to using A/D channel 1:
Code: | #define LEFT_ADC_CHANNEL 1 |
But your hardware in your previous thread was setup to use channel 0:
Code: | set_adc_channel(0); |
|
|
|
weg22
Joined: 08 Jul 2005 Posts: 91
|
Re: Help with GP2D12.c driver |
Posted: Wed Nov 15, 2006 7:38 pm |
|
|
weg22 wrote: |
I incorporated that into my code and also changed the LEFT_ADC_CHANNEL value to 0, but I'm still not getting the expected value.
|
I already changed that before posting this thread. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|