PDA

View Full Version : Problem with LCD 40X, serin, for...next loop



BrendanP
18-01-2006, 05:26
This is an on going problem that Hippy gave me some help with a few weeks back. Ive tried everything I can think off. Ive reduced the program to this simple version to demonstrate the problem. Im sering in data via RF. 50 serins takes around a second so I am using a for... next loop to give the illuison of a timer between serins. This way you can have a idea of how long since youve got fresh data comming in.

It works fine as long as I dont try and use the serin line of code. I cant understand why this would affect the program. Im using a 40X and the rev ed LCD.

main:
b1 = 0
serout 7,n2400, (254,1)
pause 30
serout 7, 2400,(254,128)
serout 7, n2400, ("REFRESH SCREEN")
pause 2000
serout 7, n2400, (254,1)
pause 30
serout 7, n24000, (254,192)
serout 7, n2400, ("SEC SINCE REF")

loop:
for b6 = 1 to 50 step 1
serin 4, n2400, (":01"), b2 'prob is here
next
'pause 1000 'use if serin disbaled
b1= b1 + 1

serout 7, n2400, (254,205)
serout 7, n2400, (#b1)
if b1 > 20 then main
goto loop

Â*

ylp88
18-01-2006, 06:07
You program is stalling at the serin command becasue the PICAXE expects data to be incoming and will wait until it receives it, including the qulifier you have specified. Thus it will wait until it has received 50 ":01" packets until the normal program loop will resume.

Using the timer will wait 1 second regardless of any serial input.

<b><i>ylp88 </b> </i>

BrendanP
18-01-2006, 06:45
What, if anything, can I do to get around this? How can I make it run through the fifty serins even if there is nothing comming in?

Â*

hippy
18-01-2006, 11:31
You can't easily, and it would probably require another PICAXE which waits for RF data then raises a line to tell the master there is a packet ready. It doesn't matter if the slave is waiting all the time, but it allows the master to run until the slave has data, and then the SERIN can be done. A Forum Search should provide additioal info, but not sure what keywords would get you there; 'master' 'slave' are probably good bets.

BrendanP
18-01-2006, 18:12
I had been contemplating this at work on night shift tonight and came to a similar conclusion. Ill try a 0M8 as a dedicated 'seriner' which will leave the 40X to do other stuff in the mean time. Im thinking I could use the serint com on the 40X to keep an eye on the OM8.

Â*