Shop OBEX P1 Docs P2 Docs Learn Events
RCTIME Accuracy — Parallax Forums

RCTIME Accuracy

Anthony240Anthony240 Posts: 24
edited 2006-03-13 17:12 in BASIC Stamp
All,
·
As some of you know, I have been working on my senior project, which is a fish tank monitor.· I have·constructed a circuit and some BS2 code, which will measure the salinity of the water in my fish tank.· The problem I'm having is that it needs to be more accurate.· If you read through the code and follow the math you can see that a very small change in the RCTIME number results in a big change in my salinity value of PPT.· For example:
If the RCTIME "result" is 4000 the salinity "ppt" is equal to 3213 which is displayed as 32.13 ppt.
If the RCTIME "result" is 5000, a change of one, the salinity "ppt" is equal to 2506 which is displayed as 25.06.·
As you can see in the above examples my RCTIME value only changed from 4 to 5 and because I multiply it by 1000 it changes from 4000 to 5000.· This is only a change of 1 in RCTIME but changes the ppt value by 7ppt, which is a great amount.
If anyone had any ideas how I could change the code to have smaller changes in salinity, "ppt"·I would appreciate it.
·
Thanks
Anthony

Comments

  • Anthony240Anthony240 Posts: 24
    edited 2006-03-13 15:06
    The above attachemnt doesn't seam to open.

    Here is the code:

    result VAR Word 'Word to hold RCTIME result
    resistor VAR Word 'Word to hold the resistor value
    conductance VAR Word 'Word to hold the conductance value
    ppt VAR Word 'Word to hold the ppt (PSU) Value

    DO
    Main:
    HIGH 7 'Discharge the cap
    PAUSE 1 'Pause for .1 sec
    RCTIME 7, 1, result 'Measure RC charge time
    result = result - 94 'Offset for the 2k resistor in series with the probe
    result=(result*1000) 'Multiply result of RCTIME by 1000
    resistor = (result*/4) 'RC=600*R*C -- R=RC*.0167 -- .0167*256=4
    conductance=(1000/resistor)*/$0350 'G=1/R Multiply by 3.3125 offset to get correct reading
    ppt=conductance*100*/165 'ppt=G*.6427 -- .6427*256=165
    DEBUG DEC result, TAB, DEC1 resistor/1000, ".", DEC3 resistor, " Kohm",
    TAB, DEC resistor, " ohm", TAB, DEC conductance, " mS/cm",
    TAB, DEC2 ppt/100, ".", DEC2 ppt, " ppt", CR
    PAUSE 2000 'Pause for 2sec
    LOOP
  • Russ MillerRuss Miller Posts: 25
    edited 2006-03-13 15:26
    Anthony, You can get better resolution by increasing the RC time constant. For example, if the capacitor in the circuit is increased by 10x then you should get readings between 40 and 50 for the same conductivity condition. Maybe you can increase the RC constant by 100x and get readings between 400 and 500. If you continue to increase the time constant you will eventually exceed the maximum measurement time of the RCTIME command when the conductivity is low.

    Another alternative is to use the sensor as part of an oscillator circuit, perhaps using a 555 timer, and then use the count command to measure the freuency. I'd try the RC constant change first since you've already got that set up.

    Russ
  • Anthony240Anthony240 Posts: 24
    edited 2006-03-13 16:26
    Why do I see the RCTIME command sometimes written with a 1 as the middle number and other time written with a 1000 as the middle number? What does this change? I thought that the middle number had to be a 1 or 0?

    Examples:
    RCTIME 7, 1, Result
    RCTIME 7, 1000, Result
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-03-13 17:12
    Anthony -

    I have a suspicion you may be confusing the RCTIME and PULSIN commands. Take a look in the PBASIC Manual or the PBASIC Help File, to check.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
Sign In or Register to comment.