PDA

View Full Version : Serial data to USB



cooksydesign
- 28th October 2008, 21:25
I have good working code to transmit serial data to and from a PIC 16F628A and a VB6 application. Now the request for a USB connection has come up. Has anyone played with a serial to USB converter? The board with the PIC has been made, I'm stuck with serial in, serial out, and ground for data transfer. The data is transfered at a blistering 4800bps, but for the small amount of data it's just fine.
Two bytes are first sent from the VB application to the PIC. The PIC acknowledges with a byte, then transfers less than 50 bytes and it's over.
Soooo, anyway, has anyone played with a serial to USB converter? I have seen one or two that are built into a cable, which would be sweet if that worked out.
Thanks to all.

Brad

mackrackit
- 28th October 2008, 21:47
I have good working code to transmit serial data to and from a PIC 16F628A and a VB6 application. Now the request for a USB connection has come up. Has anyone played with a serial to USB converter? The board with the PIC has been made, I'm stuck with serial in, serial out, and ground for data transfer. The data is transfered at a blistering 4800bps, but for the small amount of data it's just fine.
Two bytes are first sent from the VB application to the PIC. The PIC acknowledges with a byte, then transfers less than 50 bytes and it's over.
Soooo, anyway, has anyone played with a serial to USB converter? I have seen one or two that are built into a cable, which would be sweet if that worked out.
Thanks to all.

Brad
I have good luck with a Belkin F5U409.

http://catalog.belkin.com/IWCatProductPage.process?Product_Id=459431

mister_e
- 28th October 2008, 21:59
I'd never ever had any kind of problem 'till now. BUUUUUUUUT, most USB-2-serial may access COM up to 255/255. VB6 original component is usually able to work within COM1:COM15 range. With VB6, So the only kind of limitation is if you can't modify the COM port that your converter use.

You could find some info over the net to modify the VB6 control, or, i'll suggest you to move on newer .Net version (express work great).

In .NET you also could build a list of available COM port in 2-3 code lines.

Now, i use PIC with USB.

cooksydesign
- 28th October 2008, 22:18
Mackrackit, what kind of handshaking is required with the Belkin cable?

My '628A PIC is surface mount, the boards have been made. I think the boards were done before the PIC came out with USB, yep, a few years and I still have some stock.

Many thanks.

Brad

mister_e
- 28th October 2008, 22:23
I'm not Mackrackit, but handshaking is really up to you. You could have DTR line connected to the MCLR and play with it in VB, so your PIC fall in a SerialCom Test or Bootloading procedure for XYZ delay.

I usually use USART interrupt without MCLR.

mackrackit
- 28th October 2008, 22:43
What he said and..

When the serial/usb converter is installed on XP/Vista, you will have a virtual com port number ?? in device manager.

This virtual com port will have all of the settings of a regular com port.

cooksydesign
- 28th October 2008, 22:52
It has occured to me that VB6 does not support USB ports, right?
.NET does?
The PIC end of this has a three pin, 0.100 centers, header; Gnd, transmit, and receive. The end I need to mess with is the PC/VB side.

Thanks again all.

B

mister_e
- 28th October 2008, 23:31
All language support USB, but there's no easy lunch :D

If you have MicroCodeStudio, you should have a plug-in called EasyHID, this will create your code template for VB6. It will also give you a .DLL called mchid.dll or something like that, which is the core of the template.

A while back, i've posted an example somewhere her called USBDemo. sure enough you will have everything to get you started with it.

I also published here a Template to use VB.NET. Another guy on the net also used it, modified it a little bit and placed it on his website ( http://www.helmpcb.com/Software/USBHIDVB/USBHIDVB.aspx )


I really suggest you to forget the outdated (but still usefull and workable) VB6, move on .NET. VBExpress is free to use.

Jan Axelson's website also have tons of ressource and code template to work with HID devices.

cooksydesign
- 29th October 2008, 02:18
First, thanks for the responses. Very informative.

So, just so I have it straight, I should download MicroCodeStudio for the template for VB6. I also need to get MicroCodeStudio Plus for the 16F628A PIC, the MicroCodeStudio free version only cover 16F628. Is that correct?
I don't think 628A has USB capabilities.

I have a copy of .NET, I looked into the MSCOM part of it once and decided to stay with what I knew for rapid deployment. Now I'm paying for it. I will take your advice to move to .NET under consideration.

I wonder, if plugging in the Belkin cable Mack mentioned earlier, helps the situation at all. Mack??

Regards.

B

mackrackit
- 29th October 2008, 02:26
All the Belkin serial to USB does is turn a USB port on the PC into a serial port (virtually)

All communications are serial type. RS232 (sort of).

Straight USB is a different thing altogether.

The free version of MCS 3.0 does the 16F628A.

What version of PBP and MCS are you using?

mister_e
- 29th October 2008, 03:13
In .NET you want to use SerialPort component instead, it's a Mscomm but with more rich feature.

To start, simple serial com is probably the best way to go, the 16F628A is a good choice.

skimask
- 29th October 2008, 05:45
It has occured to me that VB6 does not support USB ports, right?
.NET does?
The PIC end of this has a three pin, 0.100 centers, header; Gnd, transmit, and receive. The end I need to mess with is the PC/VB side.
Thanks again all.
B

Ya could go with a CP2102/CP2103 type chip...
http://www.sparkfun.com/commerce/product_info.php?products_id=309
Serial in one side, USB out the other side, virtual COM port on the PC.

cooksydesign
- 29th October 2008, 10:50
I am using PIC Basic Pro, version I am unsure of. It does have USBIN, USBOUT, USBINIT, and USBSERVICES.

I will investigate all your suggestions. Thanks again to all.

B

cooksydesign
- 29th October 2008, 10:53
All the Belkin serial to USB does is turn a USB port on the PC into a serial port (virtually)

All communications are serial type. RS232 (sort of).

Straight USB is a different thing altogether.

The free version of MCS 3.0 does the 16F628A.

What version of PBP and MCS are you using?

Does this mean then in VB6 I can select a USB port just the same as a "normal" comm port?

B

mackrackit
- 29th October 2008, 11:15
Does this mean then in VB6 I can select a USB port just the same as a "normal" comm port?

B
I do not use VB or .NET
In other languages when using on of these converters, it is treated as a serial port.

For example. One of my machines that does not have a serial port, only USB, add a hub and four serial to USB converters, device manager shows com 2 through 5. If I use hyperterminal, I pick one of these just as I would a real serial port. The same goes for Python and Liberty Basic (the two I use).

So I would guess in VB you would do the same because the OS sees these converters as a serial port.

mackrackit
- 29th October 2008, 11:16
I am using PIC Basic Pro, version I am unsure of. It does have USBIN, USBOUT, USBINIT, and USBSERVICES.

I will investigate all your suggestions. Thanks again to all.

B
Check the Read me file in the PBP directory.

arniepj
- 29th October 2008, 11:45
This demo was created for the serial to usb port selection problem.
http://www.picbasic.co.uk/forum/showthread.php?t=7372

dhouston
- 29th October 2008, 14:44
The simplest solution is to keep your PIC application as RS232 and tell those who need USB to buy this http://www.byterunner.com/byterunner/product_name=Y-105/user-id=/password=/exchange=/exact_match=exact. It's inexpensive, it works and it eliminates the need for you to rewrite your PIC application, learning to use USB, .NET, etc.

serkanc
- 29th October 2008, 16:10
I'm using 18f2550, PBP and Visual Basic Express 2008 without any problem... With the usage of bootloader you can also programm your pic in a few seconds on your circuit over USB...