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 support@ccsinfo.com

16f877a Related adc float value comparison

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



Joined: 13 Jun 2013
Posts: 5
Location: India

View user's profile Send private message Send e-mail

16f877a Related adc float value comparison
PostPosted: Thu Oct 10, 2013 1:25 am     Reply with quote

Hai brother,

I need clarification for the following case.

when i switch on the setup : Need to read ADC1 ( float value)

Adc1 value keep on vary. I want to compare Intial Adc1 value with the present Adc1 value

How can i do the comparison?

Thank you
temtronic



Joined: 01 Jul 2010
Posts: 9164
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Oct 10, 2013 5:17 am     Reply with quote

One way...
Inside main() read the ADC1 and store the value into a variable called 'initial_ADC1_value.
Then in your 'read and compare' loop(), read the ADC1 and store into a second variable called 'current_ADC1_value'.
Then compare the two variables using an If(.....) statement.

Also...

do NOT use floating point if you expect FAST results ! FP number crunching is very,very slow on PICs.It's far faster to use 'raw' int16 numbers or 'scaled' int16 numbers.


also...
press F11 while your program is open, and you'll get the CCS Help files up! Makes it easy to lookup almost anything code related!!

hth
jay
rdevendrakumar1989



Joined: 13 Jun 2013
Posts: 5
Location: India

View user's profile Send private message Send e-mail

Thank you
PostPosted: Thu Oct 10, 2013 5:50 am     Reply with quote

Thank you for your kind reply.. Definitely i will do...
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