Shop OBEX P1 Docs P2 Docs Learn Events
Newbie, inverting scaled values — Parallax Forums

Newbie, inverting scaled values

prathbunprathbun Posts: 2
edited 2005-01-04 17:36 in BASIC Stamp
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

Comments

  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-01-04 17:36
    In that case, where Y decreases as X increases, the problem sometimes calls for the inverse, Y = 1/X, although sometimes it might be a linear formula like Y = B - A*X. Which one it is depends on the kind of sensor.

    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
Sign In or Register to comment.