Jump to content

an Arduino USB HID controller, composite USB controller


overpro

Recommended Posts

Hey overpro!

Thank you very much for your nice instruction! its a really amazing solution and pushed me to continue on my simpit!

 

 

Is there also a possibility to connect analog inputs, as potentiometers?

 

Best Regards

Adrian

 

Yes, you can, but I commented out the analogRead code in arduino source code, you can simply uncomment that line at 297:

296        for (uint8_t ind=0; ind< NUM_AXES; ind++) {
297                joyReport.axis[ind] = map(analogRead(54+ind), 0, 1023, -32768,32767 );
298        }

mega2560 's analog pin has a 10 bit resolution, so we just need to map [0, 1023] to [-32768, 32767]

this line of the code might take a long time to run, which might have side effect to the rotary encoder, so I'd recommend you to do some test,

and it might be worth to replace analogRead() to avr style function calls if available, same to map().

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

Yes, you can, but I commented out the analogRead code in arduino source code, you can simply uncomment that line at 297:

296        for (uint8_t ind=0; ind< NUM_AXES; ind++) {
297                joyReport.axis[ind] = map(analogRead(54+ind), 0, 1023, -32768,32767 );
298        }

mega2560 's analog pin has a 10 bit resolution, so we just need to map [0, 1023] to [-32768, 32767]

this line of the code might take a long time to run, which might have side effect to the rotary encoder, so I'd recommend you to do some test,

and it might be worth to replace analogRead() to avr style function calls if available, same to map().

 

 

Hi overpro!

 

Thanks for your respond!

i already found this line and also uncommented it and loaded it the arduino. Then i connected the "outer" 2 contacts of the poti to the +5V supply and GND on the board. The center i connected at various analog input pins, without success. (also tried with 3.3V connection)

But if you say it should be possible, then i have a reason more to study my arduino learn book... :-)

 

Thanks again for your nice work and that you share it with us!!!

Link to comment
Share on other sites

Hi overpro!

 

Thanks for your respond!

i already found this line and also uncommented it and loaded it the arduino. Then i connected the "outer" 2 contacts of the poti to the +5V supply and GND on the board. The center i connected at various analog input pins, without success. (also tried with 3.3V connection)

But if you say it should be possible, then i have a reason more to study my arduino learn book... :-)

 

Thanks again for your nice work and that you share it with us!!!

 

Hi don_sangria, there are 16 analog inputs on mega2560, this arduino sketch uses A0 ~ A8, and if you uncomment that line and upload the sketch, without flash it to USB HID controller you can monitor the data output by using serial monitor ( I use HTerm ), every first 16 bytes of each 46 bytes ( 16 bytes for axis and 32 bytes for buttons ) are the analogRead's data. If you don't shortcut any analog pin to ground then the pin works like an antenna so those bytes looks like totally random.

Please let me know if your have any progress.

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

Hi don_sangria, there are 16 analog inputs on mega2560, this arduino sketch uses A0 ~ A8, and if you uncomment that line and upload the sketch, without flash it to USB HID controller you can monitor the data output by using serial monitor ( I use HTerm ), every first 16 bytes of each 46 bytes ( 16 bytes for axis and 32 bytes for buttons ) are the analogRead's data. If you don't shortcut any analog pin to ground then the pin works like an antenna so those bytes looks like totally random.

Please let me know if your have any progress.

 

Thanks!

I will try that and write in here again. Might take some time until i am back to my stuff.

 

Cheers

Link to comment
Share on other sites

Holy **** I completely missed this thread!

And yeah... I also stalled with my own project to do exactly that quite a while ago.

 

It looks really impressive and I hope I will have the time to test that stuff at some point in the next few weeks.

 

And here's a question:

Is it one-way (just input), or is it possible for DCSW to send something to a HID? I'm asking because my plan is to build a working A-10 UFC, which includes the Master Caution light.

Do you know a way we could achieve that?

I wondered if it is possible to have EOS run parallel to HID on one board, but it seems it isn't, so I'm searching for other solutions that might exist. Worst case would be using two arduinos, one with EOS and one HID I guess.

Link to comment
Share on other sites

Ok broke out my R3 uno.

 

I was successful at setting up the firmware and making show up as an HID joystick.

 

I am just not sure where to start with the code?

 

I want to try using my R3 Uno instead of getting a mega right now.

 

Can anyone point me to the direction of a working sketch for the R3 UNO?

 

UNO digital pin 2~13 can be used so there are 12 pins, which can support 6 * 6 = 36 buttons.

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

Holy **** I completely missed this thread!

