|
dVcap=vref/RC*dt
First Vcap is zero, comparator output is "0". After integrated Vcap=Vin the comparator output "1", then switch close and cap discharge to ground.
Vin = vref/RC*t
If we let
Full scale: T=2^N*Tclk=RC
t=D*Tclk
Then
Vin vref
--- = ---
D 2^N
How to run it :
N=8, RC=10u s
Clock period = 10u/256=39.1ns
if you set vsource 39.1ns directly it cannot work, so first set 10us and timescale=5us after it running, then change it to 39.1ns
example vref=5v, vin=2v, output is 0x66
When you run it again (clock is 10us)the circuit cannot run because timescale is ns, so quickly click button "run"+"watch", then change timescale and run it again.
|