PDA

View Full Version : Reading a Temperature



BlueZX#
06-09-2005, 01:04 AM
First post...http://forums.parallax.com/images/smilies/smile.gif

I am using a BS1 w/ a thermister for starters...I am using the therm.bas code trimmed to only the temp formula's...

While I was testing the concept it worked fine and had only a degree off of the actual temp...

So,·I went to the next step and tried it in the actual enviroment setting and with the right settings...

My problem is that this seems to only go down to a logged temp of 50F, not useable... I need to measure like·20F-120F, wide range I know...going by the book is says that you can extend the range as they only made it for 50-90.· So I tried to follow the directions and am a little confused...it says what they
·did but didn't give any samples...·http://forums.parallax.com/images/smilies/confused.gif

I did think of using another type of sensor but have concluded that any other one either uses too many pins or uses too much code (ei..dallas ones)·to read from it...

Help!!!!!· Thanks..

I only have can have two pins for two temp readings and need space for the rest of the program as its not completed yet...

Chris Savage
06-09-2005, 02:40 AM
Hello,

·· Where is this code you're referring to?· Could you attach the original code and perhaps a link to the document that you're referring to?


EDIT: I was informed you're referring to the BASIC Stamp 1 Application notes, so you don't need to send the code or link.· I don't have any code to do what you're trying to do, but you could use a DS1620 with probably no more overhead than what you're going to need for this conversion.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)


Post Edited (Chris Savage (Parallax)) : 6/8/2005 8:07:30 PM GMT

BlueZX#
06-09-2005, 03:41 AM
Ok, I re-looked at this again and form what I am seeing is that I would have to upgrade to a bs2 form the bs1 that im using now....more pins/memory. Cause right now there are just 4 lines of code for the reading & conversion, and only uses one pin....

I also just pulled the req code lines off the app to do this and it takes a lot more to do almost the same thing...just more precise and not dependant·on a RC circuit which will be subject close to the same temps that I will be reading and there for not as stable...http://forums.parallax.com/images/smilies/cry.gif

Any more thoughts...?


