-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DRV8833-Based Rumble (for XInput) #1090
DRV8833-Based Rumble (for XInput) #1090
Conversation
After getting my own DRV8833 module to test with, here's some things worth noting for documentation's sake.
Wiring as follows:
Use AOUT and BOUT pins for the haptic motors of choice. |
Further notes. PWM FrequencyPWM frequency set to 10 KHz by default. Probably doesn't need to be ever touched by the average user, but wanted to leave customizable. With the DRV8833, anything under 50 KHz should fly. Duty Cycle Min/MaxFirst, consider Duty Cycle Min = 0 and Duty Cycle Max = 100 (ie. no rescaling done). The XInput rumble packets and the GamepadRumbleState structs use uint8 values for rumble, giving a range of 0-255. This range gets translated to duty cycle factors of 0/255, 1/255, 2/255, ... , 254/255, 255/255, giving a new range of 0% - 100%. The problem is that the lower end of this range gives too low an average voltage to drive the motor (the minimum operating voltage is motor-specific). The Duty Cycle Minimum/Maximum seek to resolve this. Setting these rescales the 0% - 100% range to DutyCycleMinimum% - DutyCycleMaximum%. Note, however, that no matter the rescaling, uint8 value of 0 will ALWAYS turn off the motor. Experimentally, with the XBOne motors (Vybronics VJQ24-35F580C), the motors started operating reliably at about 25% duty cycle, meaning I set Duty Cycle Minimum to 25% and kept Maximum at 100%. Thus, for the nonzero uint8 range of 1 - 255, the voltage will range from about 5V * 0.25 = 1.25V to 5V * 1.00 = 5V. These values will have to be obtained on a per-motor basis by the user either from the motor's datasheet or experimentally. Hooking up VMDepending on the current draw of your motors, you may want to STRONGLY consider using VBUS (or maybe VSYS?) to connect to the VM pin on the DRV8833. If the motors have high enough current draw, they could easily pull more than the Pico is rated for. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work, thank you for contributing this!
Adds DRV8833-based rumble functionality for XInput.
There are three main sets of changes: