RCTIME Accuracy
Anthony240
Posts: 24
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
·
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
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
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
Examples:
RCTIME 7, 1, Result
RCTIME 7, 1000, Result
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 -->