Page 1 of 1

AVR USB and VB6

Posted: Sun Apr 01, 2007 1:04 pm
by Urvish
Hi all...
Plz help me out this prob.
I want to communicate AVR-USB with VB6.
I am sending status of pins of MCU to PC.
I want to see that in an app made in VB.
How can I do that??

Also which mode of USB in AVR will give me Max data Xfer rate???

Tahnks 4 Help in advance.

Posted: Tue Jun 12, 2007 9:00 am
by Mario
Hi,

I'm trying to make a VB6 application to communicate with my device.

Here is the code of a little program I found in the internet:

Code: Select all

Private Declare Sub usb_init Lib "libusb0.dll" ()

Private Declare Function usb_find_busses Lib "libusb0.dll" () As Integer
Private Declare Function usb_find_devices Lib "libusb0.dll" () As Integer

Private Sub Form_Initialize()
     Call usb_init
End Sub


Private Sub Command1_Click()

nBusses = usb_find_busses()

nDevices = usb_find_devices()

Label1.Caption = "Devices " & nDevices

Label2.Caption = "Busses " & nBusses
End Sub


With this program I can see how many devices are connected to usb, but is there a way to send data to my device over the libusb0.dll, or is there another API to do this?

Thank you.

Best regards,
Mario

Using C, not VB anymore

Posted: Sat Jun 16, 2007 9:01 am
by Mario
Hello,

I did my program in C, using Dev-C++ and it works very well. I think there is no reason to do it in Visual Basic, because I saw that there is so much C code available to communicate with the AVR-USB. First I want to thank you for this. It is helping me more that I expected, to do my conclusion projekt for the university. ;-)

Now I have another question. I'm using a bootloader to copy my program to the ATmega16s memory. Both using the USB-firmwre solution (bootloader and main program). Is there a way to restart the USB enumeration by firmware, after jumping from the bootloader to the main programm? Or is there a bug in my firmware, and it should do it by himself? Now I have to disconnect the USB cable after jumping from the bootloader to the main program or do a hardware reset after a firmware update.

Thanks in advance for your help.

Best regards,
Mario

Posted: Sat Jun 16, 2007 7:44 pm
by christian
If you want to start a re-enumeration "the correct way", you must be able to deactivate the 1.5k pull-up resistor. If it's connected to a port pin instead of the positive supply, just disconnect it for several 100 milliseconds.

If your pull-up is wired directly to the positive supply, you can still get the same effect by pulling down D+ and D-. All our examples do this as one of the first actions in main(). The duration is a bit short, though, and the host will not always detect this as a re-enumeration request. To be on the safe side, pull down D+ and D- for several 100 ms.

Posted: Mon Jun 18, 2007 12:08 pm
by Guest
Mario can u please post the code u found for communication btwen PC and Microcontroller.
I need to do the same using Windows CE 6.0 and ATMEGA 32 using viasual studio 2005.

Thanks a lot

Posted: Mon Jun 18, 2007 12:08 pm
by Vishwas
Mario can u please post the code u found for communication btwen PC and Microcontroller.
I need to do the same using Windows CE 6.0 and ATMEGA 32 using viasual studio 2005.

Thanks a lot

Posted: Tue Jun 19, 2007 4:43 pm
by Mario
Thank you, Christian, increasing the time to 100ms solved my problem. ;-)

@Vishwas: for my project I took the code from the AVRUSBBoot, and somthing from elektor (I think elektor just copied and made some changes from code available here at obdev.at). Here are the links:
http://www.fischl.de/avrusbboot/
http://www.elektor.de/Uploads/Files/Magazine/060276-11.zip

I would recommend you to take a look at the projects available here on obdev.at (http://www.obdev.at/products/avrusb/), to find somthing similar to what you want to do.

Best regards,
Mario

Posted: Tue Jun 19, 2007 4:46 pm
by Mario
Sorry, I made a mistake on my last post. I incrased the time to 500ms, not 100ms.