Raspberry Pi and PWM

Thread Starter

Xavier Pacheco Paulino

Joined Oct 21, 2015
728
Hello,

I've heard that PWM from raspberry is not so "good". I really don't know if it's true or not. Is the Pi good for controlling the speed of a small DC motor? I would like to control the speed a 20V DC motor. I can do all the research by myself. This question is basically to know what you think about it, or if you have done this before. I've always used PWM from other microcontrollers, never from the Pi.
 

blue_coder

Joined May 7, 2016
36
Hello Xavier,
RPIs have a couple of hardware PWM pins which are just as good as any other PWM. Why Raspberries are viewed as not "good", is because you can do software PWM on pretty much all of the GPIOs which has aweful resolution (like 100us).
 

Thread Starter

Xavier Pacheco Paulino

Joined Oct 21, 2015
728
What is wrong with the Picmicro? if you are already familiar.
If you just want pot control, a 12F1822 would do it in spades.
Max.
I know! There's nothing wrong with the Pic. The point is that I was working in a project with the Pi nothing related with PWM. But then I came up with adding that feature.
 

ebp

Joined Feb 8, 2018
2,332
If there are hardware (counter) based PWM outputs available, they should be reliable in terms of consistent frequency and duty cycle once set up. Where things fall apart without a Real-Time Operating System (RTOS) is that the time it takes the system to respond to something is largely indeterminate. If you attempt to do closed-loop control by (just as an example) asserting an interrupt when the motor speed rises too high, requiring reprogramming of the duty cycle, the normal OS will get around to doing something about the interrupt sometime when it isn't on a coffee break or servicing the video system or Ethernet or ... Meanwhile, your motor is beginning to sound like a high speed dental drill. Even with an RTOS, care is necessary to be sure you can service critical requirements in a timely fashion.

I have no idea if there is an RTOS for the Raspberry Pi.
 

Sensacell

Joined Jun 19, 2012
3,449
Yes- beware of any software driven PWM-
For motor control, LED dimming I would never use soft PWM.

Useful for only very simple, non-critical PWM tasks.
 

Thread Starter

Xavier Pacheco Paulino

Joined Oct 21, 2015
728
Yes- beware of any software driven PWM-
To be honest, I wasn't aware of the difference between software and hardware PWM. I just googled it and realized that I've always used hardware PWM. Once I tried software PWM without knowing that it was a software driven PWM. Well, recently I used Arduino to generate a 50 ms PWM signal for a motor controller, and since that was the only application it was software driven. But thank you, I didn't have that concept in my mind.
 
Top