Shop OBEX P1 Docs P2 Docs Learn Events
BS1-to-PC Application Via DEBUG — Parallax Forums

BS1-to-PC Application Via DEBUG

Jon WilliamsJon Williams Posts: 6,491
edited 2010-04-14 15:15 in Robotics
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.

attachment.php?attachmentid=40126

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-25 21:40
    And here's a little app I created from the core code above that displays the temperature.

    attachment.php?attachmentid=40129

    attachment.php?attachmentid=40130

    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
  • Steve JoblinSteve Joblin Posts: 784
    edited 2006-01-27 18:22
    Jon... I don't want to fill the board with meaningless posts, but since no one else is saying it... WAY COOL!!!!!!

    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!!!
  • denodeno Posts: 242
    edited 2006-01-27 22:40
    Jon...what is the nifty looking usb device that the DS1302 is plugged into pictured in your photo?
    Deno
  • ForrestForrest Posts: 1,341
    edited 2006-01-28 00:31
  • Jerry ElyaJerry Elya Posts: 16
    edited 2006-01-28 02:51
    So if I'm reading this DeBug to PC thing right, I can . . . .

    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.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-28 02:57
    Yep, you could do that.· It's as simple as this bit of code:

    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
  • Tron-XTron-X Posts: 2
    edited 2006-02-07 04:26
    Is there any way to get the data to the PC faster than 4 times per second? I'd like to do something like what Jerry is talking about, but I would be concerned that a 1/4 second delay may be noticeable with what I'm doing. I suppose I could send the data only if an input changes. If I did that, how long would it take from switch closure until my program knows about it? Sorry about asking without trying it out first, but I don't have a BS1USB yet. Just looking into options at this point.

    Thanks!
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-02-07 05:07
    Absolutely none. The BS1 DEBUG packet is 97 bytes long at 4800 baud -- this means that packet transmission duration is 202* milliseconds. I said "about" four times per second to account for other program overhead, so I guess it's 4+ times per second. For any application monitoring switch inputs the 2-line program I posted above is the most responsive; no logic to consume time, just sends the status.

    *Here's the math:

    A) At 4800 baud the bit duration is 208.3 us
    B) 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
  • Tron-XTron-X Posts: 2
    edited 2006-02-08 02:05
    I'm thinking in certain cases, that the delay may be over 400ms. If a switch were to close near the beginning of a debug packet being sent, the program would have to wait for that packet·to be sent·and the next packet with the switch closure to be sent before it knows a switch has been closed.

    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!
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-02-08 02:13
    Actually, if the switch change happens within the first 65 bytes of the packet (sync header) then it would still be caught, and the pin states are simply mapped in RAM and the value at that point of transmission will be the current value.

    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
  • dandreaedandreae Posts: 1,375
    edited 2009-09-10 12:44
    This is a very nice app.

    Thanks Jon!



    Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Parallax Tech Support·
  • MoskogMoskog Posts: 554
    edited 2009-09-10 17:03
    Agree with you, Dave. But we could have told him that earlier.
  • dandreaedandreae Posts: 1,375
    edited 2009-09-11 19:42
    The reason for the late comment, is that it was brought to my attention by another member who sent me a link to link it.

    Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Parallax Tech Support·
  • sumdawgysumdawgy Posts: 167
    edited 2010-04-14 15:15
    I'd just like to post a very late but heartfelt THANK YOU.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    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
Sign In or Register to comment.