Serout and Serin

hello.

I'm playing around with the Serout and Serin commands for the first time. Basically, I would like to use it to transmit the values of variables from chip to chip.
Im using 2x 20M2 pics.

So far... I have this:

pic1:

serout b.7,N4800_32,("b1"),b1

pic2:

serin c.0,N4800_32,("b1"),b1


However, I keep getting a syntax error on the serout, although the serin seems fine. Also, is there a way to transmit more than one variable at a time? Ive tried it but it seems to mix the variables up, so for example if b1=10 and b2=30, it seems like both variables end up being 20 on pic2.

thanks, from a complete novice (with this command at least)

Jon
 

nick12ab

Senior Member
Welcome to the Forum.

You need to use for sending:
Code:
serout B.7,N4800_32,(b1)
and for receiving:
Code:
serin B.7,N4800_32,b1
Pleasee see serin and serout for more information.
 
yep. just answered that one myself, theres a thread here which talks about syntax.

so... does that mean I could use, for example

serout B.7,N4800_32,(b1,b2,b3)
and

serin C.0,N4800_32,b1,b2,b3
to transmit those variables from one pic to another? Would they stay as individual variable values, or, as it seems when I try it, does it add all the variables together and then share them out equally at the other end? I know that sounds ridiculous, but its the only thing I can think of that explains whats happening on the board.

Thanks
Jon
 

eclectic

Moderator
but its the only thing I can think of that explains whats happening on the board.
1. What is happening on your board?

2. AXE091 board.

08M C.2 serout connected to
18M2 C.1 serin

Code:
#picaxe 08m2
b0 = 1
b1 = 2
b2 = 3

main:

serout c.2, n2400,(b0,b1,b2) 
inc b0 : inc b1: inc b2

pause 1000

goto main
Code:
#picaxe 18M2

Main:

serin C.1, n2400, b0,b1,b2
sertxd (#b0," ",#b1," ",#b2, cr,lf)

goto main

All working fine.

e
 

Attachments

Last edited:
well i just typed some details about what was happening, but it didnt come up. hey ho. in any case, its working perfectly now.

Thanks to everyone for your help.
 
it was a basic test breadboard using one pic to transmit a variable which controlled a flashing LED on the other pic.

now youve all helped me with the correct syntax etc, its going to form part of a control system for a model railway, proabably using about 10 pics eventually.

thanks everyone. one final question, is there a limit to the number of variables that can be transmitted? looking in the manuals, it looks like 8 variables... or have I read that wrong?
 

hippy

Ex-Staff (retired)
The only limit on variables sent is the number of variables available and program memory.
 

jinx

Senior Member
now you got serin/serout why dont you have a look at the using the hsersetup it could be more useful,
 
Top