Forum Rule: Always post complete source code & details to reproduce any issue!
Page 7 of 7 FirstFirst ... 5 6 7
Results 151 to 162 of 162

Thread: Many axis joystick

  1. #151
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,579
    Quote Originally Posted by obzai View Post
    Can anyone see any problems with trying to use a rotary encoder to act as a Mouse.scroll() wheel in a Teensy build of a hybrid mouse-keyboard-gamepad-mega-joystick with more than 8 axes?
    This should be possible. Certainly Teensy gives you the way to implement these HID interfaces and precisely control what actually gets sent to your PC.

    To specifically answer your question, here are some challenges you might face.

    If using Microsoft Windows, the default joystick driver might not recognize more than 8 axes, even though it's properly implemented on the Teensy side (assuming you've edited the code to enable the bigger HID joystick report - or otherwise edited the USB code).

    In designing your code on the Teensy side, you'll want to avoid delays, so you're always being responsive to all the input signals. Simple as this sounds, real-world signals often aren't as nice as you might like and require "debouncing" or other techniques. Many people have gone down a path of adding delays in their code, which tends to work for only 1 signal, but then becomes really difficult when the delays to clean up 1 signal cause everything to be unresponsive to all the others. Teensyduino has features like elapsedMillis to make this easier, so if you need to do this sort of work I recommend using those and avoid delay().

    HID provides fixed bandwidth. At best you can send 1000 events per second. That's usually plenty, but it can quickly become a limitation if you do things inefficiently. The joystick functions have a way to freeze, so you can change multiple settings and have it all go out the USB cable to your PC as a single packet.

    If you do approach the bandwidth limits, those functions to send will end up waiting. If using the Encoder library, you may see the result of several changes at once. Likewise for other inputs, if those functions have to wait, your code may be "blind" to changes. Teensy's USB stack does buffer several outgoing packets, which gives you some flexibility. But as a general rule, if you try to sustain close to or more than 1000 updates per second, you will run into HID bandwidth limits and ultimately your code will suffer waits in the transmit functions.

  2. #152
    Junior Member
    Join Date
    Aug 2018
    Posts
    5
    Fantastic, thanks for the detailed reply Paul.

    Sounds like I could reasonably expect to build something that will work using this approach. I'll see how I go.
    Thanks for your work on the Teensy boards Paul, they're my favourite "do anything" solution. I always keep a couple on hand.

  3. #153
    Junior Member
    Join Date
    Sep 2018
    Posts
    1
    I tried to code a 8 axis joystick. I took the many axis joystick disabling all sliders beyond 2. Only data from the 6 axis are transmitted, sliders remain at zero
    Click image for larger version. 

