Redirect/switch PWM signal between two outputs (help)

Hello. I have a project where I need to control 5 motors using an Arduino Uno. With the drivers I have, each driver requires two PWM inputs to control the direction and speed of the motor. The Arduino Uno doesn't have enough outputs that support PWM for this. So, I would like a circuit that could use a digital signal to switch the PWM signal from one output to the other. Like this:


I only have parts from the Arduino Uno Starter Kit, including MOSFETs and NPN transistors. Is the circuit possible? The only alternative I have is turning the digital signal on and subtracting the required PWM from the max, which will also give a negative voltage, but will damage the driver in the long run. Thanks!

Better post a link to those unusual drivers then.
Normally only the enable pin requires PWM, and never the direction pin.
Leo..

There is no direction pin. To spin it one way you increase the PWM on one side and vice versa. That's why I need the circuit. I am using BTS7960 drivers.

Any help would be appreciated!

Understood.
I always used a 16-channel PCA9685 chip when I needed more than six PWM channels,
Could try a software PWM library.
Not sure about the frequency (motor wine) and UNO capabilities.
Leo..

Thanks. I'll probably just have one of the motors have only one speed. It's for a school project and the teacher's won't even know to pay attention to it, probably.

Seems you still think you're at school for your teacher.
Leo..

Haha, no. I'm in high school and I'm in a hurry with the project. I chose this as my project as a way for myself to get more into robotics, since I've been interested in it for years, but hadn't gotten further than representing my previous school in a LEGO Mindstorms sumo competition for two years. Even just building and programming those with my friend were my highlights for those years, though.

There is so many ways to do this. You can build such circuit for nearly any logic circuit. Instead of logic IC (you really cannot get some?) you can build the logic gates needed from discrete transistors. The optimal implementation depends on your requirements.

You may use Google for ideas of logic gates from discrete parts.

This wasn't very helpful. I already stated all the requirements and the parts I have available, so I asked if anyone knows a circuit that I could build with these parts, as I couldn't find one on my own.

So did you try one of the softwarePWM libraries?

A 16-channel PCA9685 (servo or PWM) board is likely not in your kit,
but frequently used so easy to get.
Hardware PWM takes the load off the Arduino. A "change_and_forget" approach.
Leo..

You did not. How many channels you need? How many transistors do you have? What frequency PWM and what voltage? It would help a lot if you told us what motor driver you are using. (EDIT: you already did, I have missed that)

As I mentioned, I have the parts that are included in the official Arduino starter kit. The driver should be able to handle any PWM frequency the Uno can give it. The circuit should take one digital, one PWM input from the Uno. I don't see where the information is lacking. I said it all before.

I see no NPN transistor on the list, only two huge power N-MOSFETs.
Maybe you could use two digital pins (+ one PWM) for the multiplexing?

1 Like

That's weird. There were actually more mosfets and the NPNs were even in one of the pictures. There are five BC547 transistors. The list also mentions a wooden base, even though it's actually plastic.I'm guessing it only lists the parts that are used in the projects.

Also, I am not able to use two digital pins, as all the pins are already taken. It's alright, though. I'll just run one motor at only max speed. It's too slow either way.

I would try this:

1 Like

Clever circuit, but I would still first try softPWM.
Leo..

1 Like

Well, great news! Now I don't have to try either of the solutions, as I seem to have burnt something out in my driver by spinning the motor without having the driver connected to a battery, creating too much backvoltage, I think. Now I can spin it in only one direction, since all that happens when I apply voltage to the other PWM pin is a momentary whining noise from the capacitor.

@Wawa @Smajdalf Thank you both for the answers, though.

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