View previous topic :: View next topic |
Author |
Message |
Creative45
Joined: 26 Mar 2016 Posts: 2
|
Analog Read |
Posted: Sat Mar 26, 2016 12:11 pm |
|
|
Hi,
I use pic 16f877a. I use QTR8a sensors. How to read analog data ?
https://www.pololu.com/product/960
For example,
If AN0 port active, portb4 high.
Another example, one by one read analog data.
Please help me.
I'm project line follower. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19561
|
|
Posted: Sat Mar 26, 2016 1:58 pm |
|
|
Just start by looking in the forum.
For instance PCM_programmer's little example here:
<http://www.ccsinfo.com/forum/viewtopic.php?t=41624&highlight=readadc>
You _are_ using CCS?. The manual and the examples show how to do this.
Be aware of the hardware limitations of your chip. Only certain combinations of ADC channels can be used. Later chips are much more flexible in this.
You are going to need buffer amplifiers. The PIC ADC requires quite a low input impedance. Photo detectors do not directly give this. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9253 Location: Greensville,Ontario
|
|
Posted: Sat Mar 26, 2016 5:53 pm |
|
|
Also be sure you use a real GOOD power supply ! That strip draws 100ma according to the datasheet so battery power may not be an option depending on your application,certainly not AA cells !!
details...it's always in the details.
and
the 877 is nearly extinct. There are newer ,better,cheaper PICs, pin compatible you should be looking at if possible.
Jay |
|
|
Creative45
Joined: 26 Mar 2016 Posts: 2
|
|
Posted: Sun Mar 27, 2016 3:48 am |
|
|
Thank you for your answers. My connections and the battery is the right choice. AN0,AN1,AN2 analog ports one by one I want to read the information.
I'm project line follower.
For example:
If AN0 active, pinb4 high
if AN1 active, pinb3 high
one by one read sensors. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19561
|
|
Posted: Sun Mar 27, 2016 5:20 am |
|
|
On reading multiple ADC's, a 1 second search here would find lots of examples. For instance, look at the final code here:
<http://www.ccsinfo.com/forum/viewtopic.php?t=54494&highlight=adc+multiple+channels>
The signals are not going to be 'active'. They return a number corresponding to voltage. You need to make a decision what level you consider to be 'active'.
Have you read my comment about buffering. The PIC ADC requires a lower impedance than your sensor will provide. You need something like a voltage follower op-amp between the sensor and each adc input. |
|
|
|