Post Edited (BlueZX#) : 6/8/2005 8:46:05 PM GMT

Jon Williams
06-09-2005, 04:03 AM
The trick with using a thermister is that it's terribly non-linaar and it takes a few lines of code to straighten things out. If you do switch to a BS2, then the DS1620 is a really good candidate. With the code space you'll have you could easily use it in high-resolution mode and get 0.05 degrees C resolution.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

BlueZX#
06-09-2005, 05:19 AM
As far as the operating temps for the bs2...all though its not recomended outside of the 0-70c range, what if its not...ie colder...what probs does this bring to light...or should I pos look at the ind version...-40-85c one....

Thanks for the help!

dandreae
06-09-2005, 06:15 AM
I recommend the industrial version of the BASIC Stamp 2 for this project.· As you mentioned· before, the temperature range is well within the industrial BS2 range, therefore less of a chance of failure.



Dave

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Andreae

Tech Support
dandreae@parallax.com (mailto:dandreae@parallax.com)
www.parallax.com (http://www.parallax.com)

·

BlueZX#
06-09-2005, 11:35 AM
Thanks...

I have to order one then, just have to wait for it to be back in stock... I'll also have to check the rest of my code to make sure thats its bs2 complient...

BlueZX#
06-17-2005, 12:31 PM
More on this project....I now have a BS2 and a couple of DS1620 SOIC's. I do have a working code for one sensor and will be reading at least from two of them. My question is, is it possible to connect say the two Clocks and DQ's together in sets. When reading from which ever sensor, all I have to do is bring the RST pin of the desired sensor high and send the communication. Would this have an effect on the other sensor....

Thanks,

Jon Williams
06-17-2005, 10:01 PM
You can share clock and DQ lines -- just put a 1K resistor between the [shared] Stamp pin and each DS1620. The Reset lines must be unique; these will act as your chip selects.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

BlueZX#
06-17-2005, 10:28 PM
Do you mean like this...right?

Jon Williams
06-17-2005, 11:13 PM
No, like this (which prevents conflicts between the Stamp and a DS1620, or the DS1620s with each other):

http://forums.parallax.com/attachment.php?attachmentid=38074


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

BlueZX#
06-17-2005, 11:20 PM
Great...thanks

BlueZX#
06-24-2005, 09:53 PM
I was doing some bench testing and all went great....then set up small rig to do some real eviroment testing and worked fine for awhile (40min) but then the ds1620 stoped working...

what I had when testing was a ds1620,filter cap, power ceramic resistor(heater) on a small bread board inside a small box,in the freezer. The cable was ~8-10ft long...

My question is: what is the point at which you might need some kinda line driver for such a device. I haven't done anything since then so I not sure as to Y it stoped...is that too long of a distance for it to push...

Post Edited (BlueZX#) : 6/24/2005 6:29:18 PM GMT

BlueZX#
09-01-2005, 01:13 AM
BUMP...

Just got back to this project and now have two sensors that don't work now...

I would really like to know what is causing them to stop working after a time of use...

Still using the above setup....

Any comments...TIA

Jon Williams
09-01-2005, 02:32 AM
It's impossible to tell without seeing your code. Please post.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

BlueZX#
09-01-2005, 10:46 PM
Ok, heres the code....

I did notice that I do need to cange the code a little cause the after the temp drops below 32F the formula stops working the way it should, due to the fact that the formula changes the C to F and it doesn't monitor the negitve bit, but not the real issue here..

I have gone as far to just put the origanal DS1620 BS2 script in to see if it was a problem in the project code and that ended up only like giving a temp reading like every 1-2mins....I really think that it something to do with the actuall chip...its the SOIC one..

Thanks,

' {$STAMP BS2}
' {$PBASIC 2.0}
' {$PORT COM1}

'============================ Pin Defenations ==============================

' P0 - DS1620 CLK PIN, CONNECT TO ALL TEMP SENSORS (DONE)
' P1 - DS1620 DQ PIN, CONNECT TO ALL TEMP SENSORS (DONE)

' P2 - DS1620 RST PIN HD TEMP SENSOR (DONE)
' P3 - DS1620 RST PIN CASE TEMP SENSOR (DONE)
' P4 - DS1620 RST PIN AMP TEMP SENSOR (NOT DONE YET!!)
'
' P5 - HD HEATER (DONE)
' P6 - HD EXHUST SERVO (RANGE CW155-C630-CCW1105) (DONE)
' P7 - HD FAN (DONE)
' P8 - CASE FAN (NOT DONE YET!!)
' P9 - POWER SUPPLY FAN (NOT DONE YET!!)
'P10 - AMP FANS (NOT DONE YET!!)
'P11 - SCREEN POWER (NOT DONE YET!!)
'
'
'P12 -
'P13 - BATT STATUS (NOT DONE YET!!)
'P14 - CAR STATUS ON/OFF (NOT DONE YET!!)
'P15 - EMPTY
'
'
'================================== Temperature Varibles ================================
j VAR Byte
i VAR Nib
x VAR Word
remain VAR Word
slope VAR Word
degC VAR Word 'storage for celcius temp
degF Var Word 'storage for fareinehitt temp
TEMP_HD VAR Word 'storage for HD temp
'TEMP_CS VAR Word 'storage for CS temp
RST_SELECT VAR NIB 'hd/case temp select pin
CLKn CON 1 'DS1620 pin
DQn CON 0 'DS1620 pin
Loop Var byte
SERVO_STATUS VAR BIT 'servo status open/close
HTR_STATUS VAR BIT 'heater status on/off
HTR_CTRL CON 4 'heater control pin
SET_TEMP CON 410 'must be 3 digits( ie..95.3 would be 953)
sPin CON 16 'pin for temp logging
Baud CON 84 'Baud mode for a rate of 9600, 8-N-1
HD_SENSOR CON 2
CS_SENSOR CON 3
HD_FAN CON 6
'============================ main program loop =============================

GOSUB startup
'RST_SELECT = CS_SENSOR
'GOSUB CHECK_CONFIG
RST_SELECT = HD_SENSOR
GOSUB CHECK_CONFIG

CHECK_HD_SENSOR:
RST_SELECT = HD_SENSOR
GOSUB CHECK_TEMP
TEMP_HD = degF
'SEROUT sPin,Baud,["DATA,TIME,",DEC TEMP_hd, ",",DEC temp_CS,",",DEC HTR_STATUS,13]
IF TEMP_HD <= 420 THEN ALARM
CHECK_CS_SENSOR:
' RST_SELECT = CS_SENSOR
' GOSUB check_temp
' TEMP_CS = degF
'SEROUT sPin,Baud,["DATA,TIME,",DEC TEMP_hd, ",",DEC temp_CS,",",DEC HTR_STATUS,",",DEC SERVO_STATUS,13]
SEROUT sPin,Baud,["DATA,TIME,",DEC TEMP_hd, ",",DEC HTR_STATUS,",",DEC SERVO_STATUS,13]
CHECK_STATUS:
GOSUB ADJ
' GOSUB BATT_STATUS

GOTO CHECK_HD_SENSOR


'=========================== STARTUP ==================================

STARTUP:
FOR loop = 1 TO 25
PULSOUT 5,630
PAUSE 20
NEXT
LOW HTR_CTRL
TEMP
'RETURN
'========================= FOR LOGGING ONLY ============================

PAUSE 1000 'Allow data communications to stabilize
SEROUT sPin,Baud,[13] 'Send a lone CR to ensure StampDAQ buffer is ready
PAUSE 50
' SEROUT sPin,Baud,[13,"LABEL,TIME,TEMP_HD,TEMP_CS,HTR_STATUS,SERVO_STATUS",13] 'Label 2 columns with TIME, TEMP
SEROUT sPin,Baud,[13,"LABEL,TIME,TEMP_HD,HTR_STATUS,SERVO_STATUS",13]
SEROUT sPin,Baud,["CLEARDATA",13] 'Clear all data columns (A-J) in Excel
RETURN

'==================== CHECKING THE CONFIG OF TEMPERATURE SENSOR ===========

CHECK_CONFIG:
'DEBUG CLS,"CHECKING CONFIG"
'PAUSE 250
'DEBUG CLS,"CHECKING CONFIG."
'PAUSE 250
'DEBUG CLS,"CHECKING CONFIG.."
'PAUSE 250
'DEBUG CLS,"CHECKING CONFIG..."
PAUSE 1500
HIGH RST_SELECT
SHIFTOUT DQn,CLKn,LSBFIRST,[$AC]
SHIFTIN DQn,CLKn,LSBPRE,[x]
LOW RST_SELECT
IF x.BIT0=0 AND X.BIT1=0 THEN CONT
RETURN
CONT:
'DEBUG "CHANGING THE CONFIG..."
PAUSE 1500
HIGH RST_SELECT
SHIFTOUT DQn,CLKn,LSBFIRST,[$C,$3]
LOW RST_SELECT
PAUSE 100
RETURN

'==================== READ TEMPERATURE =====================
CHECK_TEMP: ' start a conversion
HIGH RST_SELECT
SHIFTOUT DQn,CLKn,LSBFIRST,[$EE]
LOW RST_SELECT
busy: ' wait for data to be ready (up to one second!)
HIGH RST_SELECT
SHIFTOUT DQn,CLKn,LSBFIRST,[$AC]
SHIFTIN DQn,CLKn,LSBPRE,[x]
LOW RST_SELECT
IF x.BIT7=0 THEN busy ' x.bit7 goes high when done

HIGH RST_SELECT ' request data byte and get it
SHIFTOUT DQn,CLKn,LSBFIRST,[$AA]
SHIFTIN DQn,CLKn,LSBPRE,[x\9]
LOW RST_SELECT
x.BYTE1 = -x.BIT8 ' extend sign
degC=x*5 ' compute to 10ths, +/- 0.5 degree C

HIGH RST_SELECT ' get the count remaining DS1620
SHIFTOUT DQn,CLKn,LSBFIRST,[$A0]
SHIFTIN DQn,CLKn,LSBPRE,[remain\9]
LOW RST_SELECT

HIGH RST_SELECT ' get the counts per degree
SHIFTOUT DQn,CLKn,LSBFIRST,[$A9]
SHIFTIN DQn,CLKn,LSBPRE,[slope\9]
LOW RST_SELECT

x=slope-remain*100/slope ' compute 1/100ths degree
degC=degC+550/10*100+x-5525 ' adjust temperature to 1/100ths
degF=(degc */ $01CC)+3200 'convert to F degree's
'DEBUG " C ",TAB," F "
'DEBUG CR,dec degC/100,".",DEC2 degC,TAB,dec degF/100,".",dec2 degF
PAUSE 700
degF = degF/10
RETURN

'==================== Adjust heater & venting ===================
ADJ:
IF TEMP_HD <= SET_TEMP AND HTR_STATUS = 0 THEN HTR_ON
IF TEMP_HD >= SET_TEMP AND HTR_STATUS = 1 THEN HTR_OFF
'PAUSE 970 'CHANGE TO 970
' SEROUT sPin,Baud,["DATA,TIME,", DEC TEMP_hd, ",", DEC temp_CS,",", DEC HTR_STATUS,13]
IF TEMP_HD > 656 AND TEMP_HD < 820 AND SERVO_STATUS = 0 THEN EXH_OPEN
IF TEMP_HD < 500 AND SERVO_STATUS = 1 THEN EXH_CLOSE
IF TEMP_HD > 825 AND SERVO_STATUS = 1 THEN EXH_CLOSE

' IF temp_CS < 945 AND SERVO_STATUS = 1 THEN EXH_CLOSE
' IF temp_Cs > 947 AND SERVO_STATUS = 0 THEN EXH_CLOSE
RETURN

HTR_ON:
HIGH HTR_CTRL
HTR_STATUS = 1
GOTO CHECK_HD_SENSOR
HTR_OFF:
LOW HTR_CTRL
HTR_STATUS = 0
GOTO CHECK_HD_SENSOR
EXH_OPEN:
FOR loop = 1 TO 25
PULSOUT 5,315
PAUSE 20
NEXT
SERVO_STATUS= 1
HIGH HD_FAN
GOTO CHECK_HD_SENSOR
EXH_CLOSE:
FOR loop = 1 TO 25
PULSOUT 5,945
PAUSE 20
NEXT
SERVO_STATUS = 0
LOW HD_FAN
GOTO CHECK_HD_SENSOR

'================== CHECK BATTERY STATUS =========================
BATT_STATUS:

ALARM:
FREQOUT 7,20,2100,3000

GOTO CHECK_CS_SENSOR

Tracy Allen
09-01-2005, 11:26 PM
To get from degC in units of 0.01 degree to degF in units of 0.1 degree, I'd use,
degF=degC+10000 ** 11796 - 1480 ' F = C * 9/5 + 32

When things stop working, go back to a simpler version of the program, with just the sensor read and debug. Maybe the sensors lost their mode setting. Make sure they are in single shot CPU mode, otherwise they cannot be used for the high resolution stuff.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

BlueZX#
09-02-2005, 12:41 AM
OK, I'll try that formula.

Seeing that no one has mentioned it, I take it that 8-12ft of wire between the bs2 & ds1620 shouldn't be a prob for the soic 1620..

if i just leave the setup on the desk w/ the 1620 on the prof board it works for hours, no probs, the prob doesn't seem to show up till i extend the 1620 to another board and place it in the freezer..

I will try this tonite and be back if still having probs

Thanks,

Post Edited (BlueZX#) : 9/1/2005 5:44:33 PM GMT

Tracy Allen
09-02-2005, 01:15 AM
You do have a bypass capacitor right next to the DS1620, at the end of the remote cable, right? The cable shouldn't need to be shielded, but compressors can be electically very noisy. Avoid running your wires right next to the motor.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

BlueZX#
09-02-2005, 04:29 AM
Yes I do...and the cable is just a long ribbon cable