Shop OBEX P1 Docs P2 Docs Learn Events
Serial comm to multiple stamps — Parallax Forums

Serial comm to multiple stamps

GlennTGlennT Posts: 3
edited 2006-02-15 20:00 in BASIC Stamp
I am interested in communicating·with several stamps using serin/serout, but using addressing rather than polling a series of inputs.· Most of the info that I've seen uses more of a master/slave relationship with the master polling a series of pins with a slave connected to each pin.· I envision using a uart and then·inverting / anding the outputs to act as a chip select, to address each stamp. I'd like to solicit advice from anyone who has done anything similar.

Thanks!

Comments

  • NewzedNewzed Posts: 2,503
    edited 2006-02-15 01:05
    Very simple.· If you want to send something to Stamp 1, Stamp 1 says

    serin pin, baud, [noparse][[/noparse]WAIT("A"), data

    and from the master you send

    serout pin, baud, [noparse][[/noparse]"A", data]

    Use WAIT("B") for Stamp 2, WAIT("C") for Stamp 3, and so on



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-02-15 15:06
    "using a UART and then inverting/anding the outputs to act as a chip select..."

    The nice thing about a multi-drop RS-232/UART based network is you only have to run a few wires. If you now add chip-selects to that mix, you now have to run more wires.

    That's why most implementations DO use a 'master-slave' protocol for this -- a master 'requests' data, and the slaves 'answer'. It takes the least amount of hardware and wire to do it this way.

    Oh, wait, reading your post again, it looks like you think you can only connect one 'slave' to each pin of the 'master'? In fact, you can 'party-line' a pin of the 'master' to multiple 'slaves' (using 'Open' baud modes, that's what they're for). And 'party-line' a response line back from multiple 'slaves' to the 'master'.

    You can also use a 'token' scheme to allow any BS2 on the 'network' to become the 'master'. In this scheme, one BS2 has the 'token' to be 'master'. All the other BS2's act as slaves. Should the 'master' not talk for a period of time, then one of the 'slaves' becomes the new 'master', and gets the 'token'. There may need to be some negotiation with the other slaves to insure only one decides to become the 'master'.
  • GlennTGlennT Posts: 3
    edited 2006-02-15 18:28
    Thanks for the replies!·I tend to think in terms of hardware rather than software so the programming suggestions from Newzed are very helpful. AllanLane5, it sounds like you are talking about multiplexing and letting more than one slave use the same port.· I must confess my ignorance of "open baud modes", could you explain that to me? I'm familiar with token rings, but I don't need anything that complicated. I'm basically interested in interfacing a BS2 to a series of other BS2s or some relay circuits and addressing them serially.· For instance I would like to send out·a byte on the serial line that would consist of an address followed by an instruction. e.g. valve at address 10, move to open position. So the first·nibble would be 1010, and the second·nibble might be 1111 to signify the open position.··This would be easy using the system that Newzed suggested, but I'd also like to keep the cost as low as possible and would like to avoid using a stamp except where I need additional functionality.· Thats why I was thinking of using a UART and some sort of select line.· Using Newzed's suggestion, interfacing the BS2s shouldn't be a problem, it's the relay circuits that I'm more concerned with.· I'd like to use the uart and a logic circuit to address a specific·relay, I could·NAND· some of the lines coming out of the uart to act as an address and then use that to enable the appropriate relay.· I'm not sure that this is the best way though, any thoughts?· It's been about 15 years since I've done any real digital interfacing and I'm a little rusty, so any advice is greatly appreciated.

    GlennT
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-02-15 19:56
    GlennT -

    The topic of open baud modes is somewhat unique to the PBASIC Stamp. A discussion about that aspect, and multi-Stamp networking using that technique, can be found in the Parallax PBASIC Stamp Manual.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-02-15 20:00
    The problem with connecting multiple drivers together is when one is 'pulling' its pin low, while another is 'pushing' its pin high -- in other words, two outputs are connected together, and fighting with each other. This burns out pins, if there's not a 220 ohm current limiting resistor in the middle.

    The solution to this is the 'open baud mode'. In an 'open baud mode', the BS2 pulls the signal to ground, but a 10 Kohm resistor is tied between the pin and +5, so the pin can 'float' high. Thus the pin is never 'driven' high, and you don't get the destructive fighting.

    If two 'senders' try to send at the same time, the data on the line will be garbled, but no destruction will result.

    Now, the BS2's have this 'open baud mode', so you can connect multiple senders together. I don't think UART chips do, however.

    Your application seems perfect for a native Microchip PIC processor -- or for that matter the SX processor-on-a-card that Parallax sells. That would let you use a programmed SX card for each I/O node, and the open baud modes, probably for less cost than the UART based solution.

    If you're doing this just once, buying the BS2's may be the most cost effective solution. If you're doing this more than once, spending the additional infrastructure dollars for a PIC programmer etc. would be a good idea. The SX-based solution would be a middle-of-the-road approach.
Sign In or Register to comment.