Shop OBEX P1 Docs P2 Docs Learn Events
Basic Stamp to VB6 — Parallax Forums

Basic Stamp to VB6

DocDoc Posts: 25
edited 2005-10-20 15:03 in BASIC Stamp
Hello,

actually I have a small problem with collecting data from Basic Stamp. I have a SRF235 Ultra Sound detector connected to BS2px24-BOE/USB Interface. I wrote the code in PBasic and all works well,·thus, in the interface I can see the distance measured each "x ms". On VB6, I want to save the data in a list box, that means the distance measured every x ms. The problem is that there is a delay between Basic Stamp and VB6 and moreover, VB6 displays the range measured in basic Stamp preceded by a vertical dash which is the ASCII Value 1 (HOME Symbol).

Is there any solution for this?

Thank you.

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-10-13 14:34
    Doc,

    ·· This is kind of a trick question in a way...One could infer that if the reading is correct but with the extra character, then just don't have your VB6 App print that character.· On the other hand, do you know what's being sent from the BASIC Stamp Module?· Is that character being sent?· If so, don't send it.· If not, perhaps your MSCOMM routine is messed up?· What exactly are you getting?


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • DocDoc Posts: 25
    edited 2005-10-14 08:32
    Hello Chris,

    Thank you for your reply. Actualy, the Basic Stamp module is sending as follow : "DEBUG 1, DEC4 Range", where "1" is the HOME symbole, so this is the caracter which is not recognized by VB6. In the VB6, I am printing the MSComm.Input into a listbox :

    A = MSComm.Input
    lstdata.Additem A

    Thanks
  • stamptrolstamptrol Posts: 1,731
    edited 2005-10-14 13:01
    Doc,

    The other way around it is to use a SEROUT command ( on pin 16, if you want to use the existing connector). That way, no additional characters are sent.

    Tom
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-14 13:36
    Doc,

    Just filter the 1 from the MSComm input -- I haven't used VB in a while, but you should be able to do something like this:

    · temp = MSComm.Input
    · If Left$(temp, 1) < 32 Then
    ··· temp = Mid$(temp, 2)
    · End If
    · lstData.AddItem temp

    Double check use of Left$ and Mid$ -- like I said, I haven't used VB in a while.· The idea is to remove the first character if it's not in the normal ASCII printing range.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Beau SchwabeBeau Schwabe Posts: 6,557
    edited 2005-10-14 14:02
      temp = MSComm.Input
      If Asc(Left$(temp, 1)) < 32 Then
        temp = Mid$(temp, 2)
      End If
      lstData.AddItem temp
    


    or

      temp = MSComm.Input
      If Left$(temp, 1) < Chr$(32) Then
        temp = Mid$(temp, 2)
      End If
      lstData.AddItem temp
    



    tongue.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-14 14:09
    Thanks for the fix, Beau.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • DocDoc Posts: 25
    edited 2005-10-20 14:53
    Thanx a lot guys for your help.

    Sorry for my late reply but I was away.

    One more thing, any idea about the delay between the Basic Stamp and the VB6?



    Thx,

    Doc.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-20 15:03
    The problem with using the programming port for PC-to-Stamp communications is that the BASIC Stamp has to be sitting on a SERIN when you send your message. If you have the IO space, it's better to use a full interface that includes hardware flow-control, this way the PC won't try to send data to the BASIC Stamp until the BASIC Stamp is ready for it. Download our RS-232 DCE AppMod documentation for a circuit and demo code.

    If you're forced to use the programming port, you may want to develop a software protocol where the BASIC Stamp sends an *ready* message to the PC, the immediately loads a SERIN statement to wait on what the PC has to send.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.