Shop OBEX P1 Docs P2 Docs Learn Events
rcTime with the javelin and AD592 temp sensor — Parallax Forums

rcTime with the javelin and AD592 temp sensor

JamesJames Posts: 15
edited 2006-10-02 21:07 in General Discussion
I have this program running

import stamp.core.*;

public class Temperature {
· static int dischargeTime;
· static int chargeTime;
public static void main() {
while(true){
· CPU.writePin(CPU.pins[noparse][[/noparse]8],false);
· CPU.delay(10);
· dischargeTime = CPU.rcTime(32767,CPU.pins[noparse][[/noparse]8],true);
· System.out.println("RC rise time is: ");
· System.out.println(String.valueOf(dischargeTime));
· CPU.delay(10000);
· }
}
}

with an output of:
RC rise time is:
222
RC rise time is:
222
RC rise time is:
221.....

now i am lost a to what this number means interms of temperature and how to convert and calibrate the temperature sensor program wise, i have looked at the documentation and the applied sesnors chapter on this issue, but i see no examples with the javelin stamp. i'm not exactly the greatest in interpreting the bsaic stamp code to javelin code. so if you have any code examples you could share using this device to set it up right, it would be much appreciated since this is one step of many for my project i'm constructing.

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-09-29 07:34
    Try the attachement.
    I calculated the constant for C=0.1uF
    No fractions are calculated for the temperature so resolution is 1 degree celsius or 1 kelvin.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-09-29 18:19
    I created a seperate class for the AD592.
    It is stored in lib/stamp/peripheral/sensor/temperature/AD592 folder

    This class limits the resolution to 0.1 Kelvin units to prevent overflow
    and to have a large celsius range (-273.2 to +3003.5)

    regards peter

    Post Edited (Peter Verkaik) : 9/29/2006 10:19:48 PM GMT
  • JamesJames Posts: 15
    edited 2006-10-02 17:00
    thanx for all your help now with the last 3 classes and running them i am having issues with an error reading as if the AD592.java is not being found in the right drectory even though it is in the right dorectory, i have double checked that. but the High res version of temperature works to run yet with my test values there is something askew with the read out.

    I measured at a measured 108.3 Farenheit:

    RCTIME = 208
    kelvin = 138.47
    celcius = - 135.47

    with those values calculating the constant reaches me to a value of 65601.12 which is larger than an integer type. an assumably this value goes in place of the 15300. is there something i'm missing to get the value to read atleast to the correct degree not 180 degrees celcius off.

    also if this means anything the vDD is 4.98 and Vcap is 4.08 and its the .22uF rated.

    Post Edited (James) : 10/2/2006 5:13:59 PM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-10-02 17:28
    For the temperatureAD592_highres.java class:
    The calculation for the constant is based on a 0.1uF capacitor.
    If you use a 0.22uF capacitor then RCTIME would be (0.22/0.1)*105 = 231
    which is close to your 208. Use a 0.1uF capacitor, not a 0.22uF as in the pbasic
    examples.

    For the AD592.java class:
    Since 0.1uF gives a resolution step of +-2.5 kelvin, I recalculated the constant
    for a 2.2uF capacitor. This gives a resolution step of +-0.12 kelvin. (at 273.2K)

    The AD592 classes must be stored in a folder AD592 in
    folder <installpath>\lib\stamp\peripheral\sensor\temperature
    where installpath is your ide·installation path
    (default that is c:\program files\parallax inc\javelin stamp ide\)
    Note that case is important! Use small and capital letters as above.

    I attached a highres version for use with a 0.22uF capacitor.

    regards peter


    Post Edited (Peter Verkaik) : 10/2/2006 6:05:05 PM GMT
  • JamesJames Posts: 15
    edited 2006-10-02 21:07
    great thanx so much for allowing me to pic your brain.
Sign In or Register to comment.