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