USB : USB Classes    USB Classes for Microcontrollers  

This is what makes HIDmaker the most powerful tool in the world for making USB devices: HIDmaker's unique process of Direct Transfer of Variables.

Let's say that you want to read a pot on your peripheral device, and send the position of that pot wiper to the PC.  Here's all you have to do in HIDmaker:

  • Using HIDmaker's Visual Data Designer, you create a data item that will be used to transfer this data.  It doesn't matter for the moment what Usage numbers you give it, as long as that collection of numbers is unique, i.e. not used by any other variables you create.
  • Be sure to give that data item some meaningful name, like "Pot1".
  • You'll probably want to set its data direction to "Input," because it will be sent from your peripheral device, IN to the PC.
  • Have HIDmaker generate your code.  You will now notice that your device code will have a variable called "Pot1".  You will also see that your PC code also contains something called "Pot1".  (It's actually an object, but its current value is in the property Pot1.UnscaledValue.)
  • Now, you simply USE those variables that HIDmaker has declared for you:
    • On the peripheral side, you read the ADC converter channel that is connected to the wiper of the pot, and put that value into the variable called Pot1. Then, after the part of the generated code where you have assigned that value to Pot1, HIDmaker's framework will automatically pack the values of your variables together into packets and transfers them to the PC over the USB cable. 
    • The PC Host automatically unpacks the data for you, making the value you just sent available in property Pot1.UnscaledValue. In the PCside code, you simply USE that value, in any way that you want: print it, graph it, use it to set the positon of a gauge, store it in a file, or whatever you want.

That's all there is to it!  And the process works exactly the same way in the opposite direction as well.

We'll show you some examples in some of our other tutorials.

 
  

25 of 29
Copyright Notice and Author Information