PDA

View Full Version : pc to basic stamp serial communication



Colby
02-28-2005, 11:30 AM
Here is my situation, I have a basic stamp2, connected to a relay board that takes high and low signals to flip relays. That all works just fine. As of yesterday I have been trying to get the basic stamp to talk to my compter, so I will be able to trigger relays from my compter. I eventually got it working with the following code on my basic stamp useing the debug window to transfer data:




'{STAMP BS2}
choice VAR Byte

DO
SERIN 16, 16468, [choice]
TOGGLE CHOICE
LOOP




I then tried to get this working on my linux box by doing "echo <relaynumber> >> /dev/ttyS0". This would only work after I ran bstamp_run to upload code to the basic stamp. Im assuming when I run that program it changes some serial port settings allowing it to work. So I guess my first question is can anyone tell me how to ajust my serial port settings in linux to get this to work? I cant find any recources online that seem to deal with my issue. Just to try to see if maby it had something to do with the default serial pin (number 16, which i guess is really pin 2) I hooked up a spare serial cable with pin 2 (recieve) hooked into pin 10 on the basic stamp, and serial pin 5 (ground) into ground. And tried SERIN 10, 16468, [choice]. This does not work at all? Am I totally missing something here?

So, I guess im wondering if:

1. Has anyone had any success with serial communication and the basic stamp on linux? And how did you get it working right?
2.How can I attach another serial port to the basic stamp, so I am not limited to the default code uploading / debug port.

My ultimate goal is to be able to have a serial link to a mini-itx board for a more advanced robot. If anyone can help me out with anything it would be greatly appriciated.

Colby

allanlane5
02-28-2005, 11:47 AM
You must keep DTR 'inactive' or it will hold the stamp in RESET (unless you are using the BOE).

You can use a MAX232 chip, with 4 capacitors, to provide you with RS-232 drivers. Pin 2 and 3 have RS-232 drivers built in. Also, note that you MUST hook up Transmit AND Recieve if you want to recieve from the Stamp's built-in port -- the Stamp uses the Transmit line to power the Recieve signal back to your PC.

Colby
02-28-2005, 11:55 AM
Hi,

Thanks for the reply, but I am a little confused on what you said. "Pin 2 and 3 have RS-232 drivers built in." You are refering to the pins on the basic stamp correct? meaning that I do not have to use a max232 chip to connect a serial line into pins 2 or 3 on the basic stamp? And so I have to use a max232 chip if I wish to include serial on any other of the basic stamps inputs? Sorry for all the questions but im totally lost when it comes to serial communication.

Colby

Pinoy NYC
03-01-2005, 05:05 AM
I got confused too... but I think he is referring to same logical pin16,
it is the physical pin 2 and 3 of bs2.

Read Jon's post
http://forums.parallax.com/forums/default.aspx?f=5&m=64985

Jon Williams
03-01-2005, 05:13 AM
Actually, the physical pins are 1 (SOUT) and 2 (SIN). When using them with SERIN/SEROUT, however, they are both called 16. See the end of the DEBUG command for a SEROUT example that uses pin 16.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA