Emulate an ADC in QSPICE

Is possible to emulate an ADC in C++, with a sampling timer and a buffer for using the samples in a buffer?

I would assume so, based on the work others have demonstrated here on the forum. I’ll leave it there and hope others contribute a more useful answer.

Hi, giordano.

Seems almost certainly possible. Post a part number for a chip that is similar to what you want and I’ll give it some thought.

–robert

Just an idea to implement textbook type waveform. Input allows 0V to FullScale, convert to output 0-255 (unsigned integer), and trigger by rising edge of clk.

2 Likes

Looking good. Things to consider:

  • Some (most?) ADC’s have an external reference voltage – sometimes VCC, often a separate reference pin. Maybe replace the FS param/attribute with an input port/reference voltage.

  • It would be possible for the input voltage being measured to be greater than the reference voltage or less than 0V. Maybe clip the min/max digitized value to 0-255.

Just thoughts.

–robert

I use FS parameter because I don’t want an extra voltage source in schematic, but you are correct that practically reference is generally an input pin. For min and max, the code included if… elseif… to prevent overflow.

I am only entry level C++ user and only try to demonstrate Qspice is possible for his request. May be after giordano gives more specify of what he is looking for, C++ expert in this community can give him a much better code.