Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Analog USB HID interface update.  (Read 2570 times)

0 Members and 1 Guest are viewing this topic.

daveb

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 28
  • Last login:May 05, 2010, 08:29:59 pm
    • B-Spec Labs
Analog USB HID interface update.
« on: January 07, 2004, 03:59:54 pm »
Hi everyone.  I've made some progress on the USB interface for analog controls that I've been working on.  Right now I've got a couple prototype pcbs that have 5 analog axes implemented as joy1 x, joy1 y, joy1 z, joy1 x rotation, and joy1 y rotation.  Also, I've got 14 buttons working.  From the testing I've done, it seems to work just as well with 5k pots and 100k pots.  There does seem to be a minor bit of jitter in the analog axes from time to time, though I suspect it's being introduced by the pot. wiring or perhaps the cheap radio shack pot's I'm testing with.  Testing continues...
I've played mame with it and it works fine, though twiddling pots isn't the best way to play:)  
As far as using multiple device id's goes (to keep multiple interfaces from swapping places on each boot-up), I'd rather not have that jumper configurable at the expense of a button, so I'm considering building the devices with different hard-coded id's.  How does this sound to you guys? Still a product you'd be interested in?

tmasman

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 537
  • Last login:January 04, 2024, 03:50:44 pm
  • Hello...
    • My (no so up to date) Home
Re:Analog USB HID interface update.
« Reply #1 on: January 07, 2004, 04:43:13 pm »
With all the work you have in it (& have left to go), what price range are you going to be looking at?
$10-20
$20-30
$30-40
more?

Just asking because I know everyone wants to know...
I might eventually be interested, but I've got too many projects on the plate to add another one...
I'm not a freak!...
Oh wait...
Yes I am...

daveb

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 28
  • Last login:May 05, 2010, 08:29:59 pm
    • B-Spec Labs
Re:Analog USB HID interface update.
« Reply #2 on: January 07, 2004, 05:25:52 pm »
I'm targeting a price of not more than $30, including the board and a 10' usb cable.  Actually, I'm checking out parts suppliers now, and from what I've seen so far, I expect to be right on target.
Dave

DarkKobold

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1040
  • Last login:June 18, 2013, 11:31:23 pm
Re:Analog USB HID interface update.
« Reply #3 on: January 07, 2004, 05:33:17 pm »
Have you checked microchips site to see an analog example? My guess is you are probably polling too fast. The voltage needs to stabilize before it can be read correctly. Since you are using the PIC16C745, I am guessing you are running it at 24MHz. Try using a slight delay time between polling the pots.
-------------------------------------
My games: Tapper, Asteroids, Cocktail-MAME, Tron, ROTJ, Tempest, Star Wars (not working)
My wants: Warlords Cocktail

Xiaou2

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4135
  • Last login:August 01, 2025, 11:49:43 pm
  • NOM NOM NOM
Re:Analog USB HID interface update.
« Reply #4 on: January 07, 2004, 05:51:55 pm »

 I dont think losing a button would make a huge difference.  I think most would just use the interface for the pots only rather than anything else.  Probably use a keyboard encoder instead.

 I say just make the thing easier to configure with as many options as possible.


Minwah

  • Trade Count: (+3)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7662
  • Last login:January 18, 2019, 05:03:20 am
    • MAMEWAH
Re:Analog USB HID interface update.
« Reply #5 on: January 07, 2004, 06:59:18 pm »
Would it be possible to wire up a switch to allow single or dual axis pedal setups?

I have a diagram somewhere of how to use a DPDT switch to that effect with the pots wired using 2 wires each, but I have never wired pots using all 3 terminals before...

All sounds good :)  FWIW I probably would use many buttons either, maybe a couple max.

Tailgunner

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1156
  • Last login:October 06, 2009, 01:21:16 pm
  • ...
Re:Analog USB HID interface update.
« Reply #6 on: January 07, 2004, 08:51:51 pm »
Given the choice I'd rather have all 14 buttons available.

Tiger-Heli

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5447
  • Last login:January 03, 2018, 02:19:23 pm
  • Ron Howard? . . . er, I mean . . . Run, Coward!!!
    • Tiger-Heli
Re:Analog USB HID interface update.
« Reply #7 on: January 08, 2004, 07:16:22 am »
I'm definitely interested in the project.

I agree with MinWah, I would like to see a single-dual axis switch.  See http://www.gunpowder.freeserve.co.uk/wheels/wiring.htm if you're not familiar with what he's talking about.

I also would prefer not to lose a button input, given an option.

Hard-coding the devices sounds good, although rather than buy a bunch of these, I would probably mount one in a project box and connect controls with DB9 or DB15 connectors.

Fairly basic question - I know gameport joysticks tend to lose calibration and need to be recalibrated fairly often.  Do USB joysticks and/or this interface have the same problem, or does that correct it?
It's not what you take when you leave this world behind you, it's what you leave behind you when you go. - R. Travis.
When all is said and done, generally much more is SAID than DONE.

