Shop OBEX P1 Docs P2 Docs Learn Events
Multiple serial controlled devices? — Parallax Forums

Multiple serial controlled devices?

joe from NYjoe from NY Posts: 22
edited 2006-08-14 19:39 in BASIC Stamp
Hi, Is it possible to control multiple serial devices?
(such as a LCD mod and Text to speech mod)

If so, how is this accomplished?

Thanks Joe

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-12-16 17:35
    Yes, and with some devices they can share a common serial line (though not the ones you mention). The great thing about the BASIC Stamp is that it can send a serial message on any of its I/O pins, so you simply need to insert the appropriate SEROUT instructions. We have some products that conform to our "AppMod" protocol which allows mutliple devices to exist on the same serial buss. Before you connect things together, do make sure that their serial modes are compatible and you can communicate without data collisions. As I pointed out, LCDs and the Text-to-Speech module are not buss compatible, and should be devoted to their own pins.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • joe from NYjoe from NY Posts: 22
    edited 2005-12-16 18:49
    When you are referring to pins, you are refering to the general purpose data i/o·pins?


    Not the SIN an SOUT pins. Are the SIN/SOUT pins just for Programming and communication with the STAMP?

    Lastly can you link me to·more information on the APPMOD protocol?


    Thanks a bunch Joe
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-12-16 19:08
    The SIN and SOUT pins are indeed for programming, though you can also also use them for RS-232 level serial I/O with external terminal devices (DEBUG and DEBUGIN are just special versions of SEROUT and SERIN).· So you're right, you can't connect TTL serial devices to these pins.

    The AppMod protocol is very "loose" (we have no official documentation) and has just a couple important points:

    1) The baud mode most be set to Open True so that multiple devices can exist on the same buss without collision (the device must work in Open True mode as well)

    2) Each command is prefixed with a text header that always starts with "!" -- this is used for auto-baud calculation in some devices.· The Parallax Servo Controller, for example, starts its packets with "!SC" (for servo controller); the RC-4 relay board uses "!RC4".

    You can actually use a BASIC Stamp to create an AppMod protocol-compatible device.· Let's say you were going to use the header MSD (for My Special Device); your SERIN line would look like this:

    · SERIN Sio, Baud, [noparse][[/noparse]WAIT("!MSD"), address, command, dataByte]

    Everything after the WAIT section is dependent on your device.· Have a look at the PSC, RC-4, and AP-8 documentation to see how we've implemented various commands in our products.· If you want to do something commercial, you can also use the SX controller and write the code in SX/B (very close to PBASIC).· In fact, all of the EFX products (RC-4, AP-8, DC-16) use the SX and are programmed in high-level SX/B.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • InanesInanes Posts: 14
    edited 2006-08-08 06:20
    Jon Williams said...
    ...The great thing about the BASIC Stamp is that it can send a serial message on any of its I/O pins, so you simply need to insert the appropriate SEROUT instructions...
    ·· Hello everybody! John, on my BS2 I started using serout with the serial LCD from Parallax a couple of months ago. I used the pin4 and everything worked perfect.·I did not try to serout from different BS2 pin until I needed to. I tried to relocate the serout pin, as I thought it would work on any of the other pins. Changed the code and... nothing was being transmitted!!! I disconnected all sensors to avoid possible conflicts, but zero results! mad.gif

    ·· Then I started checking serout to LCD·from all BS2 pins; it worked only with pin2 and pin4!!! I suspected pins were damaged and tested all pins with output-low-high-low instructions to turn off-turn on leds. All BS2 pins work great with the leds!

    What is the matter with the serout command?·smhair.gif

    Thanks,
    Inanes

    Post Edited (Inanes) : 8/8/2006 7:58:29 AM GMT
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-08-08 14:12
    What's wrong? Probably nothing, usually this sort of thing comes from wiring errors.

    You did wire a ground to the LCD panel, right?

    And you did create a "CON" for the LCD_Pin, right?

    And you didn't inadvertently change the baud rate, or anything like that, right?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-08-08 14:12
    Hello,

    ·· Without seeing your code there isn't much we can offer.· Please post the code that does not work.· Thanks.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • InanesInanes Posts: 14
    edited 2006-08-09 06:01
    Thank you guys for your prompt responses! I attach the code I tested.

    allanlane5:

    - I did ground the LCD

    - I used a pin definition for the LCDpin rather than a con

    - I did change the baud rate but again, pins 2 and 4 worked perfect for baud 2400, all other pins failed.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    4th robot law: A robot may not substitute a human to satisfy another human, as long as such satisfaction does not conflict with the 1st, 2nd, and 3rd law.
    Inanes Pastas
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-08-09 14:16
    Well, "grounding the LCD" does not automatically mean you attached the BS2 ground (vss) to the LCD ground, but I'll assume you did so.

    Still sounds like a wiring error, though. Or, you've burned all pins except 2 and 4. This really shouldn't happen.
  • InanesInanes Posts: 14
    edited 2006-08-09 20:25
    Grounding is ok. If I accept that I 've burnt all pins except 2 and 4, shouldn't they fail to output current to turn on-off the leds I tested? I also put an output definition for LCDpin just to be extra sure, but in vain...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    4th robot law: A robot may not substitute a human to satisfy another human, as long as such satisfaction does not conflict with the 1st, 2nd, and 3rd law.
    Inanes Pastas
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-08-09 22:00
    Looking at your code I see a few problems...First you're using OPEN Baud Mode, when you should be using True Baud Mode.· Second, you're defining a pin but not initializing it HIGH as per our documentation.· Then you wait 13 seconds but need to wait only 100 ms or so.· Also you don't need such a big pause after the CLS, but you shouldn't have the CR on that line since the PAUSE 5 is required immediately after the CLS command is sent.

    [noparse][[/noparse]Edit - You aren't sending a CLS command, just the text, so you don't need the pause at all]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • InanesInanes Posts: 14
    edited 2006-08-10 05:25
    Thanks a lot Chris. I will retouch the code as you advised and have it tested again...

    (Later on...) Serout runs smooth in all pins now! The only thing I had to do was to remove the open mode from Baud definition. What a strange thing for pins 2 and four to work also for the open mode!!! Chris, why was that?


    Shall I put a resistor to transmit line for the true baud for protecting my LCDpin, and·is the HIGH LCDpin really necessary, since my code works without it as well (and SEROUT command defines by itself the transmit pin as an output)?

    These are·almost rhetorical questions·the main thing is my BS2 has left place for more serial devices now! Thanks to you pals!

    You have set a fantastic support site here! smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    4th robot law: A robot may not substitute a human to satisfy another human, as long as such satisfaction does not conflict with the 1st, 2nd, and 3rd law.
    Inanes Pastas


    Post Edited (Inanes) : 8/10/2006 4:34:28 PM GMT
  • InanesInanes Posts: 14
    edited 2006-08-14 19:39
    Hello guys, I returned here to remind you that only pins 2, 4 from my BS2 could send serout commands on open baudmodes, then, I switched to true baudemode and all pins could now use serout. I attached also a Nutchip to pins 10 and 11 apart from my serial LCD to pins 14 and 15.

    Then I wanted to run an RCtime command (to read photoresistors) on pin 4 but it returned zero and occasionaly some unstable values not related to the sensor. I tried also pin2 and neither it could read RC. The same was with pins 0 and 6. The odd pins (1, 3, 5, 7) worked ok. No wiring, and no grounding problems found, I just placed the sensor wire to different pins and programmed BS2. I LED tested the pins output and worked ok for all pins. I am afraid the pins input has been damaged. I attached the code I did the tests:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    sensor_left CON 3 'I/O control for the light sensor
    sensor_right CON 4 'I/O control for the light sensor
    left VAR Word 'Here is stored the time constant of the left photoresistor/RC-circuit
    right VAR Word 'Here is stored the time constant of the right photoresistor/RC-circuit
    HIGH sensor_left
    HIGH sensor_right
    PAUSE 3
    RCcommand:
    RCTIME sensor_left,1,left 'measure the light intensity on the left sensor
    HIGH sensor_left
    PAUSE 20
    RCTIME sensor_right,1,right 'measure the light intensity on the left sensor
    HIGH sensor_right
    PAUSE 20
    DEBUG ? left, ? right, CR
    PAUSE 1000
    GOTO RCcommand

    Is this a problem with the even pins input???

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    4th robot law: A robot may not substitute a human to satisfy another human, as long as such satisfaction does not conflict with the 1st, 2nd, and 3rd law.
    Inanes Pastas


    Post Edited (Inanes) : 8/14/2006 8:15:35 PM GMT
Sign In or Register to comment.