;) This forum is the property of Proton software developers

Main Menu

VB.NET HID Application Framework to send and receive to and from PIC

Started by trastikata, Apr 11, 2021, 03:03 PM

Previous topic - Next topic


PIC mcu with USB capabilities is only useful if we can do something with it. Therefore we need a PC host application to receive from and send information to the PIC microcontroller.

If the data transfer speed is not critical then for simple applications the HID USB protocol is proffered because of its simplicity of implementation (since WinXP, the USB HID driver is standardized in Windows.

So I am sharing one way to built HID-capable applications with VB.NET, far from being the only or the best way to do it, this is simply one possibility.

1. First download the required DLL files and the Windows Form example
- The mcHID.dll needs to be in the same folder as the application's exe file


- The mcHIDinterface.dll need to be referenced in your VB.NET solution as shown here:


-- 1. In the "Solution Explorer" right click on your solution and select "Properties"
-- 2. Click on "Add" and browse to "mcHIDinterface.dll" and select it to add.
-- 3. and 4. It should appear in you "References" as shown in 3 and 4

2. Make sure in your project properties, "Target CPU" is set as x86


3. Design your Windows form to fit your project. This is the example Project, included in


In this example:
- The top Label is changed to "MY USB CONNECTED" and "MY USB NOT CONNECTED" when a device with the preset VID and PID is connected and disconnected from the PC respectively.
- Button "SEND" sends a simple command to the PIC MCU to turn on the LED.
- The PIC MCU switches on the LED and responds with a string saying "LED ON"
- After 1 second the PIC switches off the LED and sends a string "LED OFF"
- As idle process the PIC constantly sends the status of the button and the green/red button in the form changes color accordingly.

To set up the application correctly, make sure the VID and PID, as well as the BufferIN and BufferOUT sizes match in both, the VB.NET application and Proton.

All functions and events are commented in the VB.NET solution and how information is being handled. However how to deal with the data received and sent to the PIC MCU is entirely up to the user and there is always a rudimentary protocol required that will avoid infinity loops (i.e. waiting for data, that is never being sent) or time collisions and overflows. 

Again, there are probably many and better ways to achieve the same result, this is just a basic to start and build on.