Serial Communication between two picaxes

tsuki_k

New Member
I'm using two picaxe 28x1 and I'm having a problem when I'm trying to send information serially to a second 28x1.

The first picaxe is sending out the following command:
serout 0, T9600_8, ("+", b0)

while I'm using this command:
serin 7, T9600_8, b1, b2

to receive the information. b0 is just a number like 72 for testing purposes. But, the picaxe receiving the data is only getting 254 & 1 for b1, b2.

Am I doing something wrong?
 

BeanieBots

Moderator
I've move your thread from the "finished projects" area to the "Active Forum" where you are likely to get more replies.

The first obvious question has to be, are you using a 8Mhz resonator/crystal on both 28X1s to go with the T9600_8 baud setting?
Do you have both 0v's connected?

Also worth having a read of this thread:-
http://www.picaxeforum.co.uk/showthread.php?t=8289
 
Last edited:

womai

Senior Member
Just to be sure, you are aware that the pin number for serout denotes an output pin, while for serin it denotes an input pin (or, more precisely, I/O pin)? So

serout 7, ....

and

serin 7, ....

access two different pins, despite the number being the same.

Wolfgang
 

tsuki_k

New Member
For the picaxe sending out the serial command, i can put a serial LCD on the output and the output comes out the way I want it to look. (+72) But, if i connect the output to a input pin in the second picaxe I don't get the input at all.

I did change the direction of the output pin using:
let dirsc = %01110000 to make pin 7 of the second picaxe an input

And yeah, I'm using output 0 pin on the first picaxe and input 7 pin on the second picaxe. All the grounds are common as well. I'm not using an external resonator though, do I need too? I mean the serial lcd works only at 9600 baud, 8 bit parity and it can receive the output from the first picaxe.
 

hippy

Technical Support
Staff member
For the picaxe sending out the serial command, i can put a serial LCD on the output and the output comes out the way I want it to look. (+72) But, if i connect the output to a input pin in the second picaxe I don't get the input at all.
Originally you said, "the picaxe receiving the data is only getting 254 & 1 for b1, b2", so does it receive nothing or something ?
 

tsuki_k

New Member
Originally you said, "the picaxe receiving the data is only getting 254 & 1 for b1, b2", so does it receive nothing or something ?
It receives 254 & 1. But, that's not what it should get. Shouldn't it receive "+" & 72?
 

hippy

Technical Support
Staff member
Thanks; receiving something is better than receiving nothing. Yes it should receive whatever you send. As already noted questions have been raised about 28X1 communicating at speeds above 2400 baud so it is well worth trying your communication between PICAXE at 2400 and seeing if that works.

The good news appears to be, on the evidence here with the LCD, that there seems to be no problem with transmitting at above 2400 baud.
 

BrendanP

Senior Member
Hippy, I have two 40X1's serially communicating, I've found the link reliable at 2400 thus far. I haven't ran the thing through a million cycles or anything which I guess is the way to really check it.

Off the top of your head, would I gain even more reliability on the serial link by slowing the baud rate to say 1200?
 
Last edited:

hippy

Technical Support
Staff member
@ BrendanP : I wouldn't expect 1200 baud to be more reliable than 2400. I wouldn't expect 4800 or 9600 to be unreliable either but there's definitely some issue here with the X1's.

I've bit-banged 115200 @ 4MHz on a PICmicro with no problems but there is a specific problem with PICAXE's and other interpreted language processors which can rear it's head with multiple bytes sent. Consider "SERIN pin,N4800,b0,b1"; after the first byte has been received, the PICAXE needs to determine where to store the received data, store it in b0, and be back and ready to catch the start bit of the next byte. As the baud rate goes up the time to do that gets less.

There's usually just 11uS at 115200, and only 150uS at 9600 baud, so if data is sent too quickly there can be problems. Using two stop bits or forcing inter-byte gaps will solve the problem. Similar problems can arise with qualifiers, eg "SERIN pin,N4800,("XYZZY"),b0"
 

BrendanP

Senior Member
What are 'stop bits' and 'inter gap bytes'?

Thanks Hippy.

Its interesting you speak of the multi byte angle as thats just what Im doing. I use the line below to recieve a telephone number. The recieving 40X1 then feeds it into a GSM module. So far its working OK. No wrong numbers called.

serin [100,load],3,n2400,("num"),b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10


bo to b9 hold the telelphone number. b10 holds the byte that indicates what to do with the number whether to dial it or what sms to send to it.


What are 'stop bits' and 'inter gap bytes'? How would I use them in my line of code above?
 

Technical

Technical Support
Staff member
It receives 254 & 1. But, that's not what it should get. Shouldn't it receive "+" & 72?
It seems to us a bit too much of a coincidence that you have used a serial LCD correctly... and then complain of (254,1) when replacing the serial LCD with the second PICAXE.

Because 254,1 is the 'clear screen' command for the serial LCD...! So if you haven't removed the serial LCD specific parts of the code from your test program the second PICAXE is actually getting exactly what is expected!

Maybe a post of your programs would help!
 
Last edited:

CWells

New Member
I'm having a similar problem - I'm trying to get two 08M's to talk to each other at 2400 baud. I'm using "serout 4, N2400, (b1, b2, b3, b4, b5, b6)", which my logic probe tells me is working fine on pin 3 of the second 08M - but the "serin 3, N2400, (b1,b2,b3,b4,b5,b6)" doesn't seem to be picking up anything...
 

tiscando

Senior Member
"serin 3, N2400, (b1,b2,b3,b4,b5,b6)"
Because these variables are enclosed in brackets, this makes the command use their value as qualifiers, rather than for receiving. This means that if all the variables are 0, the program would only move on if it recieves six 0s.

Remove the brackets, so it's "serin 3, N2400, b1,b2,b3,b4,b5,b6". The command collects any serial data and puts the bytes into the variables from left to right.

Only the 'serout' command requires the data in brackets.

Does this help?
 
Last edited:

Dippy

Moderator
What happens if you remove the brackets on the SerIN command?

Online Manual page 170 (at the moment)
 
Last edited:

CWells

New Member
Cool...still having problems, but now I've got enough to work with to figure out the rest (I hope). I'm getting a signal now, thanks a lot for the help.
 
Top