Author Topic: Recommendation for PIC microcontroller for HID USB Controller  (Read 6906 times)

0 Members and 1 Guest are viewing this topic.

Offline aiq25Topic starter

  • Regular Contributor
  • *
  • Posts: 241
  • Country: us
Hello. I'm working on a portable gaming system using the Pi Zero and I want to make my own PCB for it. I never got PCB's made, so I think this might be a good experience for me (well not for hobby use anyways).

I'm looking to create a USB HID controller to use with the Pi. In my prototype I directly soldered onto the Pi Zero pins. From what I understand, using a USB controller is a better option.

What PIC micro would be the cheapest within an SOIC package that I can use a USB HID? I really don't feel like soldering anything smaller than SOIC. I would like at least 12 I/O pins for buttons, 1 ADC (for reading battery voltage), 2 I/O pins for driving battery indicator LED's.

I'm also open to an Arduino based solution, if I can use an Arduino bootloader.

Thanks!
 

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1678
  • Country: gb
Re: Recommendation for PIC microcontroller for HID USB Controller
« Reply #1 on: April 25, 2017, 02:42:28 pm »
The PIC16F1455 seems to be the cheapest USB capable PIC.  Available as SOIC14 (there's your 12 I/O, but one is input only).

You could just use pre-made playstation knock-off controllers.  Cheap and cheerful.
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7893
  • Country: nl
  • Current job: ATEX product design
Re: Recommendation for PIC microcontroller for HID USB Controller
« Reply #2 on: April 25, 2017, 03:10:45 pm »
The Arduino Micro/ Leonardo does USB HID. Probably it is ten times easier to get it working.
 

Offline theatrus

  • Frequent Contributor
  • **
  • Posts: 352
  • Country: us
Re: Recommendation for PIC microcontroller for HID USB Controller
« Reply #3 on: April 25, 2017, 04:01:47 pm »
That PIC is my go to for super-cheap-and-cheerful USB. The libraries are not terrible either.

You can also look at an Arduino Teensy - it will be total overkill spec wise but is well supported.
Software by day, hardware by night; blueAcro.com
 

Offline aiq25Topic starter

  • Regular Contributor
  • *
  • Posts: 241
  • Country: us
Re: Recommendation for PIC microcontroller for HID USB Controller
« Reply #4 on: April 25, 2017, 06:47:36 pm »
Thanks for the recommendations. Is there are recommendation for a 20-pin USB PIC micro? I would like to have couple of I/O's extra in case I need them for something.
 

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1678
  • Country: gb
Re: Recommendation for PIC microcontroller for HID USB Controller
« Reply #5 on: April 26, 2017, 01:02:06 am »
The Arduino Micro/ Leonardo does USB HID. Probably it is ten times easier to get it working.

I forgot about the Pro micro!  I use that *a lot* for prototyping, and its USB libraries are stable.

As for 20-in PIC's, I'm sure there are newer and cheaper ones, but I still have projects using the PIC18F14k50. 15 I/O, 16kbyte of program space, nice little job for a step above the 16F1455.

Microchips libraries can be a sod to use, at least they were last time I did anything USB in earnest (MIDI, keyboard emulator etc..). That said, I ended up cheating and using an example project, and modding it. Either way, at least the IDE and libraries are free.  But so are Arduinos. All depends on what you're familiar/comfortable with.
 

Offline H.O

  • Frequent Contributor
  • **
  • Posts: 851
  • Country: se
Re: Recommendation for PIC microcontroller for HID USB Controller
« Reply #6 on: April 26, 2017, 05:09:09 am »
16F1459 would be the equivalent of the 1455 but in a 20-pin package, next would be the 18F13K50 / 14K50. Those three are the only 8bit, 20-pin parts with USB peripheral
- according to Microchips search tool.
 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2507
  • Country: gb
Re: Recommendation for PIC microcontroller for HID USB Controller
« Reply #7 on: April 26, 2017, 09:37:48 am »
I thought I would never find myself arguing against PIC but here we are...

Depending on your application you might like to consider Teensy.  I have a Thrustmaster F22 joystick and bits and pieces which I have been meaning to revitalise when I have time (a bit like https://forum.pjrc.com/threads/33371-Thrustmaster-T-Flight-Hotas-X-Teensy-MCU-mod-(USB-Flight-Joystick-Throttle) and for this project I need USB and I/O.  Teensy seems to be a good fit.

But... Also checkout... http://www.leobodnar.com/shop/index.php?main_page=product_info&products_id=204&zenid=bc971931b76a59a1848895004f293822
Looks like he uses 18F2458

Could you be a bit more specific about your requirement?


Teensy has quite alot of USB HID support.... https://www.pjrc.com/teensy/td_joystick.html
« Last Edit: April 26, 2017, 12:01:53 pm by NivagSwerdna »
 

Offline sanwal209

  • Regular Contributor
  • *
  • Posts: 114
Re: Recommendation for PIC microcontroller for HID USB Controller
« Reply #8 on: April 26, 2017, 09:38:28 am »
Hello,

PIC18F2450/4450 it fullfils your I/O requirements and USB. It costs 3.15 USD on Digikey.
 

Offline aiq25Topic starter

  • Regular Contributor
  • *
  • Posts: 241
  • Country: us
Re: Recommendation for PIC microcontroller for HID USB Controller
« Reply #9 on: April 26, 2017, 01:29:38 pm »
Could you be a bit more specific about your requirement?

I'm looking to create a handheld Pi Zero based gaming system. I'm looking to put all the electronic components I need on one PCB. I have a prototype working but it uses various eBay modules (which I don't entirely trust either) and does not have a USB HID for the game controller. There are at least 12 buttons required for the controller (for what I want to use it for).

I would like to use a micro as a HID device for the game controller. Since I will be using lithium ion batteries, I would like to also monitor the battery voltage and have couple of LED indicators to warn of low battery charge.

I'm thinking I need 14 I/O's for the game buttons and the light indicator, plus one ADC at least for battery voltage monitoring.

I think Teensy might be a good option. I will look into that as well.
 

Offline aiq25Topic starter

  • Regular Contributor
  • *
  • Posts: 241
  • Country: us
Re: Recommendation for PIC microcontroller for HID USB Controller
« Reply #10 on: May 01, 2017, 07:14:11 pm »
I'm thinking the coding might be easier with an Arduino bootloader, so I think I will go with an ATmega32U4. Will need to do more research. Seems like the Leonardo is the best option (instead of the Sparkfun's Pro Micro).
 

Offline stj

  • Super Contributor
  • ***
  • Posts: 2186
  • Country: gb
Re: Recommendation for PIC microcontroller for HID USB Controller
« Reply #11 on: May 01, 2017, 07:21:16 pm »
use an atmel and start with something like this:
http://www.raphnet.net/electronique/usb_game16/index_en.php

most of the work has been done for you!

lots of good stuff on that site!
 :-+
« Last Edit: May 01, 2017, 07:24:11 pm by stj »
 

Offline rfbroadband

  • Supporter
  • ****
  • Posts: 186
  • Country: us
Re: Recommendation for PIC microcontroller for HID USB Controller
« Reply #12 on: May 01, 2017, 07:23:24 pm »
I have used the PIC32MX family many times for USB HID devices. (read the errata if you want to use the MZ series)
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5134
  • Country: ro
  • .
Re: Recommendation for PIC microcontroller for HID USB Controller
« Reply #13 on: May 01, 2017, 07:50:11 pm »
You may also want to look at how fast ADC works on various micros. You can probably do at least 1000-2000 accurate measurements per second which should be enough for a controller, as most of the time the buttons are pressed for more than 1ms so your controller would catch them.

With PICs you have 10 bit ADC and a built in voltage reference that can be configured to 1024mV, 2048mV or 4096 mV  so it's straight forward to do the conversion, you'd have 1..4mV per step.

So for example, it wouldn't be far fetched to have the most important/most often used 8 buttons (let's say left right up down a b x y) on an 8 bit port and set interrupt on change so that your micro would be notified instantly when a button changes, and the less important buttons could be configured to produce various voltage levels when pressed .. for example buttons like start , select (my mind goes to nintendo gamepad) could output 0.5v , 0.75v , 1v etc

Assuming you may want to run the micro either from internal battery (3.7v to 4.2v) if let's say you add some bluetooth module to your controller for example, or from usb while the internal battery charges (5v), you'd probably set the internal voltage reference to 2v , but that still gives you easily enough separation for probably 8-12 buttons.. and easily done with a bunch of 1% resistors. Could potentially even run the ADC in 8 bit if you really need fast conversions.
The only potential downside is that you may or may not miss when two of these less important buttons are pressed at the same time but with clever choice of resistors you could actually detect when two buttons are also pressed.

This could make it possible to use the cheaper 14pin pic, reserving 8 io for most important buttons, 1-2 pins for led (maybe bi-color , amber for charging battery, green for on, or use just one pin and blink the led for charge status), 1-2 pins for adc of the less important buttons and one pic for adc of battery .. you're at less than 14 io pins.

« Last Edit: May 01, 2017, 07:51:57 pm by mariush »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf