bs2 serial comm. specs needed
Unit042
Posts: 21
I have a Basic Stamp 2 Homework Board as part of the·what's a microcontroller kit, and I've gotten the idea that I could click something on the computer screen, and have something in real life move(idea simplified for ease of communication brevity's sake).
It's a very nice microcontroller, but my manual (to my knowledge,·the forum also)·does not cover what I am trying to find out: what the specs for the serial communication of the bs2 are·and what commands will accomplish it.
Will debug and debugin work? If they produce standard serial communication, does it have a "stop bit", what baud is it, etc.?
The links as to what I'm doing, see:
http://www.communitymx.com/content/article.cfm?page=2&cid=8658A
http://www.instructables.com/id/Control-real-world-devices-with-your-PC/
(more links·can be given, for example, the perl tutorial I'm reading to be able to·use the serial port program·at the first link)
Generally, instead of visual basic interfacing with a picaxe, I want perl (on the computer)·interfacing to bs2.
I could use my picaxe (visual basic failed to install on my yucky vista OS), but I was hoping that the bs2 would use it's programming port or other easy pin interface for standard serial communication so that I would not have to change wiring so much (program mode Vs. serial operation mode).
If this has been talked about already, please point me toward it, as I have already tried searching this forum.
Any suggestions? If anyone wants, I can give much,· much more detail as to what I'm attempting.
It's a very nice microcontroller, but my manual (to my knowledge,·the forum also)·does not cover what I am trying to find out: what the specs for the serial communication of the bs2 are·and what commands will accomplish it.
Will debug and debugin work? If they produce standard serial communication, does it have a "stop bit", what baud is it, etc.?
The links as to what I'm doing, see:
http://www.communitymx.com/content/article.cfm?page=2&cid=8658A
http://www.instructables.com/id/Control-real-world-devices-with-your-PC/
(more links·can be given, for example, the perl tutorial I'm reading to be able to·use the serial port program·at the first link)
Generally, instead of visual basic interfacing with a picaxe, I want perl (on the computer)·interfacing to bs2.
I could use my picaxe (visual basic failed to install on my yucky vista OS), but I was hoping that the bs2 would use it's programming port or other easy pin interface for standard serial communication so that I would not have to change wiring so much (program mode Vs. serial operation mode).
If this has been talked about already, please point me toward it, as I have already tried searching this forum.
Any suggestions? If anyone wants, I can give much,· much more detail as to what I'm attempting.
Comments
Please use black text. The color you chose is very hard to read. It's a nice color, but not for significant amounts of text.
From what I gather...
DEBUG and DEBUGIN send/receive serial data (through the programming port) to the programmer terminal, but this data is not standard serial comm that can be used by another program on the computer.
SERIN and SEROUT are piaxe commands that send/receive serial data through user specified pins.
I could not find where my "What's a Microcontroller?" book mentioned SERIN or SEROUT. The Index and Table of Contents fail me.
I hate to be a burden, but as you seem to know what you're talking about, could you point me to an online "dictionary" of PBASIC commands? I have the awfullest time navigating this site, what with all the huge banners trumpeting the Propeller et cetera.
SERIN and SEROUT can target "16" (as in " SEROUT 16, [noparse][[/noparse]"Hi", CR] ") which will send stuff out the programming port using the built-in RS-232 level shifting transistors on the BS2.
I understand this isn't obvious from the documentation.
There are chapters on each of the statements like SERIN and SEROUT.
DEBUG and DEBUGIN do handle standard serial comm, but they are specific for the programming port and the Baud used by the Stamp Editor for its debug window. They have special syntax to show the names of variables in addition to the usual "formatters" provided by SEROUT and SERIN.
I'm downloading it (software guide or another for PBASIC version 1, 2, 2.5) now.
While I wait (dialup), you say that DEBUG is essentially just an easy, canned function that's essentially a serial output string that can allow the computer program to get the variable name too? Not sure what you meant by formatters, but I guess it's what determines the baud rate and other stuff.
(I just figured out what the formatting means: text shifting around by use of CR, CLS, and whatever the newline command was.)
...aha! Page 169:
On all the BS2 models, DEBUG is actually a special case of the SEROUT
instruction. It is set for inverted (RS-232-compatible) serial output through
the programming connector (the SOUT pin) at 9600 baud, no parity, 8 data
bits, and 1 stop bit. For example,
DEBUG "Hello"
is exactly like:
' {$STAMP BS2}
SEROUT 16, $4054, [noparse][[/noparse]"Hello"]
//What's with the $4054? I guess I'll have to read on.
Page 172 has more info on the debugin.
Thank you muchly for your help, I will have to do a bunch of reading as to how I'll get the computer to coperate with the BS2. I could use SEROUT to give just the facts, and DEBUGIN to receive a string of numbers/characters....
Now the information digesting begins!
I'm just going to have this printed up so I can read it easier.
$4054 is the baud setting in HEX ( 16468 in decimal ). There is a baud mode table in the Basic Stamp Syntax & Reference Manual on page 419; you can reference to get the actual speed so you can set up any other application.
Hope this helps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Joshua Donelson
www.parallax.com
I'll have to go change it.
(If it's too bloody, I have a few alternate ones I can switch to)
EDIT: I've also looked at the IDE's dictionary. Thanks for the tip!
Post Edited (Unit042) : 10/29/2008 4:46:57 PM GMT
Now, lemme see... will the following work?
' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM4}
'pin 0 has an LED on it. Computer sends a 0 or 1 @9600 baud·to set LED state.
'myvar VAR Byte 'Variable used for storing serial data
DO
· redo:
··SERIN 16, 84, [noparse][[/noparse]DEC myvar]
··· IF myvar = 0 THEN
··· LOW 0
··· ENDIF
··· IF·myvar = 1 THEN
··· HIGH·0
··· ENDIF
LOOP
darn coloring is giving me trouble....
EDIT: I hooked my BS2 and it didn't work. I don't know if it was my computer's software, the BS2, or what. So many links in the chain that could be wrong. Maybe if I had a program that is already proven to work with the serial port....
Then, once the BS2 is running, then I can switch to the computer.
Suggestions?
Post Edited (Unit042) : 10/30/2008 3:48:24 AM GMT
Personally, when testing RS-232 links, I tend to use:
MAIN:
SEROUT 16, 16864, [noparse][[/noparse]"Hi", CR]
PAUSE 1000
GOTO MAIN
This has several benefits. First, it's really short, so hard to get wrong. I used to leave out the "PAUSE", but then "Hi" goes screaming down the screen. Next, it doesn't depend on ANYTHING going right on the PC, it just keeps putting out "Hi" once a second. This gives you LOTS of time on the PC to figure things out. And it will work with a "terminal" on the PC, so you can debug the hardware interface using known-good PC software.
Oh, I assume you're using the BOE board -- it properly 'decouples' the DTR/ATN/RESET signal so the BS2 can run.
I'm not sure about the "Homework" board -- you may have to set DTREnable = FALSE for it to work there.
bestinc.org
also, I just now finished posting this:
http://tech.groups.yahoo.com/group/bestinc/message/376
I'm conqueor042.
Anyway, that serial send every second is genius!
NO, I don't have a BOE, wish I did, though.
DTREnable... lemme check the IDE help file...
Not there!
I'll check the software guide pdf...
using adobe's pdf text searching feature, it's not there!
Sorry about the dumb question, but:
What is DTREnable, and is it compatible with BS2?
Basically, any program you run on the PC side (Hyperterm, a Java program, a C++ program) will need to 'disable' the DTR signal so the BS2 program can run. On the BOE, there's a couple of capacitors on this signal, so holding it 'high' from the PC side will just generate one reset and let the program continue. Every time you close and reopen the port from the PC side, it'll reset the BS2, though.
Do I need to worry about re-enabling DTR or else the BS2 won't receive new programs?
Sorry to be rude, but COM ports try my patience: do I have to worry about DTREnable yes/no?
cin.get(DTREnable);
If(DTREnable_worry == yes){
How-do-I-make-it-a-nonissue?(); //SOS! I'm dreaming in code!
Mental_state = insane;
}else{
Mental_state = yay * woohoo("Happy days!" /n);
}
2. More complicated answer: What are you using on the PC side to open the serial port?
Don't worry, I'll try to get it under computer control, but first, the mechanical base/RC system!
btw, my team's robot got 4th place in Music City BEST. Darn good considering we were against an army of noob's and three (huge) magnet schools with infinite rescources, and my team was just a small (15 people) homeschool group. We can do better than other fair players, but the daddy-bots (that daddy built for the kids) always stayed two (short) steps ahead of us.
No regionals for us, but we learned quite a bit, and made friends. That counts, right?
http://www.aaroncake.net/circuits/crombuld.asp
You guys think it's workable? BS2 out/inputting to the parallel port?
The "big" one is a new one running vista(uncapitalised on purpose) with all USB. I've used it (and a USB to serial converter) to program my BS2 and a Picaxe or two, so I know that my serial converter is fully compatible.
The "small" computer runs 95 (or was it 98?), has 2 USB, one serial, two PS2(keyboard and mouse are using those), and one parallel port.
I figure that I could do the parallel port because it seems easier, then I move on to serial; that way, I'd be putting that unused port to good use. I dream of making my own laser printer. Not ones that use toner, but use the laser to burn the paper. First I'll do ascii text, then move on to maybe pictures. Why? Ink is more expensive than the printer itself, and not being able to print even simple text is quite a handicap, as my family of 5 must be at the one computer if they wish to view/edit text documents while doing internet research papers and whatnot etc. etc. I'm ranting so I'll take a break for my finger's sake.
Just a thought. Don't let me discourage you too much.
Where?---I want one!