Shop OBEX P1 Docs P2 Docs Learn Events
Basic Samp/PSC communication Problem — Parallax Forums

Basic Samp/PSC communication Problem

kennetkennet Posts: 33
edited 2008-07-08 20:24 in BASIC Stamp
I have one BS2p24/PSC running a program and would like to use a BS2p40 to control this setup in a Master/Slave combination. I want the BS2p40 to send serial commands to the program running· the BS2p24· not the PSC·.
Anyone·know how I can do this?

Thanks
Ken·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-08 14:08
    Yes. There are many ways to do this. It depends on the details of the interaction. Basically, the BS2p40 has to send the necessary data to the BS2p24, then the BS2p24 turns around and sends the commands to the PSC. One example:

    This uses two I/O lines. You put 330 Ohm resistors in series between the two Stamp's I/O pins to protect them from programming mistakes.
    There is a 10K pulldown on one lead on the BS2p24 end (pin X) and a 10K pulldown on the other lead on the BS2p40 end (pin Y).

    When the BS2p40 wishes to send, it does a HIGH X. From time to time, the BS2p24 checks its X pin for a HIGH. When true, it does a HIGH Y and then waits at a SERIN X for a response, then does an INPUT Y. The BS2p40 (after it does the HIGH X) waits for the Y pin to go HIGH. When true, it uses up maybe 100us, then does a SEROUT, then INPUT X. There needs to be a short (maybe 100us) delay after all this for things to finish up before doing it again.

    In this example, the format of the data has nothing to do with the PSC commands. It consists of 3 bytes. The first is the servo number and the next two bytes contains the servo pulse width.
  • kenwtnkenwtn Posts: 250
    edited 2008-07-08 14:27
    · Here is a sample of code I use and works real well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Keep buying replacement parts and sooner or later you will get it RIGHT!
  • kennetkennet Posts: 33
    edited 2008-07-08 20:24
    Mike what can I say. Brilliant! Brilliant! As usual that was an Excellent explanation!

    And Kenwtn,your right on time.Thanks for the code samples.You rule!

    Thanks Fellas

    Ken
Sign In or Register to comment.