RetroPie Joystick

Status
Not open for further replies.

T-Prime

Member
Good Morning,

I am using Teensy 3.2 to build a custom gamepad for RetroPie. I'm running into a problem where RetroPie is only detecting the analog input in one direction (Axis 0+ and Axis 1+). Pushing the joystick in the opposite direction gives an "Already Taken" message. This suggests to me that it is reading input in both directions as just one direction. I believe this is caused by the Teensy returning analog values between 0 and 1023, with 512 as the 'centre'. It looks like RetroPie wants a setup with 0 as the 'centre', positive numbers in one direction and negative numbers in the other. Do any of you know how I can implement this? I'm currently using the Complete Joystick example, with the Z-axis and Hat functions commented out.

Thank you,
 
I have done so. With a USB gamepad I get readings that are centered at 0 and rang between positive and negative 32767 for both axes, which makes sense. I get the when I wire two pots to the analog input of the teensy, but with the thumbstick I get the following:

X+ = 32767
Y+ = 32767
X- ~ -9363
Y- ~ -15235

Centered at approximately 20000, 16000. That seems wrong to me. I have posted this information on my suppliers forum to see if the unit may be defective.

Thank you.
 
Your next step probably involves a voltmeter. Watch the actual voltage at the Teensy analog input pin as you move the control and see the numbers from jstest. That won't solve anything, but it can help build some idea of where the problem is really happening.

Maybe also try with the signal disconnected from Teensy. Does the voltage response change?
 
Using my 10K pot as a control I came up with the following results. I did not include the positive axes because they all registered 32767 in the range of 3 to 5 V. The Voltage values were taken at the farthest end of the device's physical movement.

10K Pot (-)10K Pot (center)Joy X (-)Joy X (center)Joy Y (-)Joy Y (center)
Voltage0V1.43-1.81V0.80V2.57V1.19V2.42V
JSTest-327670-1659719800-621415400

[/td]
 
Last edited:
Where do you have the positive of the pot connected?

The teensy is a 3.3V device so you need to have the pot inputs ranging from 0 to 3.3V, going above that doesn't do anything useful and risks blowing things up. Looks like you have some electrical issues with how the pots are wired. Should be gnd and 3.3V for the two outer pins and the wiper should produce 0 to 3.3V with nothing else connected.
 
Wiring to the 3.3V terminal I get the following results:

X
Range: 0.66-2.71
Center: 1.65

Y
Range: 0.54-2.46
Center: 1.56
 
Now that I'm applying what appears to be the correct input voltage I get results that are a bit nicer looking. The joystick now centers at a JSTest reading of 0 on both axes, however it does not reach the maximum values of +/- 32767. That makes sense, given that my voltage readings do not quite reach 0V or 3V. Unfortunately the values do not seem to deviate far enough from zero to be picked up by the emulationstation button mapping utility With the exception of "axis 0-" which reaches a JSTest value of -24683.
 
Looks like there is still some resistance in the mix. Photo of the layout would be good, along with doing a resistance check of your sticks out of circuit to see if they have some sort off minimal value setup going on. You should get end to end values that stay constant moving the axis, and that value to zero going from the middle pin to either outside pin.

Edit: It's unlikely but if your sticks do have components that make them work this way the map function
https://www.arduino.cc/en/reference/map
Would be how you turn those values into the full range the pi wants. Looses resolution and will probably stuff with your zero point so fixing things electrically is better.
 
Last edited:
I'll Try to get a decent picture this afternoon. Here are the resistance values

X to GND
Range: 1.94K-5.00K
Center: 3.82K

X to V+
Range: 2.57K-5.16K
Center: 3.98K

Y to GND
Range: 2.48K-5.25K
Center: 3.92K

Y to V+
Range: 2.20K-5.18K
Center: 3.97K
 
You can remap using and If statement but easier if you can use a single map statement. There is certainly something up with the axis there, since would have expected all of those to get close to zero. Confirming this was with the stick out of circuit and unpowered?

Looking at the numbers it looks like there is a 2.5k in the center leg, and a 2.5k pot but no idea why it would have been done that way, nor what is up with the x low end looking that way. You may have to dig a bit into the physical structure of the stick. Does suggest there is nothing wrong with the code though.
 
I have just replaced my thumbstick with:

https://www.adafruit.com/products/2765 and
https://www.adafruit.com/products/3246

(These were my first choice anyway, but were out of stock when I made the first order)

I soldered the stick to the board and wired it to the teensy with the exact same cables as the previous. Worked flawlessly the first time with no messing around needed.

I'd still like to know if the previous unit I received is actually working as it's supposed to, though. Do any of you have any insight? My understanding is that these two are supposed to be the same, just set up to connect differently. Is that accurate?
 
Status
Not open for further replies.
Back
Top