Working on a joystick. Seems like any protocol I use to read from peripherals is going to be bottlenecked by having just one input. My microcontroller might have multiple ADCs, but there’s just one processor stepping through them. Same for spi, or i2c, or uart. There’s really only ever one sensor reporting back its data at a time.

I know this might not matter for measurement resolution. Especially if you’re polling at like 115k serial or something, but…

That’s 8 bits per axis, and three axis. Now that’s at least 34 bits. To sample each axis we’re down to only 4.5k samples per second. Plus whatever other cycles the controller has to handle… even if I spent half that time doing microcontrolle cycles at like 2k we’re probably still well with the best star craft apms or whatever. I’d still like to find some way to really over engineer this thing.

I read a little about tdm, but that’s out of my league and I don’t know if you could even have 3 simultaneously signals that way

I’m thinking a microcontroller for each axis, and a usb port for each of them. So it appears like 3 different controllers to the computer. The user would just have to map the axis from the 3 controllers into 1 in their game software. I assume the steam remapping could do this.

Is it just going to get smashed back into one thread in the computer’s usb hub anyway?

Any other suggestions?

  • cmnybo@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    9
    ·
    11 months ago

    Only having one ADC can be an issue when you need readings to be in phase, but for reading any sort of human interface device it doesn’t matter at all. Just cycle through your inputs one at a time. Some microcontrollers even have hardware to scan through multiple inputs automatically. You can use DMA to read the ADC and send data out over whatever communication peripherals your microcontroller has without using much CPU time.

    If you are using USB HID, you are limited to a 1000 Hz update rate and that’s really overkill already. You can have up to 8 analog axis in a USB HID game controller plus lots of buttons.

    • Beko Pharm@discuss.tchncs.de
      link
      fedilink
      English
      arrow-up
      2
      ·
      11 months ago

      This. It’s basically only a thing for rotary encoder, where interrupts should be used for the reading, so they don’t miss a beat.

      Also: Combining several joystick devices on the PC again is a pain in the neck especially if the game only supports one device of each kind.

  • Nawor3565
    link
    fedilink
    English
    arrow-up
    4
    ·
    11 months ago

    Honestly… I kinda think three microcontrollers is way overcomplicating things preemptively. I would try just a single MCU first, and see if the response time is adequate. If there’s any sort of noticeable input lag or delay, then try the multiple MCU route.