Shop OBEX P1 Docs P2 Docs Learn Events
Is it possible to SEROUT simultaneously from 4 pins? — Parallax Forums

Is it possible to SEROUT simultaneously from 4 pins?

holelyholely Posts: 9
edited 2005-03-14 20:21 in BASIC Stamp
Hi again,

I'm doing a project for race management system, and I need to send out signals to 4 different BS2 simultaneously to start timing for each of the 4 cars. So is it possible to do as mentioned above? If so, what is the syntax?

Thanks!

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-11 04:31
    Are you sending out specific data to each stamp that is different than the others? if not just tie the input for all 4 stamps to the same signal.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-11 04:42
    Bus the Stamps together -- with a simple protocol, you can talk to each individually; when you want to talk to all, talk to address 0 (global) which all should be programmed to respond to. This is a fairly common strategy.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • holelyholely Posts: 9
    edited 2005-03-11 06:57
    Yup, there are routines whereby specific data is being to each stamp that is different from the others.

    Bus the stamps together: does it mean connecting them on one common communication line, say all the pins 1? If so how to talk to each individually?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-11 13:56
    It would be part of your protocol. Let's say your need to send a command byte, the structure from your master would be:

    · SEROUT TX, Baud, [noparse][[/noparse]addr, cmd]

    When you want to talk to all, set addr to 0; when you want to talk to an individual, set to that individual address. Inside the slave(s):

    · SERIN RX, Baud, [noparse][[/noparse]addr, cmd]
    · IF (addr = 0) OR (addr = MyAddr) THEN
    ··· ' work with cmd
    · ENDIF

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-11 17:11
    Jon's suggestion is your best route, in communications parlance addressing all receipients is called broadcasting.
  • holelyholely Posts: 9
    edited 2005-03-14 14:30
    Jon Williams said...
    It would be part of your protocol. Let's say your need to send a command byte, the structure from your master would be:

    · SEROUT TX, Baud, [noparse][[/noparse]addr, cmd]

    When you want to talk to all, set addr to 0; when you want to talk to an individual, set to that individual address. Inside the slave(s):

    · SERIN RX, Baud, [noparse][[/noparse]addr, cmd]
    · IF (addr = 0) OR (addr = MyAddr) THEN
    ··· ' work with cmd
    · ENDIF

    I get what you mean finally. I didn't know there is such a syntax for address in SERIN and SEROUT; it wasn't mentioned in the manual.

    Thanks!
  • holelyholely Posts: 9
    edited 2005-03-14 14:37
    In the Parallax website, I found a table on Stamp Specifications. The EEPROM size for BS2sx is 8x2K Bytes. Does it mean that it has 16K Bytes of EEPROM?

    If so, its really weird. I clicked on Memory Map in PBASIC and it seems that like BS2, it has onli 2K Bytes EEPROM. The same program takes up the same percentage of EEPROM size.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-14 14:59
    The BS2sx (and BS2e, BS2p, BS2pe) have eight 2K program slots. The memory map shows only one slot at a time. The RUN command is used to move from one slot to another.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-03-14 16:02
    Yes, it has 16 KBytes of EEPROM. The BS2 run-time library can only deal with 2K at a time, so Parallax expanded it to support multiple 2k 'slots'. The 'Run' command allows you to "re-start" your program by running from the beginning of another slot.

    This is NOT a 'call subroutine' type interface -- but there are code work-arounds that let you emulate that kind of interface using this mechanism. Quite elegant really. Search for "Slots" or "Program Slots" for more information.
  • holelyholely Posts: 9
    edited 2005-03-14 17:33
    Hi, got another question :P

    On one BS2 I have this line:
    SEROUT 1\0, 16780, [noparse][[/noparse]181]

    And on another BS2sx I have this line:
    SERIN 1, 17405, [noparse][[/noparse]com]

    where com is a variable byte.

    So does it make any difference if I put "\0" behind the "SERIN 1" command?

    I try to rephrase: without that "\0" on the SERIN but keeping the "\0" in the SEROUT, does the flow control process still take place?
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-03-14 17:50
    The SEROUT command will NOT actually send data until it sees the signal on pin 0. The SERIN command is NOT sending the handshake signal. I don't think this will work very well to actually control data flow.

    If the SERIN zero pin has the proper state by default, then the transfer can take place.
  • holelyholely Posts: 9
    edited 2005-03-14 18:29
    On the contrary, I have to drop one of the "\0"s in order for the interface to work. My programs are such that having the \0 on both commands will result in no communication.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-14 19:13
    When you add flow control to SERIN and SEROUT you are granting and waiting for permission to transmit. If you SERIN does not have an FC pin then it won't give permission to the master to transmit, so the master will simply be stuck.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-03-14 20:21
    The 'flow' control (\0) parameter assumes you've connected the two BS2's with a second 'flow-control' wire. If you haven't, I'm not surprised you had to remove the \0 on the SERIN. I assume the reason it now works is because the flow control on the SEROUT is always enabled -- accidentally, perhaps. Personally I've never needed flow control, nor gotten it working, so I'm not a good person to ask.

    You don't really need flow control. The BS2 will sit in the SERIN command forever (if you don't give it a timeout parameter) waiting to recieve the data. I suggest you remove it from your SEROUT as well, if it's not working for you.
Sign In or Register to comment.