Oh! Then absolutely yes, you can RC filter that. The pwm frequency is 400hz on the old ones, and gou want something that moves at the speed of s human hand, like half a hertz max. A half second RC would hit the barn door.
10 uF and 47K ohms is a half second.
1000 Hz would be many many dB down. Its knowable.
Oops I meant 2hz max and that RC reflects that.
Start with the R C time being 10X the frequency. You can't really get all the bumps out without turning it into DC.
How good does it need to be? What's the application?
R C time is microfarads times megohms. for time in seconds. Rule of thumb.
@MLE_online @RueNahcMohr what arduino do you have? They have different PWM speeds. And what is your acceptable ripple in your output?
Slowest pwm is 490hz. If you filter that with a 1k resistor and a 10uf capacitor, that’s a cutoff of about 16hz. So you could have a control signal of about that. It would have a ripple of about [edit: 0.25] volts on the output
Edit: I accidentally ran the calculation at the wrong PWM speed. The slower speed gives you .25 volts ripple, the faster gives you 0.12v
@MLE_online @RueNahcMohr additional info: you can software bit bang a faster pwm, there are arduino libraries
Also, you can use this calculator for PWM. It has been around for decades and I use it all of the time. Just plug in the pwm frequency, and the resistor and capacitor values and it will come back with cutoff frequency, and output ripple, and even graph it over time
If the pwm is at 100kHz and you are trying to generate a sub 100hz tone, it might be fine. If you want full bandwidth audio to 20kHz, nope.
https://www.allaboutcircuits.com/technical-articles/low-pass-filter-a-pwm-signal-into-an-analog-voltage/
additionally, if you need steady more than resolution, an R-2R DAC is easy to make.
@MLE_online I'm gonna some assumptions and say hell yes.
Whatcha cooking up this time?
@ArchiteuthisFlux I have an idea I want to try on this new ebike project. The motor controllers for these things have nice throttle response, but the pedal assist sensor response is just on-off. I was thinking I would try using an arduino to read the speed the pedals are turning from the pedal assist sensor and then generate a 0-5V throttle signal.
I want to see if I can make it so the bike provides an amount of throttle that corresponds to how much pedaling you're doing
@MLE_online Oh sick. I always thought it was weird that ebikes didn't work that way by default.
Like @stargirl said, a throttle signal like that is the least demanding analog output ever and could be done on pure vibes. I would put a little pot on it that you multiply with the pedal signal in the analogWrite() and then just twiddle it while riding until it feels right.
Because doing math is for nerds.
@ArchiteuthisFlux @stargirl I was thinking exactly something like that!
I don't understand why they don't work that way. They clearly can provide a variable amount of throttle, but someone at some point decided that the pedal assist shouldn't work like that and then every factory in China that makes these controllers did it the exact same way.
@MLE_online @stargirl I wonder if that has something to do with the ridiculous number of laws around ebikes in some places.
"God forbid people just move the throttle and it goes, they must also be perfomatively moving their feet in circles for some reason."
Amazon.com: WWZMDiB 2 Pcs MCP4725 DAC Converter Module 12-bit I2C IIC Compatible with for Arduino Raspberry Pi ESP32 STM Digital to Analog Converter Board : Electronics