View Full Version : Serial Help

06-02-2005, 10:10 AM
I am having some trouble trying to use the SERIN and SEROUT commands properly. I am attempting to write program to act as a go between from the CMUcamGUI program on my computer and the CMUcam1 mounted on my boe bot. I've written a test program to see what the java based CMUcamGUI is outputting. My code is as follows:

SERIN 16, 84, [STR result\4] 'here I am using an stringarray with 4 bytes because the java prog is sending "rs/r"
FREQOUT 4, 2000, 3000 'since both the CMUcamGUI and my Stamp Editor Debug window use COM1
PAUSE 10000 'I've added these 3 lines of code to give me time to close the java app after it sends the "rs/r"
FREQOUT 4, 2000, 3000 'command and open the debug window to view what it caught.
DEBUG STR result 'this should output the string "rs/r" SHOULD is the key word here, heh

when I run the program as I described in the 'comments, all I get back is a weird character that looks kinda like a y with umlots over it (you know, the two dots you sometimes see over U and A and other characters in other languages. Any help here would be much appreciated. Been trying to puzzle this out for a while so I can get this program working with the bot/cam.

Jon Williams
06-02-2005, 11:11 AM
Embedding baudmode constants always causes errors; in my standard template the baud values for popular rates are built in and conditional compilation takes care of selecting the right one based on the module I'm using. In the end, I don't ever have to worry about it. My template is attached.

And when you're using the programming port (pin 16), you need to invert the data (a constant for that is built into the template too).

Jon Williams
Applications Engineer, Parallax

Chris Savage
06-02-2005, 11:13 AM

There are no string variables on the BASIC Stamp. You would need to use an array and deal with the characters one at a time.

Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)

06-02-2005, 11:37 AM
well, I've messed around a bit more, but still not having much luck, here's the incarnation of code I am using to try and see what the java app is spitting out to me (it should be rs/r that I recieve as the reset command for the CMUcam1, but just getting those weird y's with umlots). I changed the 84 to 19468 to account for the invert on pin 16 (SIN)(thanks btw). I am trying a array to handle things as Chris suggested, but.... :( Any ideas? Thanks again for your time!

' {$STAMP BS2}
' {$PBASIC 2.5}
counter VAR Byte
result VAR Byte
dataResult VAR Byte(4)
counter = 0
dataResult = 0

SERIN 16, 16468, 10000, NODATA, [result]
dataResult(counter) = result
counter = counter + 1

FREQOUT 4, 2000, 3000
FOR counter = counter TO 0
DEBUG CRSRXY, counter, 0, dataResult(counter) , CR

06-03-2005, 08:54 AM
OK, I know this is probubly really wrong, but I'm posting it so perhaps someone can see what I am trying to do and correct me. Here's my code block:
catch VAR Byte
SERIN 16, 16468, [catch] 'catching incoming byte sent from PC
SEROUT 7, 84, [catch] 'Send caught byte to AppMod CMUcam1
SERIN 9, 84, [catch] 'catch AppMod CMUcam1's response
SEROUT 16, 16468, [catch] 'send AppMod CMUcam1's response to PC Serial Port

Any help will be greatly appreciated. Thanks!!