So here's the deal. I want to ultimately build a go-kart with 4 independently controlled motors. I'm thinking about using an Arduino to handle the inputs and then send the outputs to the motor controllers. It seems the most common controllers use an analog, 0-5V hall sensor for the throttle. Inexpensive Arduinos (including the one I have) do not have any analog outputs, only digital, but they do have PWM outputs. For a motor controller expecting a hall sensor analog input, would a PWM input work, or would it likely cause problems? If it wouldn't work well, I read that a low-pass filter can be made with a small capacitor like 10uF, and a 4k resistor and that should effectively convert the PWM signal into an analog one. Would that be likely to work in place of a hall sensor? Has anyone done anything like this?
A low pass filter (resistor and capacitor, or two of each) works to convert the PWM to analogue - so if 8 bits is enough?, then careful selection of the values (and probably a buffer opamp) will do the job.
Or you could use an external DAC - a nice example here for you:
I made an Arduino based throttle interface. It allows you to take 0-5v input from either Hall or Potentiometer throttles, and alter the output curve to anything you'd like. I'm using it to smooth out the throttle at the lower range. You'll need an Arduino (Uno is what I used, Nano should work...
I made an Arduino based throttle interface. It allows you to take 0-5v input from either Hall or Potentiometer throttles, and alter the output curve to anything you'd like. I'm using it to smooth out the throttle at the lower range. You'll need an Arduino (Uno is what I used, Nano should work...
A low pass filter (resistor and capacitor, or two of each) works to convert the PWM to analogue - so if 8 bits is enough?, then careful selection of the values (and probably a buffer opamp) will do the job.
More to it than I realized. How do I decide what's the optimal solution? I can see that lowering the resistor value or capacitor value will decrease the settling time (which I interpret as effective response time), but it also increases the ripple. You suggested even two LPF in parallel, right? How would that affect it? Wouldn't that be equivalent to ½ the resistor value and 2x the capacitor value?
Maybe a DAC wouldn't be all that much extra programming. The one you suggested has 4 times the resolution of the Arduino Uno, so couldn't I just multiply the Arduino output by 4 to get a darn-close approximation?
More to it than I realized. How do I decide what's the optimal solution? I can see that lowering the resistor value or capacitor value will decrease the settling time (which I interpret as effective response time), but it also increases the ripple. You suggested even two LPF in parallel, right? How would that affect it? Wouldn't that be equivalent to ½ the resistor value and 2x the capacitor value?
Not in parallel, in series - so filtering it twice.
Maybe a DAC wouldn't be all that much extra programming. The one you suggested has 4 times the resolution of the Arduino Uno, so couldn't I just multiply the Arduino output by 4 to get a darn-close approximation?
I understood that the PWM was 10bit output, maxing at 1023, and the DAC was 12bit maxing at 4095. So 0>0, 1>4, 2>8...1023>4092. So basically translating addresses. I wouldn't be losing resolution, I'd be translating to make sure my output is still 5v instead of 1.25V. but if the PWM output resolution is only 8 bits, I'd need to multiply by 16.
EDIT: I reread the post you shared and he used the I2C ports to communicate to the DAC, he didn't use a PWM output, which enables the full 10-bit read resolution to be translated to the 12-bit DAC/