Newbie, inverting scaled values
prathbun
Posts: 2
Hi all,
Just been playing with the HomeWork Board ("What's a Microcontroller?").
I've been a long time away from BASIC and programming in general, and know just enough about electronics to get me into big trouble....
My goal (ultimately) is to build a (few) weather/data-aquisition station(s) to scatter around a 5,000 plus acre ranch in Eastern Oregon (not mine, sadly, I just live here).
My question is about direct-acting vs. reverse-acting inputs, and how to reverse 'em.
This is the code:
' {$STAMP BS2}
' {$PBASIC 2.5}
time VAR Word
offset VAR Word
DO
HIGH 2 ' charge the cap
PAUSE 1 ' for 1 ms
RCTIME 2, 1, time ' measure RC discharge time
time = ((time */ <something>) + offset)
DEBUG DEC ? time ' display result
LOOP
Here's the circuit:
This code/circuit is reverse-acting (higher temp = lower time).
Is there a quick-and-dirty way to invert that so a higher temp equals a higher RCTIME?
Have I missed something we'll all joke about later?
Thanks in advance!
Pete
Just been playing with the HomeWork Board ("What's a Microcontroller?").
I've been a long time away from BASIC and programming in general, and know just enough about electronics to get me into big trouble....
My goal (ultimately) is to build a (few) weather/data-aquisition station(s) to scatter around a 5,000 plus acre ranch in Eastern Oregon (not mine, sadly, I just live here).
My question is about direct-acting vs. reverse-acting inputs, and how to reverse 'em.
This is the code:
' {$STAMP BS2}
' {$PBASIC 2.5}
time VAR Word
offset VAR Word
DO
HIGH 2 ' charge the cap
PAUSE 1 ' for 1 ms
RCTIME 2, 1, time ' measure RC discharge time
time = ((time */ <something>) + offset)
DEBUG DEC ? time ' display result
LOOP
Here's the circuit:
This code/circuit is reverse-acting (higher temp = lower time).
Is there a quick-and-dirty way to invert that so a higher temp equals a higher RCTIME?
Have I missed something we'll all joke about later?
Thanks in advance!
Pete
Comments
There is info about this kind of calculation for light intensity using RCTIME in the Applied Sensors book available for free download at the Parallax web site. I have some examples on my web site math pages at,
owlogic.com/BS2math2.htm#Reciprocal
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com