distance. There is a graph that will give you the representation.
If you don't want to do that, get a ruler, object and you meter and
start plotting voltage values for different distances. It is not
going to be linear (or at least doesnt appear to be by the
datasheet). Once you have these values, you can convert volts to the
A2D conversion value by the following formula:
For oA2D:
A2D.Value = 255 * Vo / Vref
For oA2D10:
A2D10.Value = 1023 * Vo / Vref
Vo = Output voltage from sensor
Vref = reference voltage (maximum)
The reference voltage will be 5V unless you are connecting a
different voltage (through a divider or something) to Line 4 and
setting OOPic.ExtVRef = cvTrue. If you are to use an external
reference voltage, I believe that it has to be at least 2.5V and not
more than 5V. (Actually, never connect more than 5V to any Pin on
the pic)
Now, your program can take a value from the A2D and calculate the
distance based on that.
-Bill
--- In oopic@yahoogroups.com, "Mike Martin" <xaviour2me@...> wrote:
>
> Woo Hoo! I've got volts that go up and down! (Thanks Bill). So how
do
> I calibrate it and translate volts into something meaningful though
> the OOPic?
>
> --- In oopic@yahoogroups.com, "tinslwc" <tinslwc@> wrote:
> >
> > Mike,
> > I have used a GP2D15 (a digital output for specific distance) but
> the
> > datasheet that I have has the 12 and 15. Looking on the top of
> the
> > sensor, pins facing toward you, sensor facing away from you, the
> pins
> > are Vo, Gnd, Vcc. If you have a multimeter, you can connect +5
to
> > Vcc, Ground to Ground and read the output (Vo) with you meter
with
> > respect to ground. You should see approximatly 2.5V with an
object
> > about 10 cm away from the sensor and as you move the object away,
> the
> > voltage shoud decay. According to my data sheet (and IR
knowledge)
> > you need to have a reflective object in order to get the sensor
to
> > work. A white sheet of paper should work fine. There does
appear
> to
> > be some ripple in the output waveform. A small capacitor from
the
> > signal line to ground should clean this up. I would recommend
> > something on the order of ~0.01uF. Use a ceramic cap, not
> > electrolytic. If you would like the schematic/picture of what I
> > used, let me know and I will get one to you. Again, I was using
> the
> > 15, not the 12 but the pinouts are the same.
> > -Bill
> > --- In oopic@yahoogroups.com, "Mike Martin" <xaviour2me@> wrote:
> > >
> > > Hello All (newbie question)
> > > I'd like to ask two things.
> > > 1)Is the diagram on http://www.oopic.com/gp2d12.htm wrong? The
> > > datasheet in the sensors & detectors folder in the files
section
> > have
> > > the pinout different to that on the oopic site (as well as the
> > wiring
> > > colours). If I look at mine face-on, from left to right the
> wiring
> > is
> > > yellow/black/red for Vo/GND/Voc but the website suggests
> > GND/Voc/Vc.
> > > So you see, I'm having trouble figuring out if it even works.
> > > 2)Also, does someone have a code snippet (or a known working
> > diagram)
> > > I could borrow to test it? I'm not entirely sure what to read
> from
> > > the IO line. What does IR.Value produce? So far all I can get
out
> > of
> > > it is an integer value of 46. I'm using B.1.0 firmware. How can
a
> > > digital IOline read fluctuating voltages? Is it converted to
> > varying
> > > pulses? The code I'm using is below:
> > >
> > > 'Turns on a RED LED - fishing for a value out of the IR
> > > Sub main()
> > > Red.IOLine = 1
> > > IR.IOLine = 3
> > > Red.Value = 0
> > > ooPIC.ExtVRef=0
> > > IR.Operate=cvTrue
> > > X = IR.Value
> > > If X = 46 Then 'discovered this value by trial and error
> > > Red.TurnOn
> > > End If
> > > Delay = 1000
> > > Red.TurnOff
> > > End Sub
> > >
> >
>
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/oopic/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/oopic/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:oopic-digest@yahoogroups.com
mailto:oopic-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
oopic-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
No comments:
Post a Comment