Shop OBEX P1 Docs P2 Docs Learn Events
RS232 VB6 connection — Parallax Forums

RS232 VB6 connection

TexFlyTexFly Posts: 26
edited 2011-04-17 08:47 in Propeller 1
Hello,

I need to connect the Propeller to a VB6 software via RS232. In the past I have used other I/O cards that had a DLL to make it easy.

For example: when a button is pushed (...on the Propeller one of the bits goes to 1) I need to turn on
a light on the VB6 software and viceversa. When I push a button on the VB6 software I need to have a bit of the
Propeller to "1".

What's the best way to develop this?

Thanks.

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2011-04-16 17:49
    Tex: Welcome to the fantastic prop chip and forum.
    The prop with an FTDI chip gives a USB connection and looks like a normal serial UART (comm port) to the VB6 software. We regularly run comms to the pc at 115,200 baud although you will not necessarily get that figure as throughput. Dr_Acula probably has the most info here as he has used VB6 to communicate with the prop. A Prop Protoboard USB has this circuit on board. Otherwise, a Propplug has the FTDI circuit built in to connect to a prop board.
  • Mike GMike G Posts: 2,702
    edited 2011-04-16 18:10
    Take a look at the MSComm API for serial communication in VB6
    http://msdn.microsoft.com/en-us/library/aa259393%28v=vs.60%29.aspx
  • TexFlyTexFly Posts: 26
    edited 2011-04-16 18:22
    Thanks for the replies. I already have a Propeller proto board and I'm looking for the easiest way to communicate with VB6.

    Do you know where I can find some sample code "combo" (Propeller with VB6) to quickly allow the communication?
  • bennettdanbennettdan Posts: 614
    edited 2011-04-16 18:42
    TexFly,
    I am curious as to why you are using the VB6 instead of the newer VB.net platforms?
    If this is a non comercial project then you can download the new VB.net Express versions for free.
    I believe you will find more examples for Serial Port programming and I also have some experience using VB.net with a serial port.
  • TexFlyTexFly Posts: 26
    edited 2011-04-16 18:58
    ...because I have an app already working in VB6 and I do not have the time to reprogram it in Vb.Net. I'm looking for a quick solution to connect the Prop to VB6 Comm....
  • Mike GMike G Posts: 2,702
    edited 2011-04-16 19:08
    First you decide on a messaging protocol between the Prop and your application. For example, If the PC receive "!Att LED1=On [0x13]" then light LED 1 on your Win form.

    Load one of the serial object is the Propeller to Tx/RX on pins 30 and 31. See the well documented Parallax Serial Terminal Demo to test your Propeller Rx/Tx code. Do much the same in VB6, load your serial API and test. There are literally tons of of example on serial COM in this forum and on the Internet.

    Play with the Parallax Serial Terminal Demo first.
  • bennettdanbennettdan Posts: 614
    edited 2011-04-16 19:14
    I see well if you already have the App coded in VB6 then what do you type of value do you need sent from the Propeller a byte,hex,binary,string or other?
    The OBEX has a couple of Serial Port objects that will send data to and from the propeller.
    http://obex.parallax.com/objects/54/
    http://obex.parallax.com/objects/397/
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-04-17 03:56
    TexFly: If you already have a VB6 app running on a serial port, then you can use this without modification. The prop protoboard USB version will connect directly to the pc as a serial connection with the FTDI driver. if your board is the proto without the USB, then use a propplug to make the connection. Otherwise, use an TTL to RS232 adapter (or build one).

    On the prop end, take a look at the FullDuplexSerial demo program that comes with PropTool. It works fine to/from the pc using P31&P31.

    I must say I find VB6 is simpler than VB.net.
  • TexFlyTexFly Posts: 26
    edited 2011-04-17 06:16
    I do have the Protoboard with the USB port. I will check the demo.

    I was wondering...do you guys know of any sample code (for the Prop and VB) that I can use to jump start my project?


    Thanks.
  • localrogerlocalroger Posts: 3,452
    edited 2011-04-17 08:47
    Here's the basic code with an example simple terminal program using it:
    sniffer.zip
    You will need to use a timer to poll the port for incoming characters and also to see if the last TX is complete before attempting another. This code also won't work on win95/98/ME or under WINE in Linux because VB6 doesn't do threading, and those environments get threadbound. It is remarkably unstraightforward and poorly documented; the Windows serial API is absolutely the worst I have ever seen.
Sign In or Register to comment.