It's been a while since I last was on the forums, but I'm back again with another question/problem. I've been working on a multiple temperature sensor display project, using two Picaxe 20X2 chips, six DS18B20 temperature sensors and a SparkFun 16x2 SerLCD all wired together as show below (minus all the extra little bits and pieces used to get it working). The Picaxe connected to the SerLCD is what I call the "master" and the one with the six sensors attached is the "slave". Where I'm having problems is with the communications between master and slave. When first powered up, the sensor values will update just fine but after 3-5 minutes something locks up and the sensor values don't update.
After a bit of research, my problem seems to stem from inaccurate serial speeds that are caused by using 'serout' and 'serin' (http://www.picaxeforum.co.uk/showthread.php?20342-Solving-Serin-amp-Serout-Problems-with-20M2-and-20X2). I found that the suggested "good" speeds to use do extend the time before the the program locks up. 9600_8 only updates ~3 times before locking up, as will 2400_8 and 4800_8 whereas anything at __00_16 will usually update ~15 times before locking up.
I know that the circuitry works correctly as it used to work correctly. However, the slave Picaxe became physically damaged and, when replaced with a new one, my problems began. Part of the problem might be that the previous slave chip was firmware version C.0 while the new one is C.2. The master chip has C.1. I'm wondering what I can do to get this working properly. Would issuing the correct 'calibfreq' command work to get the chips synced and communicating properly? And if it would, can anyone suggest a good method of finding the right values? I don't currently have access to an oscilloscope or many tools, aside from my computer and a simple multimeter. I'm traveling right now and don't have access to all the stuff I normally do.
A quick fix would be to use 'hserout' and 'hserin' but unfortunately, after it worked at first I soldered the circuits up and glued them into two project enclosures. And when I say glued, I really mean it. It is impossible to remove the boards to work on now. This is meant to work in somewhat extreme environments (-20 to 40 degrees Celsius, lots of dust and vibrations) otherwise I wouldn't have fixed everything together so tightly.
I would greatly appreciate any help or insight anyone has.
Master program:
Slave code:
After a bit of research, my problem seems to stem from inaccurate serial speeds that are caused by using 'serout' and 'serin' (http://www.picaxeforum.co.uk/showthread.php?20342-Solving-Serin-amp-Serout-Problems-with-20M2-and-20X2). I found that the suggested "good" speeds to use do extend the time before the the program locks up. 9600_8 only updates ~3 times before locking up, as will 2400_8 and 4800_8 whereas anything at __00_16 will usually update ~15 times before locking up.
I know that the circuitry works correctly as it used to work correctly. However, the slave Picaxe became physically damaged and, when replaced with a new one, my problems began. Part of the problem might be that the previous slave chip was firmware version C.0 while the new one is C.2. The master chip has C.1. I'm wondering what I can do to get this working properly. Would issuing the correct 'calibfreq' command work to get the chips synced and communicating properly? And if it would, can anyone suggest a good method of finding the right values? I don't currently have access to an oscilloscope or many tools, aside from my computer and a simple multimeter. I'm traveling right now and don't have access to all the stuff I normally do.
A quick fix would be to use 'hserout' and 'hserin' but unfortunately, after it worked at first I soldered the circuits up and glued them into two project enclosures. And when I say glued, I really mean it. It is impossible to remove the boards to work on now. This is meant to work in somewhat extreme environments (-20 to 40 degrees Celsius, lots of dust and vibrations) otherwise I wouldn't have fixed everything together so tightly.
I would greatly appreciate any help or insight anyone has.
Master program:
Code:
#no_table
symbol SerCom=B.1 'the bi-directional pin used to communicate with the slave
symbol SerLCD=A.0 'the pin which the SparkFun SerLCD module is connected to
symbol Temp0=b5 'the six temperature sensor values
symbol Temp1=b6
symbol Temp2=b7
symbol Temp3=b8
symbol Temp4=b9
symbol Temp5=b10
symbol Counter=w8 'timer/counter for refreshing the sensor values
low SerCom 'initializes slave connection
high SerLCD 'initializes LCD connection
pause 1000 'wait for SparkFun Splash screen to dissapear
inits: pause 15
serout SerLCD,T9600_8,(254,1) 'clear screen
pause 15
serout SerLCD,T9600_8,(254,128) 'set pointer to line one, space one
pause 15
serout SerLCD,T9600_8,("Initializing se-nsors...")
serout SerCom,N4800_8,(%01010101,"D") 'asks slave for sensor values
serin [8000,errr],SerCom,N4800_8,("D"),Temp5,Temp4,Temp3,Temp2,Temp1,Temp0 'receives sensor values
if Temp0>128 then 'no need for negative temperatures, so just let them equal zero if they are negative
let Temp0=0
endif
if Temp1>128 then
let Temp1=0
endif
if Temp2>128 then
let Temp2=0
endif
if Temp3>128 then
let Temp3=0
endif
if Temp4>128 then
let Temp4=0
endif
if Temp5>128 then
let Temp5=0
endif
pause 15
serout SerLCD,T9600_8,(254,1) 'clear screen
pause 15
serout SerLCD,T9600_8,(254,128) 'set pointer to line one, space one
pause 15
serout SerLCD,T9600_8,("1=",#Temp0," 2=",#Temp1," 3=",#Temp2) 'displays the sensor values received
pause 15
serout SerLCD,T9600_8,(254,192) 'set pointer to line two, space one
pause 15
serout SerLCD,T9600_8,("4=",#Temp3," 5=",#Temp4," 6=",#Temp5)
goto tpdsy
updte: pause 15
serout SerLCD,T9600_8,(254,143)
pause 15
serout SerLCD,T9600_8,("*")
serout SerCom,N4800_8,(%01010101,"D")
serin [8000,errr],SerCom,N4800_8,("D"),Temp5,Temp4,Temp3,Temp2,Temp1,Temp0
if Temp0>128 then
let Temp0=0
elseif Temp1>128 then
let Temp1=0
elseif Temp2>128 then
let Temp2=0
elseif Temp3>128 then
let Temp3=0
elseif Temp4>128 then
let Temp4=0
elseif Temp5>128 then
let Temp5=0
endif
pause 15
serout SerLCD,T9600_8,(254,1)
pause 15
serout SerLCD,T9600_8,(254,128)
pause 15
serout SerLCD,T9600_8,("1=",#Temp0," 2=",#Temp1," 3=",#Temp2)
pause 15
serout SerLCD,T9600_8,(254,192)
pause 15
serout SerLCD,T9600_8,("4=",#Temp3," 5=",#Temp4," 6=",#Temp5)
tpdsy: if Counter=1500 then
let Counter=0
goto updte
endif
pause 5
inc Counter
goto tpdsy
errr: pause 15
serout SerLCD,T9600_8,(254,128)
pause 15
serout SerLCD,T9600_8,("Error! Check connection! ")
let Counter=1400
Code:
; *******************************
; Date: Feb. 15th 2011
; Written by: NXTreme
; Function: End goal to send 6 temp values to master when needed
; Last Revision: V0.1
; Target PICAXE: 20x2
; *******************************
#no_table
symbol SerCom=C.7
symbol Temp5=b5
symbol Temp4=b4
symbol Temp3=b3
symbol Temp2=b2
symbol Temp1=b1
symbol Temp0=b0
low SerCom
main: serin SerCom,N4800_8,("D")
readtemp C.5,Temp5
readtemp C.4,Temp4
readtemp C.3,Temp3
readtemp C.2,Temp2
readtemp C.1,Temp1
readtemp C.0,Temp0
serout SerCom,N4800_8,(%01010101,"D",b5,b4,b3,b2,b1,b0)
goto main