BS2SX and QBasic?
romshark
Posts: 14
Greetings.
I'm trying to get QBasic to send data to my Basic Stamp 2SX. I want to send numbers to the stamp, which it will then write to a Parallax Stampmem.
I have the program set up and it works within the Stamp Editor Debug window (I have it writing to an LCD for now to make sure the numbers are being read correctly.) However, I can't make it work with QBasic. Can anyone help me out?
here's what I have for the QBasic test side (most likely where my problem is)
FOR y = 1 TO 7
READ x
a$ = INPUT$(1)
PRINT x, ", ",
PRINT #1, CHR$(x)
NEXT y
DATA 20, 96, 21, 110, 22, 88, 23, 5, 185, 8, 131, 8, 141, 8
and this is my 2SX side (skipping declarations)
start:
DEBUGIN incoming
SEROUT LCDp,baud,[noparse][[/noparse]254,1]
SEROUT LCDp,baud,[noparse][[/noparse]DEC incoming]
GOTO start
Thanks for reading.
I'm trying to get QBasic to send data to my Basic Stamp 2SX. I want to send numbers to the stamp, which it will then write to a Parallax Stampmem.
I have the program set up and it works within the Stamp Editor Debug window (I have it writing to an LCD for now to make sure the numbers are being read correctly.) However, I can't make it work with QBasic. Can anyone help me out?
here's what I have for the QBasic test side (most likely where my problem is)
FOR y = 1 TO 7
READ x
a$ = INPUT$(1)
PRINT x, ", ",
PRINT #1, CHR$(x)
NEXT y
DATA 20, 96, 21, 110, 22, 88, 23, 5, 185, 8, 131, 8, 141, 8
and this is my 2SX side (skipping declarations)
start:
DEBUGIN incoming
SEROUT LCDp,baud,[noparse][[/noparse]254,1]
SEROUT LCDp,baud,[noparse][[/noparse]DEC incoming]
GOTO start
Thanks for reading.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
OPEN "com1:9600,n,8,1,cd0,cs0,ds0" FOR output AS #1
Com port 1, 9600 baud, no parity, 8 data bits, 1 stop bit, timeouts disabled.
I think that's right. I'm not to sure about stop bits, but the only other coices are 1.5 and 2
Right now, I do have some flow control in my test program. a$=input$(1), which pauses the program until I press a key.
In the final product, I plan to have the stamp write the number to the Stampmem, then send·the number back to the computer. Once my PC gets the number, it'll send out the next.
·· Why do you have the line "a$ = INPUT$(1)" in your QBASIC program?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Here it's just temporary, so I can send numbers one at a time at my discretion. It'll be different in later versions.
Post Edited (romshark) : 6/11/2005 2:41:16 AM GMT
·· I knew what it did, I just wondered why you put it there...It might be best to actually attach your code so we can verify everything.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
The LCD is set up for a BPI-216 from Scott Edwards Electronics. That's also where I got the coding for talking with anything using the serial port (the paperwork for the LCD came with examples for controlling it using QBasic, and I've gotten that to work.) Talking with the stamp itself is proving more difficult.
I did find a page about communicating between the stamp and PC, but it didn't work either.
http://home.pacifier.com/~mcginty/qbstamp.htm
Yes, I did change the baudrates to 2SX as needed.
Hopefully we can figure this out.
Oh, and in the Qbasic program, I have tried sending the numbers both with and without the CHR$ .
Post Edited (romshark) : 6/11/2005 1:09:36 PM GMT
I suspect you want to read the serial input from the programming port, and not from the DEBUG terminal. Presuming that to be the case, you want to remove the DEBUGIN statement and replace it with a SERIN (with the appropriate parameters) from Pin Port 16 (the programming port).
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Is the line I'm using in my QBasic program correct?
OPEN "com1:9600,n,8,1,cd0,cs0,ds0" FOR output AS #1
That's correct for the LCD, but does the stamp have different settings? Is one supposed to have something inverted? I think I read that PC communications are inverted.
Post Edited (romshark) : 6/11/2005 3:49:06 PM GMT
I tried hyperterminal, and it didn't work either. I then decided to try and use by 2SX with my carrier board (I've got one 2SX on my robot, the one I've been using, and another one on a carrier board.) The one on the carrier board worked perfectly. A quick search revealed that I need to add capacitors to my robot board. I've got the schematics for adding the capacitors from a forum search (posted by Jon·in another topic.)
Thanks anyway, and sorry for taking up your time for something so simple.
Edit: Yup, my robot can now read the data properly. Thanks again.
Post Edited (romshark) : 6/12/2005 12:43:40 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax