Any way out of SERIN

hippy

Ex-Staff (retired)
Not inherently. One way is to have a second PICAXE monitor the serial in line and either reset the PICAXE or mix in a faked character to kick the receiver back to life. The best mechanism is to have a second PICAXE ( 08 is cheapest ) receive serial and handshake with the main PICAXE so it only enters SERIN when it knows there is data available for it, and it doesn't matter if the serial buffering PICAXE goes into a SERIN wait.
 

SD2100

New Member
Thanks Hippy, it gets a bit messy dosn't it trying to work around this, SERIN definitely needs a timeout. Another option I was looking at was the 16F628 for the receiver, I've got all the gear to program these as I started with micros on the 16F84's.

Edited by - Phil75 on 19/04/2006 06:00:45
 

ljg

New Member
another way is to use the button command to look for "junk" data, then switch to Serin.

It requires the sending Picaxe to actually send the junk stream, but you don't need the extra picaxe.

Edited by - Larry on 21/04/2006 02:46:55
 

manuka

Senior Member
Larry - bravo! The very involved PBASIC "button" command is of course a BASIC Stamp bastion, but it's Picaxe use is rather neglected. This merits further work. Stan
 

AllanBertelsen

Senior Member
Hi -
With this code on the receiver I use interrupt for initiating communication. When sender want to sent data it raises its output pin. Receiver interrupts and raises its pin to tell the sender that it is ready. Then receiver gets the message via serin.

The receiver just does its work - blinking a LED in this case. Only when sender wants to send it will use Serin.

<code><pre><font size=2 face='Courier'>
Symbol FromMaster = input3
Symbol ToMaster = 4
Symbol LEDout = 1
Symbol LEDin = 2

high 2
high 1
pause 200
low 1
low 2
low ToMaster
setint %00001000, %00001000


Main:
high LEDout
pause 500

low LEDout
pause 500

Goto main

GetMessage:
Serin 3,N2400,B2,B3,B4
Low ToMaster
Low LEDin
setint %00001000, %00001000
return

Interrupt:
High LEDin
High ToMaster
b1 = input3
if b1=1 then Interrupt
gosub GetMessage
return
</font></pre></code>

Edited by - AllanBertelsen on 20/04/2006 08:31:20
 

ljg

New Member
I switched computers so I don't have some old code available, but here's the gist for the button command. This code is great if all you are using is an 08 or other &quot;primitive&quot; Picaxe that doesn't support interrupts

The sending picaxe does the same sequence as the interrupt example above, but needs to keep the pin in the high state long enough for the receiving Picaxe to cycle through its main loop so it isn't missed.

sending picaxe pseudocode

high 1
pause 50
low 1

serout 1, T2400, (&quot;start&quot;, databyte,databyte1,etc)



The receiving Picaxe uses the button command in the main loop to determine if the sending Picaxe wants to send data. If the main loop is long, put more than one BUTTON command in the loop

workvar= 0 ' initialize button byte variable
Main:
button 1,1,0,0,workvar,1,receivedata

&lt;&lt;your main loop code here&gt;&gt;

goto main


receivedata:
serin 1,t2400, (&quot;Start,&quot;),databyte, databyte1,etc
goto main

' the receiving Picaxe gets the data after the &quot;start&quot; string.

the code snippets are generalized, and haven't been checked, but you get the idea...

Edited by - Larry on 23/04/2006 05:16:31
 
Top