i want to output 2 potentiometer values from a arduino pro micro to the solder points of a ps5 controllers right stick pots so that i can code custom stick settings for the controller such as deadzone, anti deadzone and stick response curves. also to be able to use whatever analog stick modules i want with whatever pots i want
I can code the sticks settings all day but i am unsure of the best way to get the arduino to output the analog values.
these are the questions i need answerd.
Would a pwm signal be fine on its own? ,
would a pwm signal with the low pass filter hack be equivalent to a actuall pot value (keeping accuracy in mind)?
would using a external dac be the best way of doing this?
keeping in mind i need to be able to adjust the output values to emulate the value of the controllers original pots and i need to output at least 2 analog signals for the x and y values of the stick
would these take a pwm value or the value you get straight from pots i connect to the arduino and would it be 1 digi pot per output pot value or do these tend to be able to output mulitple values at the same time.
I assume you are asking how many chips you will need for each output. There are different chips such as the MCP4241 series which are 2 digital potentiometers in 1 chip and are available in several different values (5, 10, 50 and 100 kΩ) with a resolution of 129 steps. For 2 outputs, 1 such chip is enough. You may have to measure the value of the potentiometer of the PS5 controller to get the appropriate chip.
yo, i am at the point where i am actually putting all of this together. i got the mcp4241 but i cant find any good references for how to code it properly. I have pot 0 wired to the ps5 controllers right stick axis y and it works as intended but pot 1 does not,, instead it just sits at its max value, i have tested this on the ps5 controllers x axis and by wiring the pot back in to the arduino and reading the value.
i have seen multiple pieces of information explaining how you might select a specific pot and then set the value such as ,
pot 0
void setPot(int address, int value) {
digitalWrite(SlaveSelect, LOW); // Select the MCP4241
SPI.transfer(0.00); // Send the address
SPI.transfer(63); // Send the value
digitalWrite(SlaveSelect, HIGH); // Deselect the MCP4241
}
and
pot1
void setPot(int address, int value) {
digitalWrite(SlaveSelect, LOW); // Select the MCP4241
SPI.transfer(0.10); // Send the address
SPI.transfer(63); // Send the value
digitalWrite(SlaveSelect, HIGH); // Deselect the MCP4241
}
but pot 1 never seems to get selected or show any sign of changing value so i am assuming that while setting the value for pot 0 with SPI.transfer(63); works, the way i am trying to select witch pot to use is just not working at all or are the completely wrong addresses and then pot 0 is just the pot it picks by default when using SPI.transfer(63);.
Any idea how i would select witch pot to set a value to or what the addresses for them might be?
yes i have found a few diffrent values to put in there such as 0.10, 1, 0000100, 16 all from diffrent sources and trying to understand the data sheet, all trying to access pot 1 .
does each pot have its own slaveSelect if both pots are on the same digi pot, if so how would this work because there is only 1 cs pin on the digi pots breakout board.
yea i typed those down from memory, i think they were hex like values microsoft edges ai gave me, one of the pots did work still though.
i have found a few examples using 16 and this is the code im using now.
#include <SPI.h>
#define SlaveSelect 10 // Change this to your CS pin!
//#define READ_PIN A1 // The pin connected to the Wiper
int pot0 = 0;
//int pot1 = 16;
int pot1 = 16;
//int stickValue = 63;
void setup() {
pinMode(SlaveSelect, OUTPUT);
//digitalWrite(CS_PIN, HIGH); // Deselect the MCP4241
//digitalWrite(SlaveSelect, LOW);
SPI.begin();
Serial.begin(9600); // Start serial communication for debugging
digitalPotWrite(pot1, 0);
}
void loop() {
digitalPotWrite(pot1, 127);
digitalPotWrite(pot0, 63);
}
int digitalPotWrite(int CommandByte, int value) {
// take the SS pin low to select the chip:
digitalWrite(SlaveSelect,LOW);
// send in the address and value via SPI:
SPI.transfer(CommandByte);
SPI.transfer(value);
// take the SS pin high to de-select the chip:
digitalWrite(SlaveSelect, HIGH);
}
i keep hoping there is something else stupid and obvious im missing but i havnt found anything yet and im starting to think its broken but having just 1 pot not work seems strange to me.
this code still only works with pot 0 but i know that it is selecting pot 0 and then setting the value instead of seeming like it was just defaulting to pot 0.
you notice anything wrong or out of place with the code?
i did have a look at this library but the example code in there still only works on pot 0 and it does seem like the example is meant for both pots.
i was wondering if any of the other functions on the chip could be stoping me setting the value of pot 1s wiper, it has something called write detect witch sounded like it was to prevent changing the values on the pots in the data sheets but it has a pin on the breakout board so i assume not because i didnt wire it in