Shop OBEX P1 Docs P2 Docs Learn Events
Two Stamps SEROUT conflict — Parallax Forums

Two Stamps SEROUT conflict

ominomin Posts: 5
edited 2008-03-11 23:13 in BASIC Stamp
I have two Basic Stamps 2 which I'm trying to connect to a single
Bluetooth Modem (Bluesmirf Gold from Sparkfun). The way this works is I
have PIN 5 and PIN 10, from the first and second Stamp's respectively,
connected to the RX pin on the Bluetooth Modem. I use the commands
SEROUT 5, 6, [noparse][[/noparse]data] and SEROUT 10, 6, [noparse][[/noparse]more data] to output my data from
the stamps to the modem. The problem is that the data is all messed up
when I read it on my PC. If I only use 1 Stamp at the time it runs
flawlessly, the problem only occurs when I use the two Stamps at the same
time. I'm considering using FC to solve this problem, but I'm not sure if that'll do
the trick. I'm not interested in transferring data between stamps only to the Modem.

Any help is highly appreciated.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-11 19:08
    You have to be careful with this. You can destroy the I/O pin circuitry on the Stamps. The trick is that only one Stamp can be set to output at a time. SEROUT will set its I/O pin to output mode and will leave it in that mode when the statement is done. You have to use what's called "open mode". The Baud values for this are listed in the Stamp Basic Manual in the chapter on SEROUT. You also will have to have a pull-up resistor from the common signal line to +5V since the Stamps only switch that line to ground for a logic low. They leave it open for a logic high and the resistor supplies the logic high voltage.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-03-11 19:14
    Omin,

    Unless I am missing some information here what you are trying to do can’t be done without extra hardware or at least communication between the BASIC Stamps. It would seem that both stamps could, at any time, be trying to access the same resource. Even without that, with the baud mode you’re using you’re driving the line so the other BASIC Stamp is fighting against that pin. I’d be surprised if one or both I/O pins weren’t already damaged.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • stamptrolstamptrol Posts: 1,731
    edited 2008-03-11 19:15
    Omin,

    The stamps are interfering with each other. The Stamp that is idle is adversely affecting the signal line.

    Two possibilities may help.

    1. isolate the two signals with 1K ohm resistors. That is, come from pin 5, through the 1K, then to the line going to the modem. Similarly, come from pin 10, through a second 1K and on towards the modem. You may have to play a bit with the resistor sizes (up and down).
    2. use the "open" version of the serout command. Look in the Help file, under SEROUT, towards the end of the write-up. It is designed to allow you to do exactly what you're attempting.

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • ominomin Posts: 5
    edited 2008-03-11 19:43
    I hope the pins are not dead, I did use a two 1K resistor from the RX to each pin.

    I'll try·"open mode" when i get home.

    Post Edited (omin) : 3/11/2008 7:48:08 PM GMT
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-03-11 19:55
    From the schematic, it looks like you'll also need to add a 10K pullup from RX to Vdd.

    -Phil
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-03-11 20:11
    Omin,

    Even with resistors on the lines, how will one BS2 know when the other is busy sending data? If they both send at the same time you will still get corrupted data…

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • ominomin Posts: 5
    edited 2008-03-11 21:07
    I was considering using another PIN for FC such that they set it to high when thet·send data and the other stamp waits while that pin is set to high. Could that work?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-11 23:13
    You need two pins. Each Stamp sets its pin to HIGH when it wants the SEROUT line. It then checks the other Stamp's line. If that's HIGH, it waits until it goes LOW. At that point, the Stamp can use the SEROUT line, then sets its line to LOW to release the resource.

    I think that'll take care of possible race conditions. Anyone else want to check my thinking?
Sign In or Register to comment.