Slave outputs from master

stevercarter

New Member
I wish to use say a 20m as master and serial connect say 4 20m as slave units
I want the slave units to replicate the master outputs
 

rossko57

Senior Member
I wish to use say a 20m as master and serial connect say 4 20m as slave units
You might use serial communication. If you have enough pins on the master, a serial wire to each slave is easy.

Or you might use 'multidrop' - a single wire connects all Picaxe. Key here is to give each slave a unique ID or address. The slaves receive all data, but only act on data with their own ID.

For simplicity this can be a one-way communication ; but if there is much distance between parts you might make it two-way, which allows 'handshaking' - the master can check if data gets to the slave successfully, and if not can try again.

Are we on the right track for you?
 

hippy

Technical Support
Staff member
If the slaves only replicate the master's output it should be possible to send 'outpinsB' to all slaves and have them set their own outputs the same. Multi-drop line as described, something like ...

Code:
Master:
  dirsB = $FF
  Do
    pinsB = ...
    SerOut TX_PIN, TX_BAUD, ( outpinsB )
    Pause ...  
  Loop
Code:
Slave:
  dirsB = $FF
  Do
    SerIn RX_PIN, RX_BAUD, pinsB
  Loop
 

stevercarter

New Member
thanks for info will try out .what I have is a beijer h tm40 touchscreen with plug on plc I/O HMI unit.
I want to remotely monitor these 8 outputs (mimic panel) with led's 3 by picaxe 20m as slave units
these have 8 I/O. the relay output will control master 20m inputs 1-8 which will turn on 20m outputs 1-8 respectively.
so I would like to connect serial out to serial in of 3by 20m slave units which will replicate master 1-8 outputs.
i am not sure if serial out to serial in is best way and do i need to have slave units id numbers even tho they
will be doing the same thing
 

rossko57

Senior Member
i am not sure if serial out to serial in is best way
Presumably these mimic panels are to go some distance away, long wiring runs are traditionally a serial job, so that sounds right. How long?

and do i need to have slave units id numbers even tho they
will be doing the same thing
If the slaves only listen, and you don't need to know if they are all correctly there. or respond to buttons pressed on them or suchlike - then they can all be the same with no unique ID.
 

stevercarter

New Member
code
Master:
dirsB = $FF
Do
let outpinsB = pinsC
serout A.0, N4800_4, ( outpinsB )
pause 1000
Loop

code
slave:
dirsB = $FF
Do
serin C.4, N4800_4, pinsB
Loop
queries for master I will use picaxe20X2 and slave picaxe18m2 because serin pin is A.0(master) and serout pin is C.4 (slave) simulation then executes
is there a standard labelling for other serial in and serial out?
for baud I have used N4800@4khz is this the best setting?
when wiring from master serial out (master A.0) to serial in (slave C.4) do I use resister network on serial in or just direct connection?
am getting chips this week. do you think programme is ok and are there better chips for this application
 

hippy

Technical Support
Staff member
A.0 on the 20X2 is the Download Serial Out, and C.4 on an 18M2 is the Download Serial In. These are used for downloading to the PICAXE. SEROUT and SERIN commands do not need to use those pins, and it is often better that they do not. SEROUT and SERIN can use any of the appropriate digitial I/O pins.

It is common to put outputs (SEROUT) on B.x pins and inputs (SERIN) on C.x pins but that is is not mandatory. You can put SEROUT on a C.x pin to use all B.x for indicators or outputs. Just check the C.x pin is not 'input only'.

Baud rates need to match at both ends and it is usually best not to include and operating speed postfixes like _4 when operating at default speeds. The 20X2 operates at a default 8 MHz so N4800_4 will not give 4800 baud. Just use N4800 to start with.

The SEROUT to SERIN can often be a direct connection but it would be recommended to include an inline 1K resistor.

I would probably have used the same chips as master and slave but you can use any which have enough output pins.
 

stevercarter

New Member
have kept master the same but changed line to serout A.0, n4800, (outpinsB )
the slave I have changed to 20x2 as well and changed line to serin C.1, N4800, pinsB
this works great and have tested with 110M cat6 serial out to serial in and it works great
will try more slaves in parallel this week
only problem occurred when when cable not joined holding serial cable going to slave unit
caused it to randomly operate. I put a 10k resister from +5v to serin pin C1 and this solved
problem is there a better way of doing this
thanks Hippy 4 your help
 

hippy

Technical Support
Staff member
only problem occurred when when cable not joined holding serial cable going to slave unit caused it to randomly operate. I put a 10k resister from +5v to serin pin C1 and this solved
As you are using N4800 baud rates ( idle low ) it would be better to make the pull-down from pin C.1 to 0V.
 

stevercarter

New Member
am experiencing mains interference outputs can flicker off when say lights turned on am going to try timing it out
by pausing slave programme at slightly less time than master pause ,is there say a capacitor network to stop this
or a better delay output on ,what is the fastest pause time on master that can be used our 50 cycle mains time
works out at 20ms appreciate your thoughts
stevercarter
 
Top