My first project with a picaxe.
I am trying to switch a DPDT relay (via a mosfet) to control a latching solenoid.
This is a remote station interfaced back to my PC via a XBee pro.
The switching seem to operating OK except when opening the solenoid, then, the sleep pin (pin 1, leg22 on 28x1) goes high without being called and Xbee goes to sleep and stays there forever.
At no time does the sleep pin go low again - it should cycle every minute to enable instructions to be received.
Any idea why this might be happening.
Other commands (ADC values) are working fine and not causing the picaxe to apparently freeze.
Any help appreciated.
some of the code is:
main:
'the main loop updates temperatures & adc values once a minute at secs = 30
'At secs = 0, wakes the radio up & listens for job code from master
'get the seconds
readi2c 0, (b20)
if seconds = $30 then
goto update_values
elseif seconds < $06 then
goto wake_up
else
low RF_Tx
high RF_Sleep 'put XBee to sleep
endif
pause 250
goto main
'----------------------------------------------------------------------------
update_values:
An0=0
An1=0
An2=0
An3=0
readtemp12 Temp_pin, temp
readadc10 An0_pin, An0
readadc10 An1_pin, An1
readadc10 An2_pin, An2
readadc10 An3_pin, An3
pause 1000 'ensure time is past 30secs
goto main
'----------------------------------------------------------------------------
wake_up:
'wake up the XBee
low RF_Sleep
pause 25 'let the radio wake up
high RF_Tx
'wait for master
serin [1000, main],RF_Rx,T2400,(b26,b27),Job_Code,Param1,Param2
'process job code
if Job_Code = "1" then '1 is an relay open/close command
if Param1 = "1" then 'close solenoid
if Param2 = "1" then 'position on slave
high Sol1_Pwr
pause 75
low Sol1_Pwr
endif
elseif Param1 = "0" then 'open solenoid
if Param2 = "1" then 'position on slave
high Sol1_Dir
pause 25
high Sol1_Pwr
pause 75
low Sol1_Pwr
low Sol1_Dir
endif
endif
elseif Job_Code = "2" then '2 is send temperature
'send temp in w9 = b18,b19
serout RF_Tx, T2400, (b26,b27,#b18,",",#b19)
elseif Job_Code = "3" then '3 is send adc0
serout RF_Tx, T2400, (b26,b27,#b11,",",#b10)
elseif Job_Code = "4" then '4 is send adc1
serout RF_Tx, T2400, (b26,b27,#b13,",",#b12)
elseif Job_Code = "5" then '5 is send adc2
serout RF_Tx, T2400, (b26,b27,#b15,",",#b14)
elseif Job_Code = "6" then '6 is send adc3
serout RF_Tx, T2400, (b26,b27,#b17,",",#b16)
elseif Job_Code = "7" then '7 is a time update we only need seconds
'wait for parameters
serin [1000, main],RF_Rx, T2400,(b26,b27),Job_Code,b3 'seconds
'convert ascii to decimal
b3=b3-48
'update clock
writei2c 0,($b3,$01,$01,$01,$01,$01,$01,$10)
endif
'send completed
serout RF_Tx, T2400, (b26,b27,Job_Code)
goto main
Thanks
I am trying to switch a DPDT relay (via a mosfet) to control a latching solenoid.
This is a remote station interfaced back to my PC via a XBee pro.
The switching seem to operating OK except when opening the solenoid, then, the sleep pin (pin 1, leg22 on 28x1) goes high without being called and Xbee goes to sleep and stays there forever.
At no time does the sleep pin go low again - it should cycle every minute to enable instructions to be received.
Any idea why this might be happening.
Other commands (ADC values) are working fine and not causing the picaxe to apparently freeze.
Any help appreciated.
some of the code is:
main:
'the main loop updates temperatures & adc values once a minute at secs = 30
'At secs = 0, wakes the radio up & listens for job code from master
'get the seconds
readi2c 0, (b20)
if seconds = $30 then
goto update_values
elseif seconds < $06 then
goto wake_up
else
low RF_Tx
high RF_Sleep 'put XBee to sleep
endif
pause 250
goto main
'----------------------------------------------------------------------------
update_values:
An0=0
An1=0
An2=0
An3=0
readtemp12 Temp_pin, temp
readadc10 An0_pin, An0
readadc10 An1_pin, An1
readadc10 An2_pin, An2
readadc10 An3_pin, An3
pause 1000 'ensure time is past 30secs
goto main
'----------------------------------------------------------------------------
wake_up:
'wake up the XBee
low RF_Sleep
pause 25 'let the radio wake up
high RF_Tx
'wait for master
serin [1000, main],RF_Rx,T2400,(b26,b27),Job_Code,Param1,Param2
'process job code
if Job_Code = "1" then '1 is an relay open/close command
if Param1 = "1" then 'close solenoid
if Param2 = "1" then 'position on slave
high Sol1_Pwr
pause 75
low Sol1_Pwr
endif
elseif Param1 = "0" then 'open solenoid
if Param2 = "1" then 'position on slave
high Sol1_Dir
pause 25
high Sol1_Pwr
pause 75
low Sol1_Pwr
low Sol1_Dir
endif
endif
elseif Job_Code = "2" then '2 is send temperature
'send temp in w9 = b18,b19
serout RF_Tx, T2400, (b26,b27,#b18,",",#b19)
elseif Job_Code = "3" then '3 is send adc0
serout RF_Tx, T2400, (b26,b27,#b11,",",#b10)
elseif Job_Code = "4" then '4 is send adc1
serout RF_Tx, T2400, (b26,b27,#b13,",",#b12)
elseif Job_Code = "5" then '5 is send adc2
serout RF_Tx, T2400, (b26,b27,#b15,",",#b14)
elseif Job_Code = "6" then '6 is send adc3
serout RF_Tx, T2400, (b26,b27,#b17,",",#b16)
elseif Job_Code = "7" then '7 is a time update we only need seconds
'wait for parameters
serin [1000, main],RF_Rx, T2400,(b26,b27),Job_Code,b3 'seconds
'convert ascii to decimal
b3=b3-48
'update clock
writei2c 0,($b3,$01,$01,$01,$01,$01,$01,$10)
endif
'send completed
serout RF_Tx, T2400, (b26,b27,Job_Code)
goto main
Thanks