Rotary encoder to analog stick mimic output

Hi all,

I’m working on constructing a controller and I have run into a bit of a hitch, which has turned me to looking into Arduino as a microcontroller to control my two rotary encoders.

The project itself, consists of 14 buttons and 2 rotary encoders, my interface itself is simple:

I will be using a Brook Gaming PS4+ Board to run the audio output, 4 directional outputs, 8 buttons, and my two auxillary buttons. EZPZ.

http://www.brookaccessory.com/detail/09922855/

Now it gets more difficult. The board itself offers analog stick inputs which I need to control with my two rotary encoders.

(diagram of the board’s analog inputs here http://imgur.com/U8duDyY)

Basically I want one to mimic y- y+ of the left analog stick, the other to mimic y- y+ of the right analog stick.

From what I understand via researching it all last night, I have turned to Arduino.

I THINK the teensy is what I would like to go with, as it would have the least extra amperage added on to my draw from the console input itself, given I would probably go with just a USB hub to power the two boards and route to the console, plugged into a USB passthrough.

Now, on to my question:

I do not know how to code, however, I am a fast learner. How feasible is it for me to convert the signal of these two rotary encoders into the needed signal for the Brook PS4+ board. I have a Dualshock 4 controller I can disassemble to test directional voltages of the analog sticks themselves, but I am just not sure on the process of actually making this happen through the Arduino. To add, I understand how to connect the encoder itself to arduino, i’ve found tutorials on the nature of that, but i’m not sure on exactly how to output the proper signal for my board to read it.

I’ve also read (a little bit) that the teensy might not be my best choice given that it is more limited in terms of library than the Uno or other similar “full size” arduino boards.

The problem you have to solve is that the Arduino doesn't put out a true analog voltage. For anything between 0 and 5V it uses PWM, so it flickers the pin on and off really fast to make it "appear" to many types of components that there is a certain voltage there. But to something looking at the output of analog sticks, that's not going to work. Those would appear to be moving rapidly back and forth between the extremes instead of sitting in one position.

You'll probably have to find some digital potentiometers that roughly match the range of the sticks you have and control them with arduino. How will depend on what type of digi-pot you get. This would be a good area to research now before you get to far with anything else as your choices here will dictate how the rest will have to work.

Reading the encoders is relatively simple and straightforward. There are even libraries out there to do all the heavy lifting. All you need to do is have a variable that you can add to or subtract from in response to the encoders that represents the position and code to send that position out to the digit-pots.

As far as which board to choose it really doesn't matter much form the design size. This will be doable with just about any board you pick as long as it has enough pins for the encoders and can use whatever communication protocol you need for the digi-pots you pick out. SPI or I2C are most common and most of the boards can do either.

Delta_G:
The problem you have to solve is that the Arduino doesn’t put out a true analog voltage. For anything between 0 and 5V it uses PWM, so it flickers the pin on and off really fast to make it “appear” to many types of components that there is a certain voltage there. But to something looking at the output of analog sticks, that’s not going to work. Those would appear to be moving rapidly back and forth between the extremes instead of sitting in one position.

You’ll probably have to find some digital potentiometers that roughly match the range of the sticks you have and control them with arduino. How will depend on what type of digi-pot you get. This would be a good area to research now before you get to far with anything else as your choices here will dictate how the rest will have to work.

Reading the encoders is relatively simple and straightforward. There are even libraries out there to do all the heavy lifting. All you need to do is have a variable that you can add to or subtract from in response to the encoders that represents the position and code to send that position out to the digit-pots.

As far as which board to choose it really doesn’t matter much form the design size. This will be doable with just about any board you pick as long as it has enough pins for the encoders and can use whatever communication protocol you need for the digi-pots you pick out. SPI or I2C are most common and most of the boards can do either.

So, given PWM is smoothing my signal inappropriately to the desired output, the purpose of the digital potentiometer is to scale that according to the exact outputs I will need?

Do you have any suggestions as to what to search regarding picking my paired digital potentiometer? I do not want to have to ask you to write a ton for me, just general wording on how to look for what I need to know would be much much appreciated. I just finished reading articles on digital pots, rotary encoders, PWM, and i2C.

I’m learning a lot already, so thank you :slight_smile:

SodNINE: So, given PWM is smoothing my signal inappropriately to the desired output, the purpose of the digital potentiometer is to scale that according to the exact outputs I will need?

The PWM isn't smooth at all is the problem.

The way the joystick works is that it has a pair of potentiometers, one for each axis. The digi-pot would just be taking the place of the pot in the stick. That pot forms a voltage divider, and you read from the middle point a voltage between whatever is on the two ends, 0 and 5V in this case. If you had a true DAC on the Arduino (there are some that do but they'd be way overkill for this) then you could just output a voltage that would correspond to what would have been coming out of the pot. Since you don't have that, the best option is to just use a digi-pot the same way the pot in the stick would have worked.

SodNINE: Do you have any suggestions as to what to search regarding picking my paired digital potentiometer?

It needs to be basically the same as what's in the stick already. So if the pot in the stick is a 10Kohm linear pot then you'd need a 10Kohm linear digi-pot. It doesn't necessarily have to be exactly the same resistance number, but the closer you are the more it will behave just like the stick did. Find one of the communication protocols that you can be comfortable with (I like SPI myself) and look for ones that use that. Price is, of course, also a concern.

Delta_G: The PWM isn't smooth at all is the problem.

The way the joystick works is that it has a pair of potentiometers, one for each axis. The digi-pot would just be taking the place of the pot in the stick. That pot forms a voltage divider, and you read from the middle point a voltage between whatever is on the two ends, 0 and 5V in this case. If you had a true DAC on the Arduino (there are some that do but they'd be way overkill for this) then you could just output a voltage that would correspond to what would have been coming out of the pot. Since you don't have that, the best option is to just use a digi-pot the same way the pot in the stick would have worked.

It needs to be basically the same as what's in the stick already. So if the pot in the stick is a 10Kohm linear pot then you'd need a 10Kohm linear digi-pot. It doesn't necessarily have to be exactly the same resistance number, but the closer you are the more it will behave just like the stick did. Find one of the communication protocols that you can be comfortable with (I like SPI myself) and look for ones that use that. Price is, of course, also a concern.

Doing some research, I came up with a data sheet for a solder in replacement analog stick for the PS4, so I believe this should be compatible with the board i'm going to be using.

http://www.alps.com/prod/info/E/HTML/MultiControl/Potentiometer/RKJXK/RKJXV1224005.html

According to this, it looks you were correct, "Total resistance 10kΩ"

So, https://www.sparkfun.com/products/10613 should be suitable I can assume.

This one has two pots in one chip, so you'd only need one for your application. Under a dollar.

http://www.mouser.com/ProductDetail/Microchip-Technology/MCP4231-103E-P/?qs=sGAEpiMZZMuD%2f7PTYBwKqYSU5%2fr9Abo8qUjRViu0FUo%3d

Delta_G: This one has two pots in one chip, so you'd only need one for your application. Under a dollar.

http://www.mouser.com/ProductDetail/Microchip-Technology/MCP4231-103E-P/?qs=sGAEpiMZZMuD%2f7PTYBwKqYSU5%2fr9Abo8qUjRViu0FUo%3d

You have been overwhelmingly helpful, thank you so much!

I can't wait to get started on the project.