Where's b1 ?

russbow

Senior Member
I have been able to read outside temperature with an RF link to base.
Code:
#picaxe 08M
main:
	

readtemp 2,b0	'get temperature

count 3,1000,b1	'get speed

readadc 4,b2	'get direction

pause 100
SerOut 0, n600, ("UUUUU")	'open TX
Pause 100
SerOut 0, n600, ("XYZ ",b0,b1,b2 )	'Transmit data
pause 100
low 0			'TX sleep
pause 5000		' Approx 1/2 minute
goto main
Initially the cound and readadc lines were rem'd out and serout of b1 & b2 were deleted. Results were consistent and perfect. The display at base showed time, date,room temp & this air temp ( b0 ). So Tx and Rx progs O.K.

I then "let in" the speed ( count on pin 3 ). Disaster ! Temperature dropped to minus 140 and wind count was constant at 32. Not quite Hertfordshire on a September afternoon.

I then hard wired the 08 serout ( pin 0 ) to the relevant serin 2 on the base 18x. Same result.

So I tried these codes.
For the Tx
Code:
#picaxe 08M
main:
high 0	

b0=27:b2=40:b4=90
pause 100
SerOut 0, T600_4, ("UUUUUUUUUU")	'open TX
Pause 200
SerOut 0, T600_4, ("XYZ",b0,b2,b4 )	'Transmit data
pause 200
low 0			'TX sleep
pause 5000		' Approx 1/2 minute
goto main
and for the Rx

Code:
#picaxe 18x
high 7:high 2
serout 7,T2400,(254,1,254,1) 'clear screen
pause 500
main:
pause 500
Serin 2,T600, ("XYZ"),b1,b2,b3
pause 100
serout 7,t2400,(254,192,"b1= ",#b1," b2= ",#b2)
sertxd ("b1 ",#b1,"      b2 ",#b2,"   b3  ",cr,lf)
goto main
I seem to be losing the first ( b1 ) variable.

The dump from sertxd is

Code:
b1= 32     b2= 27   b3= 40
b1= 32     b2= 27   b3= 40
b1= 32     b2= 27   b3= 40
b1= 32     b2= 27   b3= 40
b1= 32     b2= 27   b3= 40
Why do I not read 27, 40, 90. I get the same result via RF or hard wired. Gone round in circles on this.

Thanks,

Russ
 

hippy

Ex-Staff (retired)
This probably comes down to unfortunate choice of qualifiers such that they match with the data being sent. Once you lose sync it may synch back up wrongly. Try changing to ...

SerOut 0, T600_4, ( $AA, $BB, $CC, b0, b2, b4 )

Serin 2,T600, ( $AA, $BB, $CC ), b1, b2, b3
 

russbow

Senior Member
Well, I'll go to the bottom of my garden !!!

Spot on Hippy, thanks.

How do you mean the qualifiers match the data being sent?
 

russbow

Senior Member
I see.
So using your solution, I can use hex numbers "out" of range and of course then, as they are not text, don't need the speech marks. Well,well.
Thanks
 

russbow

Senior Member
...which raises another query

The preceeding has certainly cleaned things up, but I still have a problem.

I am using the count command on the 08 to monitor reed contacts on the anemometer. According to manual 2 the format is "count 2, 500, w2"

But I want to transmit this with serout via a RF link

The manual says "serout, pin, baud, data". Data is a
variable / constant 0-255. I can't tie this up with the word requirement of count.

Does this mean I have to go through a bcdtoascii type thing before I can transmit?

Russ
 

eclectic

Moderator
Something like

SerOut 0, T600_4, ( $AA, $BB, $CC, b5,b4)

Then join them back together at the receiving end.

Serin 2,T600, ( $AA, $BB, $CC ), b5,b4

sertxd (#w2) ; or whatever needs doing

e
 

russbow

Senior Member
Yes, I see. Thanks. If I know the value will not be over 255, can I use (say) W2 for count, and just sent the low byte (b5 ? ) . I only want the single byte at the other end.

Russ.
 
Top