2CH Independent PWM Generator Duty Cycle Pulse Frequency Module Controller

Recently purchased this PWM board for testing PWM fan. Was wondering if anybody can advise how to connect this with the Arduino Uno to program the Frequency and Duty Cycle so it can be controlled with a POT.

https://www.aliexpress.com/item/2CH-Independent-PWM-Generator-Duty-Cycle-Pulse-Frequency-Module-LED-Digital-Tube/32748399775.html

Fifth, the serial control

Baud rate: 9600 bps

Data bits: 8

Stop bits: 1

Parity bit: none

Flow control: none

1, set the PWM frequency

"S1FXXXT": setting PWM1 frequency of XXX HZ (001 ~ 999)

"S1FXX.XT": set the frequency of PWM1 XX.X KHZ (00.1 ~ 99.9)

"S1F: X.X.X.T": setting PWM1 frequency of XXX KHZ (0.0.1 ~ 1.5.0..)

'S1': PWM1

'S2': PWM2

'F': Frequency

'D': Duty Cycle

'T' is the end flag

Set the PWM duty cycle

"S1DXXXT": setting PWM1 duty cycle XXX; (001 ~ 100)

"S2DXXXT": set PWM2 duty cycle XXX; (001 ~ 100)

Setting successful return: DOWN;

Setting failback: FALL.

(deleted)

(deleted)

Yes Ive seen all this info, can you provide a sample of how to put this into arduino code to set the frequency and duty cycle.

Was wondering if anybody can advise how to connect this with the Arduino Uno to program the Frequency and Duty Cycle so it can be controlled with a POT.

How will you select one of the three setting ranges?

How will you convert 0-1023 to the values of the range?

Does your Arduino have two hardware serial ports?

If only one, will you need the serial monitor after the code is downloaded?

If yes, then you will need to use Software serial.

If no you can connect the device serial after the program is loaded. You will connect the tx of the arduino to the rx of the device and the rx of the arduino to the tx of the device, set the baud rate to 9600, connect the grounds, and send the commands with Serial.write().

can you provide a sample of how to put this into arduino code to set the frequency and duty cycle.

What specifically are you not understanding.

Sorry for late reply, I am a newbie to Arduino. After having a look into PWM secrets it seems very complicated to set the frequency to 25khz for multiple pins on the arduino even with libraries. I manageed to successfully set only two pins but i need at least 6 PWM at 25khz.

I was hoping to use this 3 of these module to fix the frequency at 25khz and just have a potentiometer controlling the duty cycle to control a PWM fan. I understand the physical connnection between the arduino uno and the module Rx/Tx but in regards to the code serialwrite as you mentioned is completely lost on me.

Is an analogue control not possible via serial communication?

Cant I just set the Frequency to 25khz

'"S1FXX.XT": 25)

and control duty cycle via pot (I understand analogue control is between 0-1023

so

"S1DXXXT": setting PWM1 duty cycle XXX; (001 ~ 100) cant I just use some sort of statement to change the duty cycle based on the pots position?

If there is some sample codes available to control this type of module would a appreciate some direction.

Cant I just set the Frequency to 25khz

'"S1FXX.XT": 25)

The syntax for this command is going to be "S1F25.0T"

cant I just use some sort of statement to change the duty cycle based on the pots position?

Take a look at the map function https://www.arduino.cc/en/Reference/Map

dutyCycle = map(potentiometerReading, 0, 1023, 0, 100);

Now, you need to get the numerical duty cycle into the character serial output. You can use sprintf() to add the value to the command string "S1D025T" for 25% duty cycle. You should also review the printf() formatting statements.

Here's the idea

int potentiometerReading;
byte dutyCycle;
char dc_command[8] = {};//7 characters+null terminator
void setup() {
 Serial.begin(115200);
 potentiometerReading = 256;
 dutyCycle = map(potentiometerReading, 0, 1023, 0, 100);
 sprintf(dc_command, "%s%.3d%s", "S1D", dutyCycle, "T");//%.3d will ensure XXX
 Serial.print(dc_command);
}

void loop() {}

The code you've given doesn't compile. Can you please add something in the void setup so I can run and see how it works. Im still learning and need a little more help. Thanks for patience.

The code you've given doesn't compile.

The code posted in reply #6 compiles with ide 1.8.1 and prints out S1D025T.

Please post your code, your error messages, and any specific questions that you have.