I'm getting somewhere now. It's not giving full throttle but it is giving some throttle.
I had to hook up the throttle unit in parallel with the Arduino for the bike to accept inputs from the Arduino.
This might work out ok because i wanted to have a throttle lever and pedal assist anyway.
More testing to do still!
I briefly had it working without the throttle connected. I had put a 1.2K resistor between the positive and ground wires and that did it. The bike was under control of the Arduino. Then it just stopped working and hasn't worked since.
The Arduino still works, and the bike still works if I hook a regular throttle to it. Mysterious
describe how it's supposed to work, at least in theory..
control a transistor with the potentiometer..
1. ardie -> potentiometer -> transistor -> motor control voltage
not
2. ardie -> potentiometer -> motor control voltage
#1 is probably how it's done inside the hall effect sensor chip. there is probably more than just hall effect sensor + amp etched on that silicon chip. Identify the hall chip if you can and grab the manufacturer's data sheet if possible to verify.
@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