|
|
View previous topic :: View next topic |
Author |
Message |
logicchild
Joined: 16 Nov 2013 Posts: 14
|
|
Posted: Sun Nov 17, 2013 2:51 pm |
|
|
Hi,
I'm currently using this schema, also I will use its analog value.
In PIC,
I made the port A as analog, and I tested it and it works, I don't want the converted digital value, I just want 0 or +V, so I've connected a LED in PORTB pin0, and reading from AN2, and then checking if the value is zero it will turn off the LED, otherwise turn it on,
That's all I want.
Thanks for everyone |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Mon Nov 18, 2013 1:08 am |
|
|
Some comments:
1) The value will almost certainly need to be tested for being close to zero, rather than zero itself. A transistor pulling down, is not a perfect short, and the ADC, will see noise both on the signal and on it's Vref. So your test wants to be something like if the count (assuming you use the 8bit mode), is <20.
2) Why waste so much work?. What you want is simply detection of a voltage being above or below a threshold. Using the ADC, is a 'sledgehammer/nut' solution. The chip you are using, has a comparator. This is exactly the sort of job this is designed to do. Giving you a simple 1/0 output, when an input voltage is above/below a programmed threshold. Right tool for the job. The ADC involves a lot of processor time, and quite bulky code comparatively.
3) Key thing that people are trying to point out to you, is the first rule of debugging. Do things in little bits. Get the sensor working, and returning a voltage that changes as it sees a signal _first_. Only once you have this working, and know what voltages to expect, move on to the code. trying to do it any other way, is just wasting your time.
Best Wishes |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9240 Location: Greensville,Ontario
|
|
Posted: Mon Nov 18, 2013 8:14 am |
|
|
also...
remember that sensor is a 'flag' NOT 'distance' type sensor. It was designed to give a '1' or '0' for 'something there or not'. It cannot be used to say 'something is x inches away from me'.
hth
jay |
|
|
|
|
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
|