Name:	Joystick.JPG 
Views:	62 
Size:	49.9 KB 
ID:	14715

  4. #154
    Junior Member
    Join Date
    Jul 2019
    Posts
    1
    Hello Paul, i replaced the files and now i'm getting a serial error, like it was not recognized:
    "C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -fno-exceptions -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=144 -DARDUINO=10807 -DF_CPU=96000000 -DUSB_EVERYTHING -DLAYOUT_US_ENGLISH "-IC:\\Users\\NICOLA~1\\AppData\\Local\\Temp\\arduin o_build_113933/pch" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teen sy3" "C:\\Users\\NICOLA~1\\AppData\\Local\\Temp\\arduin o_build_113933\\sketch\\sbus2joystick.ino.cpp" -o "C:\\Users\\NICOLA~1\\AppData\\Local\\Temp\\arduin o_build_113933\\sketch\\sbus2joystick.ino.cpp.o"
    In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/usb_serial.h:34:0,

    from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/WProgram.h:54,

    from C:\Users\NICOLA~1\AppData\Local\Temp\arduino_build _113933/pch/Arduino.h:6,

    from C:\Users\NICOLA~1\AppData\Local\Temp\arduino_build _113933\sketch\sbus2joystick.ino.cpp:1:

    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/usb_desc.h:297:48: error: 'NUM_ENDPOINTS' was not declared in this scope

    extern const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS];

    Any idea?
    thanks

  5. #155
    I have a question.. I sort of asked this in another thread where I was pointed to here, so this will probably be a better place to ask this..

    I have read through the thread and think I understand a bit about what is going on here but then again maybe not because I have never messed with this stuff..

    Anyway, what I would like to do is Expand the USB HID Joystick interface to access at least 64 buttons, Maybe 128. Unlike most of the examples on here I am not really in need of extending the Axis Count, However I also need to retain serial functions for the device for other things I plan on doing.

    I would LIKE TO do this to the Teensy LC as that is the primary device I am using, though I have noticed that most of this work has been done on the 3's so I am not sure of the possibility. I have located the USB headers information based on an earlier post but don't see anything specifically for the LC in there so any info on where to do adjustments would be helpful if it is even possible to do..

    Because I am not familiar with HID headers pointers in where to research this or guidance on the changes would be greatly appreciated.

    Thank you

  6. #156
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,424
    I am no expert on this end of it. I have done more on the side of usbhost_t36 to try to handle different USB devices... I don't think there is much difference here between T3.x and TLC for this, they both use the teensy3 directory under cores.

    But if I were doing it, I think some of the areas I would look to change include:

    usb_desc.c - need to change the number of buttons... For example if you look for the JOYSTICK_SIZE==12 portion, you will see:
    Code:
            0x15, 0x00,                     //   Logical Minimum (0)
            0x25, 0x01,                     //   Logical Maximum (1)
            0x75, 0x01,                     //   Report Size (1)
            0x95, 0x20,                     //   Report Count (32)
            0x05, 0x09,                     //   Usage Page (Button)
            0x19, 0x01,                     //   Usage Minimum (Button #1)
            0x29, 0x20,                     //   Usage Maximum (Button #32)
            0x81, 0x02,                     //   Input (variable,absolute)
    So would try changing those 0x20 (32) to the size you need. Note: That will change the JOYSTICK_SIZE. Each 8 bits will add 1 byte to the size...
    So you may want to either modify these tables and/or make another copy #elif JOYSTICK_SIZE == <YOUR SIZE>

    You will need to update usb_desc.h to have the new size for your joyststick data...

    You will probably need to update usb_joystick.h to handle the additional buttons, that is the code again has specific code for size ==12 and == 64 again not knowing enough of which way you wish to start from (like how many axis) not sure which one is easiest for you to start from.

    My guess is probably the 64 one as the ==12 assumes all of the buttons fit into one uint32_t value and all of the axis are aligned to the 32 bit starting memory locations... Actually both assume a certain alignment in memory for where the axis values are stored...

    Again there are probably other things I am missing, but that is where I would start

  7. #157
    Yea that is my concern as in some ways it seems so simple , but is it really just a matter of changing the size of those parameters.. Thank you though on the information about the LC using the T3 core code as that one makes it seem feasible and two points me in the direction of the files to mess with..

    I think I may be able to figure it out from there but if anyone else or you have any further information it is always appreciated.

  8. #158
    Oh Hmm.. It looks like Paul has included the code for the extreme Joystick IN the core data as I was just looking at the usb_desc.c in the teensy3/Core/avr and noted this:

    "
    #elif JOYSTICK_SIZE == 64
    // extreme joystick (to use this, edit JOYSTICK_SIZE to 64 in usb_desc.h)
    // 128 buttons 16
    // 6 axes 12
    // 17 sliders 34
    // 4 pov 2
    "

    This will be beyond of course what I generally would need but hey seems much easier now

  9. #159
    Junior Member
    Join Date
    Aug 2019
    Posts
    4

    More than 6 axis working?

    Quote Originally Posted by Brion Sohn View Post
    Oh Hmm.. It looks like Paul has included the code for the extreme Joystick IN the core data as I was just looking at the usb_desc.c in the teensy3/Core/avr and noted this:

    "
    #elif JOYSTICK_SIZE == 64
    // extreme joystick (to use this, edit JOYSTICK_SIZE to 64 in usb_desc.h)
    // 128 buttons 16
    // 6 axes 12
    // 17 sliders 34
    // 4 pov 2
    "

    This will be beyond of course what I generally would need but hey seems much easier now
    Hi, your thread has helped me greatly in creating my own custom flight sim controls. I am having the issue of not being able to get more than 6 axis working at one time however and have tried tweaking the usb_joystick.h file with no success. I've tried the vanilla extreme joystick test and still cant get more than 6 axis working at once. Am I missing something here? Any help would be greatly appreciated!

    - Silco

  10. #160
    Junior Member
    Join Date
    Sep 2019
    Posts
    1
    Hi, is it maybe possible to emulate an USB Hub and group the control axis like 4 throttle, pitch, mixture, oil & water cooler so that windows has no problem to find all axis, it would also make the settings in the actual sim easier? Thx

  11. #161
    Junior Member
    Join Date
    Mar 2019
    Posts
    3
    Somewhat of a newbie here. Planning on making a controller that is entirely standard aside from the addition of 6 more sliders.

    I'm thinking of ordering a Teensy 4.0 just because. I haven't delved too deep into this thread yet, so I still barely know where to start, but I did see that everything here isn't compatible with Teensy 2.x boards, since it was done on 3.x. Will there be any compatibility problems if I were to do this on the 4.0?

    Thanks

  12. #162
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,899
    4.0 is very new, unsure how complete USB joystick support is. It also has ADC hardware that seems to take more effort to get good results out of. You certainly do not need the performance for this, so would suggest the LC or 3.2 would be a better fit. What may get complicated is your axis, and the number of them, both Teensy LC and 3.2 have only 10 analog inputs that are easy to access so 4 axis but two sliders will only just fit. You will also need to make decisions about how much hacking around you want to do making those 10 axis work. The less pretty solution may involve having two teensies sharing the axis in a more default configuration.

    Certainly before buying anything would download and install https://www.pjrc.com/teensy/td_download.html teensyduino and put together some test code and make sure it compiles.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •