readtemp neg values

russbow

Senior Member
I have a little masthead unit sending data over a 433Mhz link to base.

I am reading wind speed, direction & temperature.

Code:
#picaxe 08M
main:
	high 0
	serout 0,T2400,(254,1,254,1)
readadc 1,b1	'get direction
count 3,1000,b2	'wind speed raw data
readtemp 2,b3	'get temperature




pause 100
SerOut 0, T2400, ("UU")	'open TX
Pause 100
SerOut 0, T2400, ("XY ", #b1," ",#b2," ",#b3 )	'Transmit data
pause 100
low 0			'TX sleep
sleep 5		' Approx 1/2 minute
goto main
I realised I would need to cope with negative temps. Manual 2 suggests -
Code:
readtemp 1,b1 ‘ read value into b1
if b1 > 127 then neg ‘ test for negative
serout 7,N2400,(#b1) ‘ transmit value to serial LCD
Do you see any problem in using the read value to set a variable and to use this as a flag at base.

Something like -

Code:
readtemp 2,b3	'get temperature
         b4=0
         if b3 > 127 then b4=1
         .
         .
        SerOut 0, T2400, ("XY ", #b1," ",#b2," ",#b3,#b4 )	'Transmit data

and at the base

        serin 1,T2400,("XY"),#b1,#b2,#b3,#b4

        if b4=1 then do something else.
Also, do I need the # symbol?

Russ.
 

hippy

Ex-Staff (retired)
The simplest thing to do is to send the byte data as read and leave the receiver to deal with handling any negative numbers; what it will receive is exactly as if it had done the READTEMP ...

TX:
ReadTemp 2, b3
SerOut 0, T2400, ( "XY", b3 )

RX:
SerIn 1, T2400, ( "XY" ), b3

No need to use #
 

russbow

Senior Member
Thank you both. Of course, the variable is received as sent. Then do the maths.

I am doing this with the wind speed, why did I not think of it for temp!!

Grateful, as ever for your help.

Russ.
 

manie

Senior Member
Just as another lousy question: Once you have the data onboard the receiver, how is the "negative" interpreted and displayed and how will you use the negative value from there on in your program (the manual is not very clear...)
 

russbow

Senior Member
I am displaying it on the LCD Manie. Now I have cleared up the confusion, thanks to this forum, I lifted the code from the readtemp command in the manual.
Code:
temp:

if b3 > 127 then neg ‘ test for negative
serout 7,T2400,(254,128,"Air ",#b3,$df)
goto chill
neg:
let b3 = b3 - 128 ‘ adjust neg value
serout 7,T2400,(254,128,"Air -",#b3,$df)

chill:
if b4 > 127 then neg2 ‘ test for negative
serout 7,T2400,(254,138,"Chill ",#b4,$df)
return
neg2:
let b4 = b4 - 128 ‘ adjust neg value
serout 7,T2400,(254,138,"Chill -",#b4,$df)


return
If I stuff dummy variable in for b3 & b4, say 180 to 225, works fine.

The next Q is, has anyone got a suggestion for measuring the "chill factor"?

Seems to me that the sensor needs to be exposed to the elements. Poking out the top of a tube with lots of silicon?
 

hippy

Ex-Staff (retired)
The next Q is, has anyone got a suggestion for measuring the "chill factor"?

Seems to me that the sensor needs to be exposed to the elements. Poking out the top of a tube with lots of silicon?
That mounting idea sounds feasible though make sure you use a silicon which doesn't corrode the chip or leads and can withstand 'real weather' abuses. You can mount the DS18B20 inside something which is heat conductive and gives protection, but there may be thermal lag.

Others have done 'weather station' projects so a Forum Search should turn up ideas.

http://en.wikipedia.org/wiki/Wind_chill

Has some info on Wind Chill factor, showing tables and calculations. As there's some 'contention' on what the equation should be, you may be able to simplify, approximate or change those for temperatures and winds you are likely to encounter.
 
Last edited:

manie

Senior Member
Russbow: Thanks mate. I'll take a close-up pic of how I have mounted my LM35DZ's for use in the chook-house where pressure cleaning with water is done. So far they have lasted and stood up well. I have used Pouring Resin as used for electrical cable splicing. I just chucked away the horrible plastic cable jacket and used my own. Will post pics when I've got a moment.
 
Top