# How can I build hall sensor based PWM dimmer?

So there is a hall sensor on a scooter throttle and it's missing the speed controller. I tested the sensor and it does work. 5V in, and with full throttle it's about 4V and 0.9 when closed.

I want to make a pwm 'dimmer' (actually a motor speed controller which are similar) but I can't find a way except using arduino to measure the analog volts and calibrate it into a 0-255 value which I did last night.

But can someone tell me if this can be done with an op amp and 555, and tune it to have 0-100% duty cycle? The 0% is important as the motor shouldn't start without throttle, but also should be able to reach near 100%.

Thanks

• Sure, let the 555 run at 100 Hz for example. Make the discharge resistor (between pin 6 and 7) much smaller than the charging resistor. Then the voltage across the capacitor will aproximate a sawtooth shape. Use a comparator (or an opamp) to compare that sawtooth with the Hall sensor voltage. At the output of the comparator you will then see a PWM signal related to the sensor voltage ! – Bimpelrekkie Sep 15 '15 at 17:35
• Thanks, I forgot to mention it needs to be tuned for 0% duty duty cycle when off and as close to 100% as possible on high. If it's not too much trouble a rough schematic would be awesome. Otherwise, I will probably just use the arduino since I know I can get a reliable 0-255 duty cycle. Matt – Matt Sep 16 '15 at 4:20

I expect a microcontroller with an ADC and a timer with output for pwm will be easiest. If you do want an analogue solution, you might look at comparator type relaxation oscillators. See http://www.linear.com/solutions/1417 for example.

Analog solution

simulate this circuit – Schematic created using CircuitLab

This solution uses an LTC6992-1 voltage-controlled pulse width modulator chip to do the PWM.

• Rset determines the internal master oscillator frequency.
• R1(LTC) and R2(LTC) determine the internal frequency divider.

The rest of the circuit scales the 0.9 - 4 V signal to 0 - 1 V.

• R1 and Rg2 provide the offset.
• Rg1 and Rf set the gain.
• R5 and R6 form a divider for the hall effect output to bring it below 1 V.
• The op-amp needs to work with 0 V on the inputs and drive the output down to zero volts. Presumably you will want it to run on a 5 V supply also.

All the resistor values were calculated using a rather interesting document Designing Gain and Offset in Thirty Seconds from Bruce Carter, Texas Instruments. I used Section 2 and Section 4. You should rerun my calculations. A trim-pot or two might not go astray.

Paste this row into cell A1 and convert text to columns separating on comma. Remove apostrophes to make formulas active.
Vref,   5,  V
Voutfs, 1,  V
Voutzs, 0,  V
Vinfs,  0.8,    V (after 5:1 reduction)
VinZS,  0.18,   V (after 5:1 reduction)

m (gain),   '=(B3-B4)/(B5-B6)
b (bias),   '=B4-B8*B6

Rf, 10000,  ohms (guess)
Rg, '=B12/(B8-1),   ohms
Rg2,    '=B13/10,   ohms
Rg1,    '=B13-B14,  ohms
Vref~,  '=(ABS(B9)*B15)/(B15+B12),  V
R1, '=B14*(B2-B16)/B16, ohms