Shop OBEX P1 Docs P2 Docs Learn Events
ping sensor with multiple BS2 — Parallax Forums

ping sensor with multiple BS2

frosliefroslie Posts: 67
edited 2005-06-28 15:19 in BASIC Stamp
I have a Ping))) sensor connected to two BS2s. Both BS2s are on separate BOEs.· One board powers the Ping))) and the signal line splits off one rail to both boards. The sensor only seems to work with the BS2 it is directly attached to.

Anyone have any ideas to drive both stamps with the one sensor?

also, when I kill the power to the board that does work, and then re-power it - the sensor does not activate, the stamp seems to skip right into the code.

The sensor is being used as a fairly basic motion sensor for both BS2s.

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-06-27 21:05
    connect the ground of both BOEs together.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • frosliefroslie Posts: 67
    edited 2005-06-27 21:23
    I'm not sure how to accomplish this at this point. Both BOEs are powered by separate wall-warts. I have spliced the cords on the wall-warts already to add two different toggle switches ( this was done in order to power the boards as they are contained inside a box and the switch will not always be accessible).

    can I simply connect the ground to two grounds to the sensor somehow?
  • edited 2005-06-27 22:00
    You might want to try jumpering VSS on the two BOE's. That in effect would tie both grounds to a common point, I believe anyhow.

    Regards,
    Michael G. Jessat
  • frosliefroslie Posts: 67
    edited 2005-06-27 22:13
    there is a fair amount of pre-existing circuit on both boards. I assume you mean to connect a single wire between the VSS points,

    Do you think there is any risk of damage to the circuits in doing this?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-27 22:27
    You should be very careful with this setup -- make sure the Ping pin on each board are always in INPUT mode except when doing the PUSOUT. Also, I would be inclined to but a 220 resistor between the Stamp pin and the Ping; it won't interfere with the Ping signalling and will prevent problem should one Stamp make its pin high while the other makes its pin low.

    Another thought... How does one Stamp know when NOT to attempt access to the Ping lest is step on the Ping output that is currently underway?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 6/27/2005 10:39:57 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-27 22:30
    Hello,

    ·· I would use one BS2 to take the readings and send it to the other via serial line.· My question is, how are you triggering the PING?· Are both BS2's trying to trigger it?· How do you know which one has control?· How does each BS2 know when to get the return pulse?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • frosliefroslie Posts: 67
    edited 2005-06-27 22:32
    for clarification - the 220 resistor between the stamp pin on each board and the Ping. And then run a single jumper wire between the VSS on the two BOEs?
  • frosliefroslie Posts: 67
    edited 2005-06-27 22:37
    Chris,

    Both Bs2s are trying to trigger it

    I was trying to get both to receive the return pulse at the same time.

    Basically, I would like for it to serve as a motion dector that activates both stamps at the same time.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-27 22:39
    froslie,

    ·· Yes, and as I said, you're going to have a problem doing that.· What if one BS2 is trying to trigger it at the same time as the other?· What if one is triggering and one is receiving?· The one receiving is going to interpret the PULSE as a measurement.· The only way I can see to get the data to two BS2 Module is to have one read, and send that data to the other over a serial interface.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-27 22:41
    Chris's idea is the smartest: Let one Stamp control the Ping and then send a serial message to the other. If you don't want to do that then one Stamp has to be "in control" of the triggering. The other will watch that line for the trigger pulse then go into the PULSIN routine. This is safer because the second Stamp never makes its Ping pin an output.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • frosliefroslie Posts: 67
    edited 2005-06-27 22:45
    Unfortunately the BOEs are already built into an existing structure for an artwork going into a museum. This limits my access to the serial ports for a connection cable. I understand the triggering and receiving issue.

    maybe I will need to try two Ping sensors.

    Is there no other way that I can send a simple message to the other stamp and let it know the first has become activated?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-27 22:50
    Froslie,

    ·· Connect the Vss and an I/O pin to each other and you have a serial link.· If you were going to connect to Stamps to one PING, then you should be able to use the same lines.· You do need common ground though.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • frosliefroslie Posts: 67
    edited 2005-06-27 22:56
    So, I connect the Vss on the board with the Ping to an I/O on the board without and this establishes a serial connection. Then I also connect a jumper between the VSS on both boards to create a common ground.

    how do I send the commnad through the serial connection?
  • Kevin B SlaterKevin B Slater Posts: 49
    edited 2005-06-27 23:06
    froslie,

    · If I may jump in on this I will make my suggestion, although I will say you have two excellent Parallax employees helping you.· You should read "A Tale of Two Stamps"· this Nuts & Volts article by the very Jon W. has and excellent tutorial on connecting two stamps together.· I believe this will help getting the stamps to communicate with each other.

    Kevin
  • frosliefroslie Posts: 67
    edited 2005-06-27 23:10
    Kevin,

    thank you, I will check it out.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-27 23:12
    Okay, I'm not wild about your idea of connecting two Stamps to one ping ...·but I think you can make it work.· The attached schematic shows how to connect things safely.· The key is letting Stamp 1 be the master.· Stamp 2 will watch for Stamp 1's trigger pulse and when it goes away it will start it's PULSIN cycle, just like on Stamp 1.

    Hopefully this will clear things up:

    Main1:
    · GOSUB Get_Ping1
    · END

    Get_Ping
    · HIGH Ping1
    · PAUSE 5
    · LOW Ping1
    · PULSIN Ping1, 1, pingRaw1
    · RETURN

    On Stamp 2 you would have something like this:

    Main2:
    · DO
    ··· PAUSE·10
    · LOOP UNTIL (Ping2 = 0)··········· ' wait for line to clear
    · GOSUB Get_Ping2
    · END

    Get_Ping2:
    · DO : LOOP UNTIL (Ping2 = 1)······ ' wait for trigger to go high
    · DO : LOOP UNTIL (Ping2 = 0)······ ' wait for trigger to go low
    · PULSIN Ping2, 1, pingRaw2
    · RETURN

    You get the idea.· Still, if things get out of sync there will be a problem.· I made a small change to the Stamp 2 code so that it could attempt to sync itself -- basically it waits for the line to be low for more than 10 ms; that way it can't mistake the output from the Ping return as a trigger pulse.

    If you have a couple spare pins on each Stamp a serial scheme would be much easier to implement.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    638 x 334 - 35K
  • frosliefroslie Posts: 67
    edited 2005-06-27 23:20
    this looks great, thanks for the jpg.

    I do have extra pins on boths stamps. I am unsure though, how to implement the serial scheme.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-27 23:30
    If you're not sure you need to be very careful with everything you're doing -- we'd hate to have you kill a couple Stamps with a Ping that costs half as much....

    The article pointed out in the post above will give you lots of good information -- you can also find information right in our help file (see SEROUT and SERIN).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • frosliefroslie Posts: 67
    edited 2005-06-27 23:34
    I agree - I am a student and cannot afford to loose these stamps.

    I will check out the article and help files,

    thanks for your time.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-28 15:19
    froslie said...
    So, I connect the Vss on the board with the Ping to an I/O on the board without and this establishes a serial connection. Then I also connect a jumper between the VSS on both boards to create a common ground.
    how do I send the commnad through the serial connection?
    froslie,

    ·· I see you've gotten many replies since I was last on, but to clarify, no you wouldn't connect the Vss from one Stamp Module to the I/O pin on the other Stamp Module.· All that would give you is a LOW on the destination Stamp Module's I/O pin.· I was trying to give an example of a simple serial interface, but I see Kevin pointed you to a detailed one.· That was my suggestion.· Communication between the two Stamps, which, depending on what the other Stamp is doing may only need to be one way.· If you can get the PING two work as Jon describes, then that is closer to what you were originally trying to do anyway.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.