X9C503 works with ESP32?

ESP-LED
Posts: 3
Joined: Thu Mar 21, 2024 3:27 pm

X9C503 works with ESP32?

Postby ESP-LED » Wed May 08, 2024 11:38 pm

I can't get X9C503 to work with ESP32 but it can with Arduino Mega.

What do I need --> To be able to operate the X9C503 to lower the volume of an audio line input. I don't want to use common manual potentiometers.

X9C503 Scheme:

INC__| o o | VCC
U/D__| o o | CS
RH___| o o | RL
GND__| o o | Rwiper


In my case:

INC------| o o | VCC (5v)
U/D------| o o | GND
Audio in | o o | GND
GND------| o o | Salida


On Arduino Mega I connect everything directly to the board and the operation is correct.

In ESP32 if I connect it to the board it doesn't work, so I have used the 2N3904 diode for the 'INC', 'U/D' pins (I have also tried with 'CS' but Arduino Mega does it well being grounded), and It works but it doesn't do it well, I describe the problem:

You have to enter values between 0 and 99, and in general it does it well, for low values the volume goes down and for high values the volume goes up. I detected the problem by always entering the same value.

In this case it was '91', if I enter it several times in a row I get different results, normally the volume remains constant but sometimes it goes up, other times it goes down and even total silence occurs

With Arduino Mega I enter the '91' 500 times and the
The volume never changes, it is constant and its operation is always correct.

What could be the problem?
What other component can I use?

As an alternative, I have tried the FM62429, with ESP32 it works correctly, but it has the amplification function that does not suit me. For the line input I already use 22kΩ resistors, then the potentiometer and finally the MSGEQ7, it doesn't make much sense to change a potentiometer to lower the voltage and replace it with a component that can amplify. I can limit the FM62429 by code, for example, to 60% and only use it to lower the volume, although I don't think it is a very elegant solution.

Audio Line In -> 22kΩ resistors -> X9C503 -> MSGEQ7
Audio Line In -> 22kΩ resistors -> FM62429 -> MSGEQ7

Any ideas or suggestions?

Code: Select all

#include "X9C10X.h"
#define CSPIN 33
#define INCPIN 14
#define UDPIN 27

X9C503 pot;

void setup() {
  Serial.begin(9600);
  pot.begin(INCPIN, UDPIN, CSPIN);  //  pulse, direction, select
  Serial.println("Introduce un valor entre 1 y 99");
}

void loop() {
  if(Serial.available() != 0){
    int value = Serial.parseInt();
    if (value != 0) {
      pot.setPosition(value, true);
      delay(30);
      Serial.print("Valor introducido: ");
      Serial.println(value);
    }
  }
  delay(100);
}

ESP-LED
Posts: 3
Joined: Thu Mar 21, 2024 3:27 pm

Re: X9C503 works with ESP32?

Postby ESP-LED » Fri May 10, 2024 9:55 pm

The X9C503 that I have in my hands works at 5V, if it is connected to an Arduino Mega it works correctly, but to be able to use it in ESP32 you have to use transistors.

The problem is that I don't have much experience and I didn't know that with transistors I had to use the 4k7 resistors to ground so that they can reach the LOW state. Now it works correctly, for the same input always the same output.

Keep in mind that the X9C503 is a cheap one bought on AliExpress, I bought 4 and 1 does not work.

Keep in mind that the same thing that has been done with 'INC' AND 'U/D' must be done with 'CS' if you want the selected resistor value to be stored. I don't need it to persist so I leave it grounded and in the code I select a free pin that I am not going to use. Even if the pin is not going to be used, you cannot select any that is free, if you select a pin and it is not good, do not worry, every time you try to change the resistance value it will show you an error message through the console and so you can Select another one that does not fail.

The code that makes it work is the same one that I published at the beginning

Image

Who is online

Users browsing this forum: No registered users and 130 guests