Shop OBEX P1 Docs P2 Docs Learn Events
Stamp to Robot communication — Parallax Forums

Stamp to Robot communication

Imad MansourImad Mansour Posts: 3
edited 2011-01-24 09:23 in BASIC Stamp
I'm new to the forum and new to PBasic. So please bear with me. We've built a small control box using a BS2p to act as an intermediary between two laboratory robotic devices (neither of which are manufactured by my company). The intent is for the control box to recieve input from machine 'A' (using digital I/O), and then issue a command string to machine 'B' via DB9/RS232 - (9600,8,N,1),. I've had intermittant success in getting it to work. The main problem has been on the machine 'B' side. I've reduced my program down to:

' {$STAMP BS2p}
' {$PBASIC 2.5}
Main:
'DEBUG " "
SEROUT 16, 240,["AM21",CR]
PAUSE 12000
GOTO Main

The twelve second pause is ample time for the device to complete its action. Upon turning on the controller, the command string is issued and machine B does its thing - sometimes. Sometimes, it will repeat when the loop comes around, but usually not. I've hooked up the control box to hyperterminal and watched as it successfully issued the command string every 12 seconds - so I know that it is getting out. I've hooked up machine B to hyperterminal and successfully sent the same command string to it many, many times. So I'm fairly certain that it is working properly. I played around with the PACE setting and at one point thought I had solved the problem when the above program successfully looped 10 times before I turned it off. However, upon turning it back on, it went back to it's original erratic behaviour. Very confusing. I don't know much about electronics, but is it possible that this may be due to an incorrect voltage swing on the serial port? If that doesn't make sense given the above information, are there any suggestions as to what might be going on, or where I should look?

Thank you in advance.
Imad

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-01-21 17:13
    You're using the programming port to connect to machine B and this port is not true RS232. The idle state (1) is set by the serial input signal from the DB9 connector while the active state (0) is +5V. Normally, the serial input signal idles at =5V, so the DB9 serial port kind of meets the minimal RS232 voltage requirements. If there's no serial input signal (it's not connected), the output signal will go from 0V to +5V only which may not be adequate for machine B's serial input.

    One way to fix this is to use a MAX232 attached to a regular I/O pin (0 to 15) to generate a "proper" RS232 signal. Another way would be to use a 6V battery to supply the negative voltage. A 4 AA cell battery pack would do with the positive lead connected to the DB9 ground pin and the negative lead connected to the DB9 receive pin. The current drain is small (about 250uA) and the batteries should last for thousands of hours.
  • Imad MansourImad Mansour Posts: 3
    edited 2011-01-21 18:33
    Mike, thank you for the quick reply and the excellent suggestions. I will discuss it with our engineer and see how it goes. Thanks again.
  • Imad MansourImad Mansour Posts: 3
    edited 2011-01-24 08:38
    Mike, we're about to wire up the battery to the serial port and wanted to ask if you could please confirm the wiring as shown below.
    Thank you.

    Untitled-2.jpg
    786 x 506 - 77K
  • Mike GreenMike Green Posts: 23,101
    edited 2011-01-24 09:23
    Your diagram looks correct.
Sign In or Register to comment.