And yeah... I also stalled with my own project to do exactly that quite a while ago.

 

It looks really impressive and I hope I will have the time to test that stuff at some point in the next few weeks.

 

And here's a question:

Is it one-way (just input), or is it possible for DCSW to send something to a HID? I'm asking because my plan is to build a working A-10 UFC, which includes the Master Caution light.

Do you know a way we could achieve that?

I wondered if it is possible to have EOS run parallel to HID on one board, but it seems it isn't, so I'm searching for other solutions that might exist. Worst case would be using two arduinos, one with EOS and one HID I guess.

 

I think it's possible, grab the data from DCSW and send the data to the board by using USB protocol, I haven't tried it before.

The firmware part need some changes, add an OUT endpoint, so arduino knows how to interpret the data received from Host.

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...

A question for you Overpro - I've got a couple of different types of encoders, and seem to miss turns with some of them. Is this likely to be a timing issue? It catches a percentage of the 'steps'.

 

Normally I'd just replace the encoders with the one I know work, but these encoders are in a premounted panel, so sizes are different.

 

Cheers

 

Peter

Link to comment
Share on other sites

Hey Icemaker!

 

Are you willing to share the schematics (myabe eagle files??) of your great boards?

I would like to integrate the arduino stuff to the motherboard and we would get then a ready to use - of course after a bit soldering work - arduino based joy stick solution.

 

kind regards

Link to comment
Share on other sites

A question for you Overpro - I've got a couple of different types of encoders, and seem to miss turns with some of them. Is this likely to be a timing issue? It catches a percentage of the 'steps'.

 

Normally I'd just replace the encoders with the one I know work, but these encoders are in a premounted panel, so sizes are different.

 

Cheers

 

Peter

Hi Peter,

 

Yes, it's the scan timing issue, I'd recommend to change the ARDUINO code like below to have a try, it will try to catch more "pulses"

 

//if (EncoderState[encoderId] == CWPattern1 || EncoderState[encoderId] == CWPattern3   )
               if (EncoderState[encoderId] == CWPattern1 || EncoderState[encoderId] == CWPattern3 || EncoderState[encoderId] == CWPattern2 || EncoderState[encoderId] == CWPattern4 )
               {
                   //this is a full CW pattern,
                   direction = 1;
                   }
               //else if (EncoderState[encoderId] == CCWPattern1  || EncoderState[encoderId] == CCWPattern3 )
               else if (EncoderState[encoderId] == CCWPattern1 || EncoderState[encoderId] == CCWPattern3 || EncoderState[encoderId] == CCWPattern2 || EncoderState[encoderId] == CCWPattern4 )
               {
                   //this is a full CCW pattern,
                   direction = -1;
                   }

 

 

And could you let me know the specs of your encoder? Maybe I can give it a try from my side as well.

 

Regards

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

Hi Peter,

 

Yes, it's the scan timing issue, I'd recommend to change the ARDUINO code like below to have a try, it will try to catch more "pulses"

 

//if (EncoderState[encoderId] == CWPattern1 || EncoderState[encoderId] == CWPattern3   )
               if (EncoderState[encoderId] == CWPattern1 || EncoderState[encoderId] == CWPattern3 || EncoderState[encoderId] == CWPattern2 || EncoderState[encoderId] == CWPattern4 )
               {
                   //this is a full CW pattern,
                   direction = 1;
                   }
               //else if (EncoderState[encoderId] == CCWPattern1  || EncoderState[encoderId] == CCWPattern3 )
               else if (EncoderState[encoderId] == CCWPattern1 || EncoderState[encoderId] == CCWPattern3 || EncoderState[encoderId] == CCWPattern2 || EncoderState[encoderId] == CCWPattern4 )
               {
                   //this is a full CCW pattern,
                   direction = -1;
                   }

 

 

And could you let me know the specs of your encoder? Maybe I can give it a try from my side as well.

 

Regards

Thanks for the reply Overpro, I'll give that a go. Not sure of the specs, I'll take apart the panel and see if I can make anything of it.

 

cheers

 

Peter

Link to comment
Share on other sites

Hey Ovenpro!

 

Just one question regarding your fantastic joystick controller:

Do you if somebody had already connected an anlog input (pontentiometer) to one of the ports?

I would like to connect two joysticks (poti based) and the engine throttle.

Any help ist welcome cause until now it didnt work for me.

 

kind regards

Robert

Link to comment
Share on other sites

Hey Ovenpro!

 

Just one question regarding your fantastic joystick controller:

Do you if somebody had already connected an anlog input (pontentiometer) to one of the ports?

I would like to connect two joysticks (poti based) and the engine throttle.

