Interfacing Motor Driver/X9C103S Digital Potentiometer/Wireless Arduino-MQTT

  1. PWM DC Motor Speed Controller, DC 10-55V / Rated 40A / Max 60A, LED Display Stepless DC Motor Speed Controller with Adjustable Potentiometer and Forward-Brake-Reverse Switch

  2. X9C103S Digital Potentiometer Module

  3. 12k Ohm Resistor

  4. ACEBOTT Development Board ESP32 Max V1.0

Will be workout out the kinks in the code to try and make a universal template due to the nature of requiring the fan(s) to be controlled.

To determine the suitability of using the X9C103S Digital Potentiometer Module with the motor driver, it is essential to understand the working principle of the digital potentiometer and the motor driver's requirements. The X9C103S is a 10kΩ digitally controlled potentiometer with 100 selectable wiper taps and non-volatile storage of the current tap position 7. This means that the module can be used to provide a variable resistance, which can be used to control the motor speed.

The motor driver output a maximum power consumption of 120W at 12V, which corresponds to a maximum current of 10A. However, the maximum voltage at the pot knob is 5.17V at the highest. Given that the X9C103S digital potentiometer module can handle a maximum voltage of 5V, it appears that the module can be used with the motor driver without exceeding its voltage rating.

To convert a 100k potentiometer to work with a 10k digital potentiometer, you can use a resistor bridge across the 1 and 3 lugs of the potentiometer [[6]]((I need a 10K pot. I only have 1k's, 100k's, and 1M's. Converting? - DIY (Do It Yourself) - Harmony Central). This will create a voltage divider that can be used to control the gain of the amplifier, which provides the digital-to-analog converter (DAC) output 7.

One way to achieve this is by connecting a 12k resistor in parallel with the 100k potentiometer, between the top and bottom lugs (pins 1 and 3) 2. This will put the 12k ohms in parallel with the 100k ohms of the pot, effectively reducing the total resistance to around 10k.

It's worth noting that using a potentiometer with a different value than the one specified in the circuit can affect the performance of the circuit. Therefore, it's essential to ensure that the modified potentiometer is compatible with the circuit and does not cause any issues.

Where is your schematic?

one moment.. coming right up...

Its interesting that Cytron makes the whole model including the PWM, but going Arduino/Espressif allows for more incorporations into one board.

Sorry I do not follow pictures very well and there is a lot of information missing.

I will make a chart soon enough. Sorry for the delay been updating a different graph that is taking a while.

What kind of help do you need???

Code?
Wiring?
Part selection?
Using the IDE?
How to draw a schematic?

need more time to test after this last update. But help if there i any errors in the schematic if there are errors and design that won't work if you have the time. Will be a while putting tis together and troubleshooting the typical errors that will arise


                 
                           |---------------------------------------------------------------------------------|
                           |   |---------------------------------------------------------------------------| |      
                           |   |                                                                           | |
                           |   |          |----------------------------------------------------------|     | |
                           |   |          |     |--------------------------------------------------| |     | |           
                           |   |          |     |                 +-----------------+              | |     | |   
               +----------------------+   |     |                 | (A1)Nextion HMI |              | |     | |   
               |LOGIC LEVEL CONVERTER |   |     |                 |                 |              | |     | |   
               |                      |   |     |       |---------|                 |              | |     | |   
               |                      |   |     |       |         +-----------------+              | |     | |       //RC  Snubber
               |                      |   |     |       |           RX(a)|    |TX(e)  +---------+  | |     | |       //Mosfet Modules
               +----------------------+   |     |       |                |    |       |  (C1)   |  | |     | |       //Time Delay Modules
                           |   |          |     |       |                |    |-------| NANO V3 |  | |     | |       //Time Offet Modules
                           |   |     RX( )|     |TX( )  |                |       RX(e)| (RX/TX  |  | |     | |    
                           |   |    +---------------+   |           TX(a)|            +---------+  | |     | |     
                           |   |    |( )Ct-Uno      |   |         +-----------+	      TX(f)|       | |     | |   
                           |   |    | Shield stacks |   |         |   (B1)    |  |---------|       | |     | |      
                           |   |    |Cytron MDD-10  |   |         |  Nano V3  |  |                 | |     | |  
                           |   |    |Cytron MD-10   |   |         |  (RX/TX)  |  |           RX( ) | |TX/RX| |TX( )
                           |   |    +---------------+   |         +-----------+  |        +------------------------------------------------+
                      RX( )|   |TX( )                   |         RX(b)|         |        |                 (D1)                           |
                    +-----------------+                 |              |         |        |           Arduino Mega 2560                    |  
                    |                 |                 |              |         |        |                                                |  
            --------| ( )Esp32-S3 DEV |                 |              |         |        +------------------------------------------------+  
            |       | 1-8 Network     |                 |              |         |     RX(4)|  |TX(2)                                          
            |     |-|   SCA/SDL       |                 |              |         |          |  |                                               
            |     | +-----------------+                 |              |         |          |  |                                               
            |     |SDL                                  |         TX(b)|    RX(f)|     TX(4)|  |RX(2)                                          
            |     | +-----------+ GPIO0  +-----------------+        +------------------------------------+                                     
            |     | | 3v3or5v   |--------|  ( ) Nextion    |        |         LOGIC LEVEL SHIFTER        |                                     
            | SCA --| pull up   | GPIO1  |    Advanced     |        |                (E1)                |                                     
            |-------|pull down  |--------|      GPIO       |        +------------------------------------+                                     
 PROGRAMMED |       +-----------+        |   8 Channel     |        TX(c)|            RX(g)|  TX(3)|  |RX(1)                                     
AUTOMATIONS |             |SDL           |   Expansion     |    	     |                 |       |  |------|                                   
IN ARDUINO  | SCA   +-----------+ GPIO2  |                 |        RX(c)|            TX(g)|       |------|  |                                   
(HOT WATER) |-------| ARDUINO   |========|                 |    +---------------+     +---------------+   |  |                                   
 (HVAC MON) |       +-----------+ GPIO3  |                 |    | ESP32-S3 DEV  |     | ESP32-S3 DEV  |   |  |                                   
  (ETC)     |             |SDL           |                 |    |    (F1)       |     |    (G)        |   |  |                                   
            | SCA   +-----------+ GPIO4  |                 |    +---------------+     +---------------+   |  |                                   
            |-------|  ARDUINO  |========|                 |            TX(d)|           |RX(h)           |  |        
            |       +-----------+ GPIO5  |                 |                 |           |                |  |        
            |         	  |SDL           |                 |            RX(d)|           |TX(h)           |  |                                
            | SCA +------------+  GPIO6  |                 |               +---------------+              |  |                              
            ------| ARDUINO    |=========|                 |               |ESP32-C6 DEV   |              |  |
                  +------------+  GPIO7  |                 |           	   |    ( K )      |              |  |
                  		                 |                 |               | ZIGBEE/MQTT   |              |  |
                  		                 |                 |               +---------------+              |  |
                 	            ---------|                 |                  TX(1)|  |RX(3)              |  | 
                                         |                 |                       |  |-------------------|  |
                 	                     |                 |                       |-------------------------|
                 	                     |                 |          
                 	            ---------|                 |          
                 	                     |                 |          
                 	                     |                 |          
                 	                     |                 |          
                 	            ---------|                 |          
                 	                     |                 |          
                 	                     |                 |          
                 	                     |                 |          
                 	            ---------|                 |           
                                         |                 |                                  
                                         +-----------------+

Your original post says ESP32 but your diagram shows several ESP32-S3s, a C6, several Nanos and a Mega2560.
I don't see the digital pot anywhere

So exactly what are you trying to do?

I am adding the digital potentiometer to the HVAC section. Its for a skylight. Anyhow I just learned through searching the internet since yesterday that it should work with a shelly RGBW2. Im just trying to figure out how incorporate it. Give me a an hour or two to work this over and prepare and test. And yes I posted this schematic in the wrong post for the same system.. But it is relevant to the whole so will leave that post.

The matter at hand is creating a fall back from the shelly RGBW2. I'll get back to sorting in the complete integration with the schematic design.

  Voltage at ANALOG PWM-100K 5.17VDC TO DIGITAL PWM-10K  WITH 12K RESISTOR      

                +------------------+       +-----------+       +-------------+
                |  INC (Increment) |-------| 12k ohm   |-------| Pin 3 (INC) |
                |  (Red)           |       |  Resistor |       |  (X9C103S)  |
                +------------------+       +-----------+       +-------------+
                                                  |                                            
                                      -------------                                                  
(**POTETIOMETER INLINE                |
FROM MOTOR DRIVER**)                  |                                                                                                                       
     |      --------------------------+----------------------------------
     |      |     +-------+           |                                 |
     |      |     |X9C103S|           |                                 |    
     |----->|     +-------+---+-------+-------+------+---+              |   
            |     |  GND  |  U/D  |  INC  |  CS  |  VCC  |              |              
            |     +-----------+-------+-------+------+---+              |      
            |     |  GND  |  U/D  |  INC  |  CS  |  5V   |              |        
            |     +-----------+-------+-------+------+---+              |   
            |                                                           |       
            |     +-------+                                             |     
            |     |X9C103S|         (CONTROLS)                          |       
            |     +-------+-----+-------+                               |
            |     |  VH   | VW  |  VL   |                               |        
            |     +-------------+-------+                               |     
            |     |  5V   | VW  |  GND  |                               |      
            |     +-------+-----+-------+                               |                
            ---------+------+------+-------------------------------------      

                                                                                  
      +-----------+
      |  Motor    |
      |  Driver   |
      +-----------+
                 |
                 |
                 v
     ----------- +-----------+
     |           |  PWM IN   |------|  VW     |-------|  Motor    |
     |           +-----------+      +---------+       +-----------+
     |           |  (e.g.,   |      |(X9C103S)|       |  (e.g.,   |
     |           |   Arduino)|      |         |       |  DC Motor)|
     |           +-----------+      +---------+       +-----------+
     |
     |  



       +-----------+
     |           |  Shelly   |
     |           |  Device   |
     |           +-----------+
     |                    |
     |                    |
     |                    v
                +-----------+
                |  UART     |-------|Microcontroller
                +-----------+       +-----------+
                |  (e.g.,   |       |  (e.g.,   |
                |   UART)   |       | Arduino   |
                +-----------+       +-----------+

Connections:

Black (Top 3) to GND: Correct, this connects the ground reference to the X9C103S.
Yellow (Top Middle) to U/D: Correct, this connects the Up/Down control signal to the X9C103S.
Red (Bottom 2) to 12k ohm Resistor to INC: Correct, this connects the Increment control signal to the X9C103S with a 12k ohm resistor.
Black (Bottom 2) to CS: Correct, this connects the Chip Select signal to the X9C103S.
Red (Top 3) to VCC: Correct, this connects the positive power supply to the X9C103S.
Remaining Connections:

The remaining connections are for the analog pins (VH, VW, VL) on the X9C103S.

VH (High Voltage): Connect this pin to the positive power supply (VCC) of your system, which is typically 5V.
VW (Wiper Voltage): This pin is the output of the digital potentiometer and should be connected to the input of your motor driver or other circuit that requires a variable voltage.
VL (Low Voltage): Connect this pin to the ground reference (GND) of your system.
Shelly Device Connection:

The Shelly device is not directly connected to the VH, VW, VL pins. Instead, it should be connected to a microcontroller (e.g., Arduino) that controls the X9C103S.

Microcontroller Connection:

Connect the Shelly device to a microcontroller (e.g., Arduino) using a suitable communication protocol (e.g., UART, SPI, I2C). The microcontroller will then control the X9C103S using the U/D, INC, and CS signals.

By removing the manual potentiometer there is a voltage spike up to the input voltage. From 5.17 to ful input which in this case 12-13VDC. For this specific motor driver the voltage test conducted with the Noyito octocoupler, voltage is manageable wit a voltage regultor and capacitors but i can seem to figure out the correct wiring to get an Acebott Esp32 Max to stabilize and control the pwm. My first guess is tere is no PWM in the code besides that is no pwn modulation. Other than that it seems a highervoltage rated X9cXX is required just to simplify the equation.

#include <WiFi.h>
#include <PubSubClient.h>
#include <X9C103S.h>

// Define the WiFi settings
const char* ssid = "your_wifi_ssid";
const char* password = "your_wifi_password";

// Define the MQTT settings
const char* mqttServer = "your_mqtt_broker_url";
const char* mqttTopic = "your_mqtt_topic";
const char* mqttUsername = "your_mqtt_username";
const char* mqttPassword = "your_mqtt_password";

// Define the relay pin
const int relayPin1 = 23;

// Define the digital potentiometer pins
const int incPin = 16;
const int udPin = 17;
const int csPin = 18;

// Create an instance of the X9C103S digital potentiometer
X9C103S pot(incPin, udPin, csPin);

WiFiClient espClient;
PubSubClient client(espClient);

void setup() {
  Serial.begin(115200);
  pinMode(relayPin1, OUTPUT);

  // Connect to WiFi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to WiFi");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  // Connect to MQTT broker
  client.setServer(mqttServer, 1883);
  client.setCallback(callback);
}

void loop() {
  // Check if we're connected to the MQTT broker
  if (!client.connected()) {
    reconnect();
  }

  // Publish a message to the MQTT topic
  client.publish(mqttTopic, "Hello, World!");

  // Turn on the fan in forward direction
  digitalWrite(relayPin1, HIGH);
  delay(1000);

  // Ramp up the fan speed from slow to fast
  for (int i = 0; i <= 99; i++) {
    pot.setWiper(i);
    delay(50);
  }

  // Wait for 5 seconds
  delay(5000);

  // Turn off the fan
  digitalWrite(relayPin1, LOW);
  delay(1000);

  // Turn on the fan in reverse direction
  digitalWrite(relayPin1, HIGH);
  delay(1000);

  // Ramp down the fan speed from fast to slow
  for (int i = 99; i >= 0; i--) {
    pot.setWiper(i);
    delay(50);
  }

  // Wait for 5 seconds
  delay(5000);

  // Turn off the fan
  digitalWrite(relayPin1, LOW);
  delay(1000);
}

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);
  }
  Serial.println();
}

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect("ESP32Client", mqttUsername, mqttPassword)) {
      Serial.println("connected");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

// Tag for skylight fan
const char* fanTag = "skylight_fan";`

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.