Basicstamp connectet to comport (receiving data)
Iguan
Posts: 8
Hello
I've got a Basic Stamp 2e and a Board of Education.
Now, I would like to receiving data on Hyperterminal.
I connected Pin 5 (GND) of my comport to VSS on my Education Board and
Pin 2 (RxD of com) is directly connectet to my I/O Pin 0. (I tried with a 22k resistor as well)
My simple program looks like this:
Main:
DO
·· SEROUT 0, 9600, [noparse][[/noparse]"Hello!", CR]
·· PAUSE 500
LOOP
END
But I don't receive any characters
Hyperterminal is set to 9600,8,N,1· Flow Control: None (i tried different settings)
whats wrong?
please help me!!
Best wishes
Iguan
I've got a Basic Stamp 2e and a Board of Education.
Now, I would like to receiving data on Hyperterminal.
I connected Pin 5 (GND) of my comport to VSS on my Education Board and
Pin 2 (RxD of com) is directly connectet to my I/O Pin 0. (I tried with a 22k resistor as well)
My simple program looks like this:
Main:
DO
·· SEROUT 0, 9600, [noparse][[/noparse]"Hello!", CR]
·· PAUSE 500
LOOP
END
But I don't receive any characters
Hyperterminal is set to 9600,8,N,1· Flow Control: None (i tried different settings)
whats wrong?
please help me!!
Best wishes
Iguan
Comments
You need the 22K resistor if your comport provides an RS232 signal. You can damage the Stamp if you directly connect an I/O pin to an RS232 signal.
My new code is:
' SERIN_SEROUT1.bs2
' Using two BS2-IC's, connect the circuit shown in the SERIN command
' description and run this program on the BASIC Stamp designated as the
' Sender. This program demonstrates the use of Flow Control (FPin).
' Without flow control, the sender would transmit the whole word "Hello!"
' in about 1.5 ms. The receiver would catch the first byte at most; by the
' time it got back from the first 1-second PAUSE, the rest of the data
' would be long gone. With flow control, communication is flawless since
' the sender waits for the receiver to catch up.
' {$STAMP BS2e}
' {$PBASIC 2.5}
SO PIN 0 ' serial output
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T1200 CON 813
T2400 CON 396
T9600 CON 84
T19K2 CON 32
T38K4 CON 6
#CASE BS2SX, BS2P
T1200 CON 2063
T2400 CON 1021
T9600 CON 240
T19K2 CON 110
T38K4 CON 45
#CASE BS2PX
T1200 CON 3313
T2400 CON 1646
T9600 CON 396
T19K2 CON 188
T38K4 CON 84
#ENDSELECT
Inverted CON $4000
Open CON $8000
Baud CON T9600 + Inverted
Main:
DO
SEROUT SO, Baud, [noparse][[/noparse]"Hello!", CR] ' send the greeting
PAUSE 500 ' wait 2.5 seconds
LOOP ' repeat forever
END
I tried it and the Hyperterminal showed "Hello!". But only without the resistor. And as soon as i disconnect the USB from my
Education board. The Hyperterminal says nothing ;-(
Do you know the reason?
the Pin 5 of the pc-comport is connected to the GND of the Board of Education and Pin2 (pc-comport) is connected to I/O-Pin 0 (On the Board of Education as well).
The word "Hello!" appears on the Hyperterminal with that setting (without the resistor). As soon as i disconnect the programming cable (USB). The Hyperterminal doesn't show anything.
If the USB to serial adapter provides an RS232 signal, it can damage the Stamp without the 22K resistor. If it provides a +5V logic signal, then you should be ok.
What kind of USB to serial adapter are you using?
Then, you're trying to use "pin zero" to talk from the BS2 to the PC.
You CAN talk to the PC through the USB connection with "SEROUT 16, BAUD, [noparse][[/noparse]"Hello!",CR]"
Usually to talk from a 'generic' I/O pin (like Pin zero) you need a MAX232 driver. It sounds like your PC is able to recieve a 0 to 5 volt signal and properly recieve it. If you connect the PC's TX signal to the BS2, you'll definitely need the 22 Kohm resistor. Signals going in the OTHER direction (from the BS2 TO the PC) don't need the resistor.
thats correct
>>Then, you're trying to use "pin zero" to talk from the BS2 to the PC.
Thats also correct, it doesn't matter for me which pin...
>>You CAN talk to the PC through the USB connection with "SEROUT 16, BAUD, [noparse][[/noparse]"Hello!",CR]"
I would like to talk to the PC without USB (because i wrote a PC-program which can read comport charakters...)
>>Usually to talk from a 'generic' I/O pin (like Pin zero) you need a MAX232 driver. It sounds like your PC is able to recieve a 0
what do you mean with "generic I/O pin"? is Pin 0 a special case? ( i also tried with other I/O's but it doesn't work )
I don't understand.. you mean, its not possible to talk to the PC whitout additional electronics?
>>to 5 volt signal and properly recieve it. If you connect the PC's TX signal to the BS2, you'll definitely need the 22 Kohm >>resistor. Signals going in the OTHER direction (from the BS2 TO the PC) don't need the resistor.
OK, I gonna use a resistor, but first I'd like to fix that problem in the OTHER direction (without resister)(BS2 to PC)
And the phrase "generic I/O pin like pin zero" means that pin zero is 'generic' like all I/O pins on the BS2 from 0 to 15. That "16" in "SEROUT 16, ..." is a 'pseudo-pin' meaning to the BS2 "Use the programming I/O port pins".
Signal direction is very important in RS-232 communications. Your BS2 can 'talk' out pin zero to the PC's serial port RxD pin without a resistor. But if you connected your PC's TxD pin directly to a BS2 pin it would burn out the BS2's pin -- so in that direction (the PC 'talking' to the BS2) you MUST have the 22 Kohm resistor in series.
>>The USB connection looks to the PC like it IS a "comport", so I'm still not sure why you're not using "SEROUT 16, ... "
Because, at the end, i dont wanna use the Board of Education for that project.. (i wanna use that board only for testing)
On top of that, im not sure, if my own written PC-program would work with that "virtual comport" and anyway, i dont have enough USB-Ports on my Notebook. My aim is to build a Notebook controlled robot (the BS2 is only for reading sensor data and sending it to the notebook)
>>Signal direction is very important in RS-232 communications. Your BS2 can 'talk' out pin zero to the PC's serial port RxD pin without a resistor. But if you connected your PC's TxD pin directly to a BS2 pin it would burn out the BS2's pin -- so in that direction (the PC 'talking' to >>the BS2) you MUST have the 22 Kohm resistor in series.
OK, I promise you, I gonna do that
I just wanted to know, if it is possible without adittional electronics, that the BS2 speaks to my PC via Comport (not the USB programming cable! (not the "virtual comport")
Post Edit -- You must use Inverted Baudmodes.
SEROUT 0, 16468, [noparse][[/noparse]"hello!", CR]
sends "hello!" out on P0, 9600 8N1.
Post Edited (PJ Allen) : 10/18/2009 3:08:36 PM GMT
The baud was wrong... i used:
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T1200 CON 813
T2400 CON 396
T9600 CON 84
T19K2 CON 32
T38K4 CON 6
#CASE BS2SX, BS2P
T1200 CON 2063
T2400 CON 1021
T9600 CON 240
T19K2 CON 110
T38K4 CON 45
#CASE BS2PX
T1200 CON 3313
T2400 CON 1646
T9600 CON 396
T19K2 CON 188
T38K4 CON 84
#ENDSELECT
Inverted CON $4000
Open CON $8000
Baud CON T9600 + Inverted
On the subject:
Serout 16 or Debug ? any real difference? which one is more efficient?
The case is that I'll have a VB code read the incoming info. But don't care really if I miss the incoming data. The code will catch it eventually.
Cheers,
Yosh
The SEROUT Formatters (like STR) are slightly different.
SEROUT lets you use different pins if you want to, DEBUG is 'fixed' to port 16.
For all these reasons, I prefer SEROUT 16.