Shop OBEX P1 Docs P2 Docs Learn Events
Basic Stamp and Visual Basic — Parallax Forums

Basic Stamp and Visual Basic

NWUpgradesNWUpgrades Posts: 292
edited 2005-04-17 22:41 in BASIC Stamp
This may not be the correct forum to ask this, but I will try any how. Does anyone know how to use Visual Basic to connect to my Basic 2 Stamp via the Serial Port? In other words, I wantto use Visual Basic to do my programming instead of PBasic. I just need to be able to open the serial port from Visual Basic. Thanks for any help.

Comments

  • bishopbishop Posts: 82
    edited 2005-04-17 01:19
    you'll need to use the MSCOMM object to perform serial communication in VB6 (i'm assuming you're using 6 and not .net)
    try this:
    http://www.developerfusion.co.uk/show/21/
    to get you started. as far as actually working with your BS2 with the pc serial port, i can offer little help. but the coding side of vb6 comm is pretty easy to research.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    **************

    daniel woolston
    Teksystems Inc.
    www.danwoolston.com
    **************
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-17 01:33
    You can create applications in Visual Basic to "talk" to an application on the BASIC Stamp, but you cannot program the BASIC Stamp using VB -- VB is designed for the desktop environment; PBASIC is designed for embedded micros.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-04-17 01:52
    Thanks Jon, That clarifies it a little. So, is there a way in PBasic to create a GUI? The reason I ask is that I want to create a program to control stepper motors via mouse clicks and have Graphics with directional arrows.
  • BeanBean Posts: 8,129
    edited 2005-04-17 02:00
    No you CAN do that in VB, but you said you wanted to PROGRAM the BS2 in VB. That would be difficult.

    To do what you want:

    Write a program in PBASIC that receives serial data and outputs pulses to the stepper motors.
    Download that program into the stamp.
    Now write a VB program to send the serial data that the PBASIC program is looking for.

    I think you use (virtual) PIN 16 for the programming serial port.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video Display Module" Available Now.

    www.sxvm.com

    "A problem well defined, is a problem·half solved."
    ·
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-04-17 02:11
    Bean, You lost me. I already have the Basic Stamp programmed. How do I then integrate the VB Program with it? Also, there are 16 pins on the stamp, 0-15, are you referring to pin 15?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-04-17 02:47
    In essence you create a program that sends commands via the serial port which corresonding to user button presses. The stamp is on the recieving end which takes the command and performs the coresponding operation.
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-04-17 02:51
    Do you by chance know of an easy example?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-04-17 03:00
    Like pre-coded example? no. But it should be fairly straightforward, research how to control the serial port in VB through thier help files. Create your own function map for stepper motor commands (forward, backward, half step forward, etc) and have the VB program send the code out the serial port when the user presses the button. The stamp will be programmed to sit listening to the serial line and perform the action associated with the command sent.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-17 13:03
    The docs for the RS-232 AppMod have a VB example: http://www.parallax.com/detail.asp?product_id=29120

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-04-17 15:21
    which doc? I see the .bs2 app, but not a VB. Thanks
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-17 15:43
    There's a ZIP file will all of the code -- BS2 and VB. Look closely (hint, hint), and you'll also see a link to a Nuts & Volts article that discusses VB and BS2 communications.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-04-17 15:59
    Thanks a bunch. I seen that, but was not sure if that was it. Thanks again for your help. One last question, Since i plan on creating a GUI, would it be a good idea to upgrade to the BS2PX Stamp?
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-04-17 16:06
    Is the Max232 the same as the RS-232 DCE AppMod? If not, where can I order one?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-17 16:12
    Remember, it never hurts to take a look when someone has pointed you to a page.· Don't make those that help you do it twice by being unwilling to do a little investigating....

    You can use your VB GUI with ANY BS2-family module.· The key is writing code on your BASIC Stamp such that it will adjust the SERIN/SEROUT baudmode parameters for any module that you use.· My standard template (attached and updated for the BS2px) has the constants used for the most popular serial baud rates.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-04-17 16:54
    Jon, I am currently using the Homework Board. Would the Max232 be able to work with this for testing purposes?
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-04-17 17:10
    NWUpgrades:

    1. When you use SERIN 16, 16384, [noparse][[/noparse]DEC MyValue]
    You are reading from the port that the PC uses for programming. The 'mythical' pin 16 is used to indicate to the BS2 that it should use the programming port.

    2. You want to create your GUI in Visual Basic. This GUI should have a part which talks to the BS2. This part should use the MSCOMM control, to talk to the PC's serial port, which you'll have connected to the BS2 DB-9 connector.

    3.· The attached ZIP file contains two programs.· The VB side is how VB should be configured to work with the BS2 on a serial port.· The BS2 side is how the BS2 can listen and respond to a VB program.

    It includes instructions on the VB side on how to add the MSCOMM control to your VB project.
  • geekythinggeekything Posts: 53
    edited 2005-04-17 17:29
    Just wanted to mention that REALBasic is also a viable contender for these sort of applications. Unfortunately, their free offer to tempt people "away from the darkside" expired on April 15th, but you can still get a demo version from www.realbasic.com.

    (I'm one of those people a little mad with Microsoft's decision to maroon VB6 in favour of VB.Net!).

    -marc
  • NWUpgradesNWUpgrades Posts: 292
    edited 2005-04-17 17:37
    Thanks for the info. I just ordered the Teach Yourself VB 6 in 21 Days. That includes VB 6, but not sure if it is going to work for what I need. I have programmed in C and C++ in the past, but am new to VB. I am trying to use the KISS statement( Keep It Simple, Stupid). I do not want to spend months trying to figure out something that should take a few hours. I really appreciate all the help that I get from this forum.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-17 18:07
    Probably not -- you need the MSCOMM control that comes only with the Pro versions of VB. And ... Microsoft has dropped support for VB6. As pointed out in another post, you could use REALBasic which does in fact include the COM port control you need.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • bishopbishop Posts: 82
    edited 2005-04-17 22:41
    microsoft didnt 'maroon' vb6. vb6 by nature couldnt be 'upgraded' to vb7 and be consistent with the .net framework. there were so many issues with the basic structure of VB6, that personally, I'm glad they just decided to offer VB.NET. And theres still a huge support network out there for VB6. I can still remember people complaining about VB6 when it came out.
    and i like microsoft. i think they rock. any company that throws as much into developers and research in general, is o.k. in my book. and my kids get to eat each week because daddy makes software with microsoft products. [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    **************

    daniel woolston
    Teksystems Inc.
    www.danwoolston.com
    **************
Sign In or Register to comment.