Lilwolf

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4945
  • Last login:July 31, 2022, 10:26:34 pm
Re:Analog USB HID interface update.
« Reply #8 on: January 08, 2004, 09:51:54 am »
GREAT!

1) Do you need beta testers?  I will buy a setup for you in the beta board if you want some testers before mass purchasing.

2) I don't know about others... but 14 inputs would be nice... but many people already have a keyboard encoder.  So I would have to think of setups... but I think people with swappable or multiple controls on their cab will still need more then 14 inputs...  

3) Consider asking around for software options.  The dual pedal option would probably increase the amount of real pedals by 3 fold.  I believe that there is 4 differnt types of analog pedals.  If you could support them all (these wont change from game to game I don't believe... just the brand / pedal)... Anyway, you might really increase your setup.

4) Hotswappable?  I would want it to work with 2  T2 guns, a starwars yoke, a flight stick.,.. but never at the same time.

5) Beta testers?


Dave_K.

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1807
  • Last login:July 06, 2022, 03:27:30 pm
    • Arcade Fever
Re:Analog USB HID interface update.
« Reply #9 on: January 08, 2004, 12:53:11 pm »
Do you use a special USB driver or generic joystick driver which supports digital and analog inputs?

daveb

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 28
  • Last login:May 05, 2010, 08:29:59 pm
    • B-Spec Labs
Re:Analog USB HID interface update.
« Reply #10 on: January 08, 2004, 01:02:23 pm »
Well, I've been thinking about the single/dual axis wiring problem and I have come up with individual wiring solutions for both, but they dont seem easily switchable - at least not by one switch.  Anyways, I'll keep thinking about it and see what I come up with :)
As for the recalibration issue, in my testing thus far, I have not experienced that problem.  I imagine though, that due to the nature of the pots and the mechanics of the joysticks, the center point may experience a slight drift from time to time, possibly requiring a recalibration to correct.
As for hotswapping, it might be possible, but i'm not sure it's a good idea - it may place undue strain on the a-d converters.  In the worst case, you'd just need to unplug the usb cable from the device before swapping the analog connections.
Finally, with regards to the driver, the advantage of the USB HID (Human Interface Device) standard is that the device reports it's capabilities to the operating system when it's first plugged in and enumerated. Then the operating system provides a driver in real time that supports the device capabilities, installing the device automatically.  I believe all versions of windows after 98SE, as well as Mac OS (not sure which version) and Linux Kernel 2.4+ support HID devices.
Dave

Tiger-Heli

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5447
  • Last login:January 03, 2018, 02:19:23 pm
  • Ron Howard? . . . er, I mean . . . Run, Coward!!!
    • Tiger-Heli
Re:Analog USB HID interface update.
« Reply #11 on: January 08, 2004, 02:04:05 pm »
Finally, with regards to the driver, the advantage of the  I believe all versions of windows after 98SE, as well as Mac OS (not sure which version) and Linux Kernel 2.4+ support HID devices.
98SE inclusive, (I am sure 98SE supports it.  Possibly even as far back as 95 release B, but I'm not sure about that one.)

It's not what you take when you leave this world behind you, it's what you leave behind you when you go. - R. Travis.
When all is said and done, generally much more is SAID than DONE.

Minwah

  • Trade Count: (+3)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7662
  • Last login:January 18, 2019, 05:03:20 am
    • MAMEWAH
Re:Analog USB HID interface update.
« Reply #12 on: January 08, 2004, 02:14:56 pm »
There does seem to be a minor bit of jitter in the analog axes from time to time, though I suspect it's being introduced by the pot. wiring or perhaps the cheap radio shack pot's I'm testing with.  Testing continues...

I have encountered this before when wiring 100k pots to the gameport, but also with commercial (gameport) joysticks.  I too am not sure what the cause is, I have used fairly expensive cermet (not carbon) pots.

Thanks for the answer about the single/dual circuit pedals...

I would have thought hot-swapping without disconnecting from USB would be a bad idea.  Similar to disconneting optics from a mouse board / Opti-Pac without disconnecting.  I could be wrong tho  :D

daveb

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 28
  • Last login:May 05, 2010, 08:29:59 pm
    • B-Spec Labs
Re:Analog USB HID interface update.
« Reply #13 on: January 09, 2004, 02:34:30 pm »
Just a quick update here.
The jitter problem seems to have been the combination of a timing issue (thanks DarkKobold - I did have a delay, but apparently it wasnt long enough), a tiny little bug in the code, and noise introduced through the movement of the wires I have connecting the pots.  The first two issues have been fixed, and the last one goes away if I'm not pulling on the wires when I adjust the pots:)
Would anyone be able to tell me the 'normal' state of single axis pedals? i.e. without pressing them down do they give a reading at the middle of the axis, or the bottom?
My initial guess is that they start at half-way, and pressing one pedal raises the reading, while pressing the other lowers it.  If I've modeled the behavior correctly, connecting single axis pedals wont be a problem, though it will require a couple current-limiting resistors not necessary for dual axis operation.
As for a circuit to switch between the two, well, it can be done with either an 8-pole double throw (8PDT) switch, or a couple of 4PDTs, or 4 DPDT switches. It's not complicated, it's just a lot of wiring :)
Dave

