Why don't you want to use PWM. Are you trying to control a motor? To change the polarity, you need a h-bridge.mike6216 wrote: ↑Mon May 11, 2020 11:39 pmIs there a way to control the voltage with a raspberry pi without using PWM. Basically, having a 12V DC power cable, be able to change the voltage output and polarity direction using code? What can be used in conjunction with the raspberry pi to achieve this to change voltage directly and does not involve PWM?
Hey BoyOh
Yes I am trying to control a 12V DC motor. I tried PWM with l298N but at a low duty cycle of below ~40 the motor does not spin. I tried playing around with the frequency but that does not fix the problem. My project requires the motor to spin at different speeds from the lowest to the highest speed associated with if the voltage was 3V to 12V, so PWM would not work because there is still a wide range of speeds that I need below a duty cycle of ~40 that would've worked if I simply attached a DC power supply and changed the voltage between 3-12V. A solution which includes changing the voltage physically would also not work as I wanted the speed and direction controlled fully through codeBrandon92 wrote: ↑Tue May 12, 2020 7:51 amWhy don't you want to use PWM. Are you trying to control a motor? To change the polarity, you need a h-bridge.mike6216 wrote: ↑Mon May 11, 2020 11:39 pmIs there a way to control the voltage with a raspberry pi without using PWM. Basically, having a 12V DC power cable, be able to change the voltage output and polarity direction using code? What can be used in conjunction with the raspberry pi to achieve this to change voltage directly and does not involve PWM?
By the way, you can add a filter at the PWM output and you have a variable voltage.
emma1997 wrote: ↑Thu May 14, 2020 12:44 amActually both PWM and digital pot are rail-to-rail.
It is the failure of most motors to start at 1/10th or even 1/3rd voltage that is confusing OP. The solution is to understand the concept of impedance, scaling, and offset. Easily implemented with op amp, properly biased transistor, or if frightened by DIY then simple limit translation in software using built-in PWM or just about any DAC hat.
Oke it should work. What is the type of motor you are using, what is is power. It could be that the l298n is not the best solution for you. It has a reasonable high resistance when it is on.mike6216 wrote: ↑Wed May 13, 2020 10:19 pmYes I am trying to control a 12V DC motor. I tried PWM with l298N but at a low duty cycle of below ~40 the motor does not spin. I tried playing around with the frequency but that does not fix the problem. My project requires the motor to spin at different speeds from the lowest to the highest speed associated with if the voltage was 3V to 12V, so PWM would not work because there is still a wide range of speeds that I need below a duty cycle of ~40 that would've worked if I simply attached a DC power supply and changed the voltage between 3-12V. A solution which includes changing the voltage physically would also not work as I wanted the speed and direction controlled fully through codeBrandon92 wrote: ↑Tue May 12, 2020 7:51 amWhy don't you want to use PWM. Are you trying to control a motor? To change the polarity, you need a h-bridge.mike6216 wrote: ↑Mon May 11, 2020 11:39 pmIs there a way to control the voltage with a raspberry pi without using PWM. Basically, having a 12V DC power cable, be able to change the voltage output and polarity direction using code? What can be used in conjunction with the raspberry pi to achieve this to change voltage directly and does not involve PWM?
By the way, you can add a filter at the PWM output and you have a variable voltage.
Coming back to this.mike6216 wrote: ↑Wed May 13, 2020 10:19 pmMy project requires the motor to spin at different speeds from the lowest to the highest speed associated with if the voltage was 3V to 12V, so PWM would not work because there is still a wide range of speeds that I need below a duty cycle of ~40 that would've worked if I simply attached a DC power supply and changed the voltage between 3-12V. A solution which includes changing the voltage physically would also not work as I wanted the speed and direction controlled fully through code
Brandon92 wrote: ↑Thu May 14, 2020 8:29 pmComing back to this.mike6216 wrote: ↑Wed May 13, 2020 10:19 pmMy project requires the motor to spin at different speeds from the lowest to the highest speed associated with if the voltage was 3V to 12V, so PWM would not work because there is still a wide range of speeds that I need below a duty cycle of ~40 that would've worked if I simply attached a DC power supply and changed the voltage between 3-12V. A solution which includes changing the voltage physically would also not work as I wanted the speed and direction controlled fully through code
I you successfully make a variable power supply that regulate the voltage from 3V to 12V. This this setup will not work. Because the L298N is not suitable for this. The first reason is that the minimum supply voltage for the L298N to operate is 5.8V in your application.
And the other imported specification of the L298N is VCEsat. Lets say that your motor wil consume 1A. Then the voltage drop in the h-bride inside the L298N between 1.8V to 3.2V. So if you supply it with 12V, (at worst case) the motor only will see 8.8V (at 100% duty cycle). So when you supply the L298N with 6V, it could drop to 3.4V across the motor (at 100% duty cycle).
So it is important that we have more Information about your setup. It is also important that you use the correct cables and things like that.
