Here is a complete simulation of a Run-Up phase of a simple DIY Multislope integrating ADC built from junkbox parts. Intended for people who want to play with something more complex than blinking an LED and who want to learn.
The Runup is 20ms long, with 1000 fixed steps @20us.
The integrator is composite one, with slope amplifier and fast comparator.
There are also 3 counters - for VrefP, VrefN and Runup_Clk events.
In the below example the input voltage is a sine wave 4Vpp, at 4V DC.
The simulation itself runs till 20ms, exactly.
You may measure the residual voltage at the end of Runup phase therefore.
The sequences and timings are provided by various voltage sources and by a simple CMOS logic. Timing is considered precise.
The ADC strategy is to sample the comparator output @20us periods, and to switch the VrefP and VrefN references as required. The number of VrefP and VrefN switchings is not constant, but 1000 in total.
This is not a continuous pwm Runup, nor any high-end related stuff, but rather a wiki-like one example intended for hobby experimenters.
With the below ready example you should get VrefP=321 and VrefN=679 at the runup end. With Vinput=4V with no added sine wave you should get the same (as the 500Hz sine wave cancels out during integration).
With a -10V Vinput you may get VrefP=955 and VrefN=45, and vice versa with 10V at its input.
With Vinput=0V (input shorted) you should get VrefP=504 and VrefN=496.
The 3 voltages in the upper pane do represent the event counters, at the end of the simulation you may go with the cursors to the very end of the timescale and read out the counters and residual voltage values.
Enclosed is the .asc source and .plt file.
Worked with LTspice latest, and the Bordodynov library for some parts used. The parts were chosen as an example only. You may experiment with better parts when models are available.
Note:
1. Before you start to mess with different parts, R/C values and timings, try to run the stuff to get familiar with it.
2. Not all models of op-amps and switches work fine. Feel free to experiment.
3. The V1 schematics is rather complex, the simulation speed is about 30us/sec with a mainstream 2 core notebook. So take a nap.
4. You will get around 750MB of data (waveforms) with the example.
Provided as-is.