Networking 4 basic stamps
guyba
Posts: 2
HI
I need to network 1 ("master") basic stamp to 3 ("slaves") basic stamps. There is a need fo one way communication (master to slave). THe master cntroller will have most fo·the code loaded on it. The slave controllers would run a stepper moter (send pulses to motors)
I"m kind of new to it all and was wondering if anyone could help me to understand how this is done (hardwae and software)
Best
Guy
I need to network 1 ("master") basic stamp to 3 ("slaves") basic stamps. There is a need fo one way communication (master to slave). THe master cntroller will have most fo·the code loaded on it. The slave controllers would run a stepper moter (send pulses to motors)
I"m kind of new to it all and was wondering if anyone could help me to understand how this is done (hardwae and software)
Best
Guy
Comments
With hardware, the master has one pin to each slave that·tells the particular slave to listen and wait.
With software, the master broadcasts to everyone and each slave has an address that it receives. Then it knows the message applies to it.
And of course, you can use both. This is sometimes done when a slave has two functions [noparse][[/noparse]or more]. In this way, the slave listens and then identifies which function it should be responding with.
The hardware mode is a bit faster, but requires additional wires.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Cheers
Thanks for your replay but I guess that i need more basic help...
How do I determine in the addresses of teh slaves ?
How do I refer to them in the code. The speed of the stepper motors (code on the slaves) will have to be a variable and teh master will changes it by sending them values. do I send them with serin/derout commands ? not sure how to do that ?
I hope that my qurestions make sense. As I mentioned before I"m quite new to it all.
Best guy
And how many pins can you spare for the communication?
If pins aren't a problem, I'd connect 4 or 8 I/P-pins of the master to all the slaves, creating a 'databus', and one I/O-pin for each of the slaves.
(Say, P4 - P7 is Data, and salves are connected with P0 to Slave0, P1 to Slave1, P2 to slave2 )
Leave a final pin also connected to all BS2s, say P3 in this case.
Then you can do this:
Master pulls P0 low, then waits for a response.
Slave0 acknowledges by pulling P3 low.
Master Outputs 4bit Data(allows for 0 - 15) on P4 - P7, then sets P0 High again.
Slave Watches the P0 pin, and when it notices it go High, reads the Data on the bus, then pulls P0 High
If more Data needs to be relayed, pull P0 low again.
You can easily change this to 8bit if that's needed.
This scheme will use 8 I/O-pins on the Master, and 6 on the Slaves.
If you need to expand this scheme, a 74HC138 3-to-8 decoder can be connected to the 'Address' outputs (P0 - P2) on the Master which will give you control over up to 8 Slaves (S0 - S7) without using more pins on the Master.
This routine CAN also be done completely in Software, and also with Serial transfer to save pins, but that is a bit more difficult.
If you wish to try that, then I would suggest getting hold of a book 'Serial Ports Complete' by Jan Axelson.
It is available as bot Print and Electronic download on Amazon.com and a very good read.
(It even has example code written in PBASIC )
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't visit my new website...
Then, you implement a simple protocol with a sync start, an address byte, some message bytes, and an ending byte. You program each 'slave' so its knows it's own address, and will only respond to that address.
Then the 'master' puts out a poll every so often, so each 'slave' periodically gets an opportunity to talk to the 'master'.