CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Analog Read

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Creative45



Joined: 26 Mar 2016
Posts: 2

View user's profile Send private message

Analog Read
PostPosted: Sat Mar 26, 2016 12:11 pm     Reply with quote

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: 19520

View user's profile Send private message

PostPosted: Sat Mar 26, 2016 1:58 pm     Reply with quote

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: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Mar 26, 2016 5:53 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Mar 27, 2016 3:48 am     Reply with quote

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: 19520

View user's profile Send private message

PostPosted: Sun Mar 27, 2016 5:20 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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