Basic Stamp serial communication

We are trying to use a BASIC Stamp 2 px (BS2px) to preprocess Sonar data. I am not very familiar with stamps, but it is what we had on hand and interfaces well with the sonar units. So, making the Stamp and the RC talk to each other is stumping us. Using a TTL to serial adapter, we were able to make the RC send data to the stamp, but were unable to read a response. It is wired correctly, both are at the same Baud, and the code (which I do not have on hand at this moment to post, but will be happy to retrieve when I can) seems correct, at least on the C side of things.

I read somewhere that the BS2px relies on the device it is communicating with to provide the normally high voltage on the serial communication pin. Does the TTL board satisfy this? If not, would using a BS2 project board with a serial port, and connect it to the program port on the RC work? Thanks for any help. I am sorry if this post was hard to follow, you know how the day before ship is. :rolleyes:

Could you show the wiring diagram you are using? Are you using separate RX and TX . Are you using a Handshaking line? Or are you running two wire Asynchronous?
I’ve done stamp to stamp serial communication and it is indeed TTL There are examples in the programming manual that I know work. If you can plug into the TTL serial port you can probably get the communication you’re looking for. However, I must emphasize that I have never done this to an RC before.
Oh an after thought, what does the Stamp program look like?

There is a separate RX and TX, but no handshaking line. Here is a crude diagram:

Since the communication is asynchronous, the stamp waits for a signal from the RC before sending the sonar data. I can’t get the actual program until I can get to the school, but it was essentially this:
'Code that makes variables
'Code that gets data from sonar
'Code that converts it to centimeters

SERIN 13, 240, [ack]
IF ack THEN
SEROUT 12, 240, [sonarData]
ack = 0
ENDIF

A question, if the BS2 is TTL, can I skip the serial/TTL converter completely and connect it directly to the TTL port on the RC? If so, can you point me to some TTL examples?

I don’t have a manual… we got the BS2 second hand.

The HELP section of the Stamp editor program has a built in manual and you can access the example drawing at the end of the SERIN or SEROUT command explanations. They mention that to protect the stamp from the higher RS232 voltage levels you need a 22K ohm resistor to limit current. I don’t see that on your diagram but the stamps are pretty robust. I’d add if you continue to use RS232 but I believe you can just go straight TTL.
According to page 11 of the RC reference guide the port2 is TTL but since IFI FIRST doesn’t support the using the serial ports there are no examples. Anyway, my read on port 2 is that you don’t need a serial converter and should be able to connect directly to the RC controller.
The example for the stamp shows a pulldown resistor. This implies some kind of open drain output and may be a problem in your setup.
I have a stamp laying around here. I may set this up and see if I can get a stamp and the RC to talk later.

Thanks a lot, I will look into the diagrams.

Just remembered. Would I have to use different commands on the BS2 side of the communication, or would SERIN, SEROUT still work?

On the stamp side you just use SEROUT and SERIN. I’ve been looking at some of the other posts on using the ttl port. If you are not using the Kevin Watson code I suggest you try sending a single byte from the BS2.
Are you shipping the stamp today? I found my stamp but I need to redo the board I was using. I was testing something else last time I used it. I’ll still have a an RC system so I can work on the communication setup but that might be too late to help you.

Steve

We are using Kevin Watson’s code, and we have a stamp to work with and a spare RC. Sadly, we won’t have access until next week. Thanks for your help though.