Tiger-Heli

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5447
  • Last login:January 03, 2018, 02:19:23 pm
  • Ron Howard? . . . er, I mean . . . Run, Coward!!!
    • Tiger-Heli
Re:Analog USB HID interface update.
« Reply #14 on: January 09, 2004, 02:45:39 pm »
My initial guess is that they start at half-way, and pressing one pedal raises the reading, while pressing the other lowers it.

That's exactly how they work in Windows.  Not sure how MAME interprets it.

Really cool that the DPDT switch will work with it.

Thanks
It's not what you take when you leave this world behind you, it's what you leave behind you when you go. - R. Travis.
When all is said and done, generally much more is SAID than DONE.

DarkKobold

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1040
  • Last login:June 18, 2013, 11:31:23 pm
Re:Analog USB HID interface update.
« Reply #15 on: January 09, 2004, 02:58:15 pm »
Daveb: Have you considered building another interface, using the PIC16C765? It would allow for an extra 16 buttons for the interface....

Also, have you considered adding 2 more buttons to your report descriptor to allow for the pedals to act as buttons - Imagine this -
 
You press the pedal down X amount - the signal reads < X, send button 15, or 16? It would allow for digital games to use the same controls as analog games... Could also use it for left right, up down. That would add 4 more buttons, and take a little extra programming. If you want help with this, just ask.

Also, are you planning on sharing the source code? I am curious mostly to see your report descriptor.

Did you write this in ASM or C? And if C, which version? PICC, or Hi-Tech C?
-------------------------------------
My games: Tapper, Asteroids, Cocktail-MAME, Tron, ROTJ, Tempest, Star Wars (not working)
My wants: Warlords Cocktail

daveb

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 28
  • Last login:May 05, 2010, 08:29:59 pm
    • B-Spec Labs
Re:Analog USB HID interface update.
« Reply #16 on: January 09, 2004, 03:49:28 pm »
DarkKobold: Yeah, actually, I have been considering that.  I only count 8 extra buttons though: on the 745 theres digital inputs on RA4, RB0-7, and RC0-2,6,7. And for analog inputs, AN0-4 = 14 digital and 5 analog.  On the 765 I see digital RA4, RB0-7, RC0-2,6,7, and RD0-7, and analog AN0-7 = 22 digital and 8 analog.
Of course, the analog pins could be used as digital pins, but not simultaniously without some kind of multiplexing...
For now, in the report descriptor, I've got the 5 axes mapped to x,y,z,x-rot, and y-rot.
I'm not sure I follow you with regards to the extra buttons... are you saying, for instance, with the x-axis, x-max and x-min could be mapped to two extra buttions? I'm not quite sure what advantage that would bring, as I thought analog axes could be mapped to digital axes in mame anyways...
Or do you mean that, if someone doesnt need all 5 axes, they could wire up buttons in their place? Please elaborate :)
The code itself was written in ASM, based on microchip's firmware 2.0 (polling version) with a few bugs squashed.  The biggest problem I had with microchip's code was that it seemed to begin polling the hardware too soon (i.e. before the report descriptor was sent, which is handled in the ISR), which crashed the device.  I hadn't planned on releasing the source, but it's something I'll consider.  As for the report descriptor, I wouldn't mind sharing it with you, but I'm curious as to why you'd like to see it. :)

DarkKobold

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1040
  • Last login:June 18, 2013, 11:31:23 pm
Re:Analog USB HID interface update.
« Reply #17 on: January 09, 2004, 05:57:53 pm »
Daveb: I didn't count, sorry - Your also forgetting Port E, which, (doing from memory) is another 3 - 4 buttons for digital.

I was unaware that you could map analog to digital in MAME. I've only played one mame game with real Analog, and haven't tried any others. It may help for other emulations, such as Snes (Who wouldn't want to play mario kart with a wheel and pedals? :) )

It was more the idea - at  x axis  <= 30%,  button 15 held down, at x axis  >= 70% button 16 held down. This would allow for non digital/analog emulators to use your interface as well. Same for accelerator - X pushed to 50%, another button triggers.

As for the report descriptor, I'm just curious, because everything I've ever read says "The report descriptor is HELL!" Thats all. Not trying to steal code ;)
-------------------------------------
My games: Tapper, Asteroids, Cocktail-MAME, Tron, ROTJ, Tempest, Star Wars (not working)
My wants: Warlords Cocktail