Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to write a formula for PIC16F in C to measure a sensor reading?

Status
Not open for further replies.

handsprince

Member level 2
Joined
Feb 7, 2006
Messages
43
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,583
how to write a formula to measure a sensor reading? for an example i want to measure temperature using LM35DZ ...newbie
 

Re: Reading formula

for PIC MCU 16F series using C language
 

Re: Reading formula

Hi,
You use the formula as follows:

Sensor output in Volts(Vs) = ( N * Vref ÷ Nf) ÷ A

Where N = Current ADC Count
Vref = Vlaue of the reference Voltage in Volts ( 2V, 2.5V , 5V etc.)
Nf = ADC Full scale count (1023 for a 10 bit ADC, 255 for an 8Bit ADC etc.)
A = Amplifier Gain if used, else A = 1

Sensor Output as variable X = Vs÷ K, where K is the Conversion factor V/U(X),
U(X) is the unit of X

For LM35, K = 10 mV/°C = 0.01V/°C

So the current temperature measured Tc = Vs÷0.01 °C
= [( N * Vref ÷ Nf) ÷ A ]÷0.01 °C

Regards,
Laktronics
 
Re: Reading formula

Laktronics , thanks...all the sensor reading can refer to your formula?
 

Reading formula

Looks right to me.

As a sidenote if you can convert the math to integer you won't need a floating point library.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top