com1
leshea2
Posts: 83
Can I get the basic stamp to send and receive data to and from my computer's com port, and if so, would I use the serin, serout commands or some other commands ?
Thanks !
Thanks !
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Sio·····CON·····16
... then in your program:
· SEROUT Sio, Baud, [noparse][[/noparse]"Here is a string!"]
Baud is also a constant that is appopriate for your Stamp module and baud rate, and must be set to Inverted mode.· I have posted on setting baudmode dozens of times through our forums.· And yes, you can use the programming port (pin 16) to "talk" with other programs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
' {$STAMP BS2sx}
' {$PBASIC 2.5}
YMTU VAR Word
GJH VAR Word
TGM DATA "God Bless The World !", 0
Main:
YMTU = TGM
GOSUB Main2
END
Main2:
PAUSE 20
READ YMTU, GJH
YMTU = YMTU + 1
IF (GJH = 0) THEN GOTO Main ELSE SEROUT 16, 9600, [noparse][[/noparse]GJH]
GOTO Main2
Is there anything wrong with it ?
Thanks !
Your program does exactly what I suggest it shouldn't -- it embeds "magic numbers" (numeric constants) in the operational code.· You might want to have a look at our document The Elements of PBASIC Style, and then study the online help file for any of the instructions you think you'll want to use (there's a lot of stuff in our manual, the answers are there).
In the·meantime I've·rewritten your program following our suggested style guidelines and conforming to PBASIC 2.5.·I will ask just one thing: you actually study the code, and don't post anything else that you haven't tested in your editor.· ·You ask if anything is wrong with your program and the editor would have complained and directed you right to the offending code.·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
(Or, you could just use the attachment Jon gave you above.)
Post Edited (PJ Allen) : 2/8/2006 9:01:26 PM GMT
·· RTS and CTS would be the lines used for flow control.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
· With SEROUT, Fpin is made an input.· Someone will have to determine whether "the program" has an output that the STAMP can use as a cue for its transmission to begin.
The advice you gave is valid if you're using a modem, but not on the '16' port of the BS2.
So, Leshea2, the simple answer to your problem is to have the BS2 wait on a SERIN when it comes up.
The PC then sends something to the BS2, to tell it it's ready for data.
The BS2 then sends the desired string to the PC.
That's how you get the synchronization you're looking for, without requiring extra wires or hardware.
I'm aware the person is using the STAMP programming connector and..... (slow burn)..... far be it for the likes of me, but.....
I have nothing further.
The reason it works when you run the PC program first is because the PC program is waiting before the BS2 starts sending, so it catches the whole string. When you start the BS2 first, it has already sent some characters when the PC program begins looking for input, and it misses the first characters.
You can use hardware control to sync it up, but you can also mess around with the transmit and receive timings on both sides of the serial cable (meaning on the PC & BS2). BTW, what language / IDE are you creating your PC program with?
Please, don't stop now, I'm still laughing about the Darth Vader thread........
·· Let me clarify the whole flow control thing.· There will be none on the programming port.· Asserting DTR there will serve to simply reset the BASIC Stamp.· RTS and CTS and not implemented in a flow-control fashion on this port.· RTS is looped to DSR, not CTS.
·· When using standard I/O pins for serial interface there are options for implementing flow control using RTS/CTS but no provision for implementing DTR/DSR, which basically says, "Hey I'm here and ready to do business."· The basic RTS/CTS flow control system is all that's needed to dramatically increase the reliability of serial communication on the BASIC Stamp side when talking to devices that support it since the BASIC Stamp is no longer required to be right there waiting when the other device wants to send data.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I'm sorry, I don't quite follow your last post. Is this correct?
The programming port does not support flow control. I can use neither RTS/CTS nor DTR/DSR.·Asserting DTR will reset the stamp.
If I were to use another serial port (ie not the programming port), I would be able to use RTS/CTS, but I still not be able to use DTR/DSR.
Thanks!
Cindy
Everything you say IS CORRECT. You will need to assign an additional pin for use as the flow control pin. See the PBASIC Manual or the PBASIC Help File for additional information.
RTS/CTS should be all you need to establish flow control. In other words, there should be no need for DTR/DSR.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->