Using the Basic Stamp Homework Board, how do I send date over the serial line t
What I am trying to accomplish.
I want my computer to be able to run my (DC power and N scale) model trains. To do this each block will have an IR sensor at each end. Four blocks will use 8 inputs, 4 outputs will control H bridges to drive the engine, and the last 4 outputs will control the direction of the train. For now I have only a 3’ by 6’ circle of track, if and when it all works, more will be added.
What my problem is.
Using the BS2 homework board for testing only, how can I use the "SEROUT" command to communicate with an MS Basic program. I do have the board sending single ASCII characters to the Debug screen only when an IR sensor sees a change.
Other thoughts.
Eventually I plan to use more that one BS2 - 24 pin ICs on a perf board for the whole layout. And will probably change to Visual Basic, but need to get past several other hurtles first.
I want my computer to be able to run my (DC power and N scale) model trains. To do this each block will have an IR sensor at each end. Four blocks will use 8 inputs, 4 outputs will control H bridges to drive the engine, and the last 4 outputs will control the direction of the train. For now I have only a 3’ by 6’ circle of track, if and when it all works, more will be added.
What my problem is.
Using the BS2 homework board for testing only, how can I use the "SEROUT" command to communicate with an MS Basic program. I do have the board sending single ASCII characters to the Debug screen only when an IR sensor sees a change.
Other thoughts.
Eventually I plan to use more that one BS2 - 24 pin ICs on a perf board for the whole layout. And will probably change to Visual Basic, but need to get past several other hurtles first.
Comments
So, you're already half way there if you are sending commands via debug. Now all you need is a Visual Basic program.
If you are looking to create your own, you'll need to get yourself set-up with Visual Basic. The best choice if you are a beginner / novice is to download the free Visual Basic Express 2005 form Microsoft. Visit their VB Learning Center, and you can also download several tutorial videos that will get you moving forward.
If you aren't looking to create your own, and if you are looking for a logging program, you can find one in this thread: http://forums.parallax.com/showthread.php?p=665399
Thank you for your quick response. In reading your reply, I realized that once I had used the BASIC Stamp Editor Program v2.2 to download “My Program” to the BS2 Homework Board, I could turn the BSEP v2.2 program off, and “My Program” would still running on the BS2 Homework Board. I proved this by adding an LED that changes state every time the IR sensor changes state. Now I can run an MS Basic Program to read the serial input from the BS2 Homework Board. TTFN, Watashiwa
Kevin,
Do you have a specification sheet that explains the bit definitions for the registers on the computer serial board. I need to write my own driver. Or do you know where I could go to down load a PDF file ?? Thanks, TTFN, Jim
++++++++++++++++++++++
Hi Jim. I'm not too sure what you're looking for. What exactly are you trying to do? From Kevin
++++++++++++++++++++++
Kevin,
At the present time I need to use QBasic on my computer (IBM compatible) to communicate with the BS2 Homework Board. The only 2 commands that seem to work are INP and OUT which read and write to the port registers on the COM #1 Serial Board. The best I can find out is that there are 7, 8 bit registers located at &H3F8 to &H3FE. Perhaps there is one also at &H3FF as that is what is listed in Properties when I query COM #1.
My QBasic is ver 1.1 from a Windows 98 CD. I decided to respond to you this way as someone else might be able to help me out. Thanks !!
It seems to have Serial Support:
··· open "com2:19200,n,8,1,ds0,cs0,rs" for random as #commHandle
Remember that when a modem dials and connects to another modem, it negotiates a cpnnectopm speed.· In the case of 14400 speed modems, you need to specify 19200 as the connection speed and let the modems work it out between themselves during the connect.· This is because 14400 is not a baud rate supported by Windows (and you'll find that QBASIC doesn't directly support 14400 baud either).
Once the port is open, sending data is accomplished by printing to the port (ATZ resets modems that understand the Hayes command set):
··· print #commHandle, "ATZ"
To read from the port you should first check to see if there is anything to read.· This is accomplished in this fashion:
··· numBytes = lof(#commHandle)
Then read the data using the input$() function.
··· dataRead$ = input$(#commHandle, numBytes)
Putting the lof( ) and input$( ) functions together on one line, it looks like this:
··· dataRead$ = input$(#commHandle, lof(#commHandle))
When you're all done, close the port:
··· close #commHandle
Just BASIC has the ability to disable DSR checking by specifying a zero or non value using the DS switch:·
··· open "com1:9600,n,8,1,ds0" for random as #com
· or
··· open "com1:9600,n,8,1,ds" for random as #com
Use the txcount(#handle) function to get a count of bytes in a serial communications transmit queue.
··· count = txcount(#com)
--- Excerpt from the help file ---
pw
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There's nothing like a new idea and a warm soldering iron.
Post Edited (pwillard) : 8/16/2007 2:34:50 PM GMT
When I was ready to expand my·stamp applications to talk to my PC I struggled with many of the examples available trying to get to the core of sending serial data to my PC for processing by an application.· I was finally able to get my stamp to talk to visual basic express (the free version of VB)
I've created a page with the details of how I got this to work....thought it might help.
http://www.theabramgroup.com/basicstamp/
Good luck!
D. Abram,
···· I am on vacation right now, but will·try to remember to get back to you. But I have to be honest, I tried Visual Basic once and it fouled up my operating system, so I’m not in a rush to reload it. Anyway, perhaps we can trade ideas. TTFN, Jim
I looked over your V Basic code and it appears you are receiving data from the BS2 board. I have been able to get that far also, with Qbasic. But what I’m trying to do is after receiving the (data-in) input into Qbasic, make a decision on what that data means and then send a command (data-out) back to the BS2 to perform another function.
In real terms the "data-in" is from an IR sensor under my model train track that senses when an engine or caboose passes over it. The "data-out" command to the BS2 is to control an "H" bridge·to·stop (slow down, speed up etc.) the engine or not. The "H" bridge makes it possible to run the (DC) engine either forward or backward, or in the opposite direction after a loop back track.
I did finally find out some info on the Serial chip on the COM1 board. Google does a great job of searching for you, IF you put in the proper terms. The serial chip is called a UART. Hope some of this makes sense to you. Thanks for your help. Wat