BS1-to-PC Application Via DEBUG
Jon Williams
Posts: 6,491
As you know, you can't do a SEROUT (or SERIN) on the BS1 programming port, but the fact is that the BS1 does send DEBUG information serially (at 4800 baud) to the PC.· The trick is understanding the BS1 DEBUG packet and parsing the BS1 variables from it.· You'll have to wait for the March 2006 edition of Nuts & Volts for the full explanation, but for those with VB Pro (or REALbasic and want to convert the program) I've attached the source files for my BS1 DEBUG Viewer application.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Comments
1-27-06: Added VB source code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 1/28/2006 1:09:19 AM GMT
Actually, you kind of got me thinking about a project I am working on and how I can simplify my design... You made me go back and check out the ol' classic BS1 and if my thoughts are correct (always suspect!), I think I can do it using a BS1...
Bottom line, great idea... can't wait for the March N&V to hit my mailbox!!!
Again, thanks for the inspiration!!!
Deno
Billiard ball hits switch (one of many)
Switch inputs a logic "1" into, say, input pin 1
Stamp "debugs" and sends an identifier to the PC, telling which switch was hit
PC, running Visual Basic, determines which sound effect file to play for that specific input
Visual Basic program calls up and plays a .WAV sound effects file.
Main:
· DEBUG·PINS
· GOTO Main
You'll get the state of the input sent to the PC about four times per second.· Just have your PC program grab the packet (as demonstrated in the programs above) and watch for changes in the [noparse][[/noparse]input] PINS variable.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Thanks!
*Here's the math:
A) At 4800 baud the bit duration is 208.3 us
Each character uses 10 bit periods (start bit, eight data bits, stop bit) -- character duration·is 2.083 ms
C) 97 characters x 2.083 ms = 202 ms
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 2/7/2006 5:10:30 AM GMT
Suppose the BS1 were to initiate a debug only if a switch changes state. That way, you would not be waiting on a packet with outdated information. Would there be a way to compose the debug packet so the pertinent info (switch status) were at the beginning of the packet? One byte could hold the status of·all the switches. Could the application make the appropriate response without having to wait for the entire packet? How much time would transpire?
Thanks!
You're probably wondering why the 65-byte sync header... remember that this product was designed in 1991/1992 back in the DOS days, and the original editor needed to bit-banger serial via the printer port; having a long sync header helped the program catch the packet with few misses. The short version: it's a legacy issue.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Thanks Jon!
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Andreae
Parallax Tech Support·
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Andreae
Parallax Tech Support·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Before you criticize someone, walk a mile in his shoes. That way if he gets angry, he'll be a mile away and barefoot. - unknown