Any help ist welcome cause until now it didnt work for me.

 

kind regards

Robert

 

Hi Robert,

 

You need to uncomment one line of the ARDUINO code, please scroll down to the very end of the arduino sketch and you will see this:

for (uint8_t ind=0; ind< NUM_AXES; ind++) {
       [b][color=Blue]//[/color][/b]        joyReport.axis[ind] = map(analogRead(54+ind), 0, 1023, -32768,32767 );
   }

 

As you can see I have comment out the code that read the analog input, so you just need to delete the two slash symbols ( marked in blue ) and re-program the board.

 

Please note that for all unused analog pins you need to short it to GND ( ground ) or the corresponding axis will jump like crazy.

 

Please let me know if it works for you.

 

Regards

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

Hi Ovenpro,

 

thanks for your quick reply:-)

I have found the lines to uncomment by myself but I have read in a former post that it didn't work as expected (and have maybe side effects).

 

However I'm on a business trip at the moment and can't try it really. Arduino and a poti are with me but no breadboard - so it will be hard to connect the unused pins to ground.

But I can already confirm that the axis are jumping like crazy. Even that one woth the poti conected.

Wait until I have the right environment and I'll tell whats going on.

 

thanks

Robert

Link to comment
Share on other sites

Overpro, installed everything like you instructed but it's not working right for me. On the Game Controllers page, on the first CVP Controller (with the axis etc.) it doesn't matter what type or arrangement i try and hook a switch up to, nothing works. In the second CVP Controller (without the axis etc.), when i hook up a switch from Row A to Column 1 i get nothing...but if i hook up a switch from Column 2 to Column 3 i get TWO rows of lights that light up, and is reproducible throughout the entire Column area. So not quite sure why i'm not getting any switch logic with the prescribed method of hooking up switches...

Link to comment
Share on other sites

Poti on Arduino USB HID Controller

 

Hi Overpro,

 

back home I have tried the following:

 

1) Shortcut all analog Pins to GND -> flickering has been gone on all axis and all axis are stable at 50% (see 01.png)

2) Remove the shortcut on one (1) analog port and conect one of the the outer pins to +5V and the other to port 4

-> Poti is on max. left, still all axis at 50%

-> poti slowly turning to right, the Z-Rotation Bar goes (linear) to left (see 02.png)

-> poti turning a bit more to the right, Z-Rotation Bar jumps (not linear) to maximum (see 03.png)

-> turning poti further to the right, Z-Roation Bar goes (linear again) back to 50%

 

So, in prinziple it works - but why don't I have a linear growing of the axis?

Any Idea?

 

regards

01.png.ea82834d96bc2f2cdfafa900118e3112.png

02.png.4b3c94851fee7d373bc50ec00d4887ff.png

03.png.a9db78f4117ad223bcad56e7a0dce670.png

Link to comment
Share on other sites

Hi Overpro,

 

back home I have tried the following:

 

1) Shortcut all analog Pins to GND -> flickering has been gone on all axis and all axis are stable at 50% (see 01.png)

2) Remove the shortcut on one (1) analog port and conect one of the the outer pins to +5V and the other to port 4

-> Poti is on max. left, still all axis at 50%

-> poti slowly turning to right, the Z-Rotation Bar goes (linear) to left (see 02.png)

-> poti turning a bit more to the right, Z-Rotation Bar jumps (not linear) to maximum (see 03.png)

-> turning poti further to the right, Z-Roation Bar goes (linear again) back to 50%

 

So, in prinziple it works - but why don't I have a linear growing of the axis?

Any Idea?

 

regards

 

I'm thinking if the poti connection is correct, the outer pins should connect to the 5v and ground repectively, and the 3rd pin should connect to the analog pin 1~8, please refer to this page:

http://arduino.cc/en/Tutorial/AnalogReadSerial

 

AnalogReadSerial_BB.png

overpro = I'm not good at Nintendo Mario and always get "Game over" pretty fast, so over~~pro

Link to comment
Share on other sites

Overpro, maybe my setup isn't working correctly. With a wire connected from Pin 30 to Pin 38 (with the Diode and switch in place on breadboard) i get the Button 1 light on the CVP Joystick #2, i can move the Row wire (#38 all the way down to Pin 53 and get to Button 16 on the display. I move the wire from Pin 30 to Pin 31 and repeat with wire from Pin 38 to Pin 53 and i get Button 17 to Button 32...but that's it. I get no response from the rest of the column pins to activate the Button lights on the CVP Joystick #1 (the one showing the Axis sliders). I have GOT to be doing something wrong...

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...