Connecting multiple picaxes via serin/out commands

sid

Senior Member
Are there any obstacles or protocols that should be used when trying to Connect multiple picaxes to each other via serin/out commands
For instance if I wanted to connect ten pics together via one wire (plus common earth return) and control them from one central circuit, would this be possible if each pic was given its own qualifier eg: ("one") ("two") etc or does the reliability of the serin/out command deteriorate the more pics you try and communicate with?
 

Dippy

Moderator
A Master Serout to 10 Slave Serins should be OK (assuming you aren't using 10 miles of wire) but do read up on fan out for your edification. And assuming all Slaves are definitely in 'input' mode. I wouldn't get too carried away though as any degradation will have more impact as you turn up the data rate.

Each Slave having an identifier/address is the basis of simple serial networking.

However, one Master Serin from 10 slave Serouts on one wire requires a bit more thought.
You shouldn't wire them directly.
Some use a diode mix method, I would use a transistor on each Slave to make each of them them 'open' with a pullup at the master Serin pin - a bit like I2C. Don't forget the inversion if using transistors.
Other methods are around too.

If you are sure that Slave to Master data will never overlap (e.g. if using polling carefully) then you could wire them via a small res and set the pin to 'input' after each slave response transmission. This makes the pin high impedance when not being used. Though I don't think you can do that with every PICAXE type.
 

hippy

Ex-Staff (retired)
On protocol it depends on what you need. If it's master to slave initiated, slave responds only when asked to, everything should be plain sailing. If slaves never respond at all it's likely even easier; as you suggest SEROUT with an identifier, slaves running SERIN looking for their identifier. The only thing you have to watch for is that some data may appear to be an identifier of a slave.

If the slaves want to send to the master when they feel like it, it gets more complicated and you need some from of arbitration. A master to hub then star network to slaves can help there.

Sometimes multiple networks are better if you have a mix of how slaves need to work, and it's also worth considering a ring topology.

Bottom line is that how best to do it depends on what data there is, how that data is generated or being used and the purpose of the system as a whole.
 

Paix

Senior Member
You may like to investigate the RS423 range of devices available and their datasheets. They are ubiquitous and may fit your bill. Only one device transmitting at a time of course. In the past one or two suggested projects crashed upon the rocks of unrealistic expectation when it came to establishing a sensible protocol.

Good luck.
 

sid

Senior Member
Thank you all for the advice.
The idea is to have one control board and several standalone boards all connected together via a ring.
The standalone boards will be pointed to a serin command on start up and will wait for some data with its "qualifier" in it
The control board will send out a set of serout commands around the ring one for each standalone device a second or so apart and then goto a serin command to wait for a response.
The final standalone board to receive its data will then send a response back to the control board stating that the sequence is complete.

I have the above working reasonably well so far on two standalone boards but with a slight glitch on one of them.
The boards are made from pcb's and have the same code with the exception of the qualifier
If I disconnect the standalone board from the serin/out ring then it works fine.
I've probably made some silly mistake that will become evident in time but for now I'm going to swap the software from one board to the other and also try swapping the boards round to see if I can prove the fault to the software, the board or the position within the ring.
I will then introduce a third board again same pcb and software (different qualifier) and see what happens then.

I was interested to know if there were any known issues around the serin/out commands and multiple working that I've failed to see in any of the manuals etc.
Once again thanks for the advice , I intend to provide a full write up when this project is complete
 

Dippy

Moderator
There aren't any probs as far as I've heard.
Comms faults are usually down to wiring and timing (baud and code structure).

I would suggest that if you want advice on physical wiring and connections that you post the schematic of your 'master' and 2 'slaves'.
A drawing could save hours/days of questions and, as often is the way, actually drawing it may give you a Eureka moment :)
And a drawing can take loads of ambiguities out of the query.

Obv wiring faults are for you to find but anything fundamentally wrong will become obvious if you post a schematic then your code (chopped down to minimum).
 

oracacle

Senior Member
just out of interest could yu not use the line for chip select without the need for exsesive use of the serout comman - ie number of pulses = chip selected (or if have enough spare pin use a chip select line for each save)
 

hippy

Ex-Staff (retired)
The idea is to have one control board and several standalone boards all connected together via a ring.
I agree with Dippy; a schematic and/or block diagram showing how things are connected, how many signal lines, which direction data travels, will really help. Otherwise it may get quite confusing; one man's "ring" may be another's "multi-drop bus".
 

sid

Senior Member
Well I sorted out my glitch, with was nothing more than adding a pause between sending data and receiving data, so the data bus is only being used by one device at any one time.
I'm not an expert with electronics and I use it as an means to an end, however in the interests of shared learning when I've finished this project I will do a full write up and add it to my website like I did with my signal control units. http://www.stuartmoore-modelrailways.co.uk/Signal control.html

As for this servo project if you go follow the link below and then skip to the last page and scroll down there is a video showing the multiple servos in action
http://www.rmweb.co.uk/community/index.php?/topic/50534-an-asymetrical-double-outside-slip-in-2mm/page__st__100

Thanks once again for all the advice
Rgds,
Sid
 
Top