* SPICE netlist
Vpwm PWM 0 PWL(0 -12 10m 12)
R1 N002 PWM 100k
V1 V+ 0 12V
V2 0 V- 12V
V3 V3V3 0 3.3V
R3 CV2 N002 56k
XU2 0 N002 V3V3 0 CV2 AD8541 ;pnba In+)In-)V+)V-)OUT
V4 0 N003 5V
C1 CV2 N002 470p
R6 V- VRef 2.2k
D1 VRef 0 BZX84B10VL
R7 N002 VRef 200k
R2 N001 PWM 100k
R4 CV1 N001 33k
XU1 0 N001 V3V3 0 CV1 AD8541 ;pnba In+)In-)V+)V-)OUT
C2 CV1 N001 470p
R5 N001 VRef 169k
.tran 0 10m 0 500n
.include MCP6001.mod
.include LM4040NA10.mod

* LTspice schematic (.asc)
Version 4
SHEET 1 1728 864
WIRE -768 -416 -864 -416
WIRE -608 -416 -688 -416
WIRE -560 -416 -608 -416
WIRE -448 -416 -496 -416
WIRE -48 -416 -144 -416
WIRE 112 -416 32 -416
WIRE 160 -416 112 -416
WIRE 272 -416 224 -416
WIRE 736 -288 736 -336
WIRE -608 -272 -608 -416
WIRE -560 -272 -608 -272
WIRE -448 -272 -448 -416
WIRE -448 -272 -480 -272
WIRE 112 -272 112 -416
WIRE 160 -272 112 -272
WIRE 272 -272 272 -416
WIRE 272 -272 240 -272
WIRE 736 -176 736 -208
WIRE 864 -176 736 -176
WIRE -528 -128 -528 -144
WIRE 192 -128 192 -144
WIRE -768 -112 -832 -112
WIRE -608 -112 -608 -272
WIRE -608 -112 -688 -112
WIRE -560 -112 -608 -112
WIRE -48 -112 -112 -112
WIRE 112 -112 112 -272
WIRE 112 -112 32 -112
WIRE 160 -112 112 -112
WIRE 736 -112 736 -176
WIRE -448 -96 -448 -272
WIRE -448 -96 -496 -96
WIRE -304 -96 -448 -96
WIRE 272 -96 272 -272
WIRE 272 -96 224 -96
WIRE 416 -96 272 -96
WIRE -560 -80 -608 -80
WIRE 160 -80 112 -80
WIRE -528 -48 -528 -64
WIRE 192 -48 192 -64
WIRE 736 48 736 -48
WIRE -608 64 -608 -80
WIRE 112 64 112 -80
WIRE -336 320 -336 256
WIRE -176 320 -176 256
WIRE 0 320 0 256
WIRE 160 320 160 256
WIRE 352 320 352 288
WIRE -336 432 -336 400
WIRE -176 432 -176 400
WIRE 0 432 0 400
WIRE 160 432 160 400
WIRE 352 432 352 400
FLAG 352 432 0
FLAG 352 288 PWM
FLAG -112 -112 PWM
FLAG 160 432 0
FLAG 0 432 0
FLAG -176 432 0
FLAG -176 256 V3V3
FLAG 0 256 V-
FLAG 160 256 V+
FLAG 416 -96 CV2
FLAG 192 -48 0
FLAG 192 -144 V3V3
FLAG 112 64 0
FLAG -144 -416 VRef
FLAG -336 432 0
FLAG 864 -176 VRef
FLAG 736 48 0
FLAG 736 -336 V-
FLAG -832 -112 PWM
FLAG -304 -96 CV1
FLAG -528 -48 0
FLAG -528 -144 V3V3
FLAG -608 64 0
FLAG -864 -416 VRef
SYMBOL voltage 352 304 R0
SYMATTR InstName Vpwm
SYMATTR Value PWL(0 -12 10m 12)
SYMBOL res 48 -128 R90
SYMATTR InstName R1
SYMATTR Value 100k
SYMBOL /voltage 160 304 R0
SYMATTR InstName V1
SYMATTR Value 12V
SYMBOL /voltage 0 416 R180
SYMATTR InstName V2
SYMATTR Value 12V
SYMBOL /voltage -176 304 R0
SYMATTR InstName V3
SYMATTR Value 3.3V
SYMBOL res 256 -288 R90
SYMATTR InstName R3
SYMATTR Value 56k
SYMBOL /Opamps/AD8541 192 -160 R0
SYMATTR InstName U2
SYMBOL /voltage -336 416 R180
SYMATTR InstName V4
SYMATTR Value 5V
SYMBOL /cap 224 -432 R90
SYMATTR InstName C1
SYMATTR Value 470p
SYMBOL /res 720 -304 R0
SYMATTR InstName R6
SYMATTR Value 2.2k
SYMBOL /diode 720 -112 R0
SYMATTR InstName D1
SYMATTR Value BZX84B10VL
SYMBOL /res 48 -432 R90
SYMATTR InstName R7
SYMATTR Value 200k
SYMBOL res -672 -128 R90
SYMATTR InstName R2
SYMATTR Value 100k
SYMBOL res -464 -288 R90
SYMATTR InstName R4
SYMATTR Value 33k
SYMBOL /Opamps/AD8541 -528 -160 R0
SYMATTR InstName U1
SYMBOL /cap -496 -432 R90
SYMATTR InstName C2
SYMATTR Value 470p
SYMBOL /res -672 -432 R90
SYMATTR InstName R5
SYMATTR Value 169k