strange oscillations in the output of the LTSPICE D flip-flop model - Page 1
Forum section: electronics / general

author: graybeard
author_rank: Frequent Contributor
timestamp: August 21, 2021, 07:17:02 pm
content: I was planning to run simulation with LTSPICE using the built-in theD flip-flop model. Since I have never used that model I decided to run a few test simulations with the model before I used it in a much larger circuit. When I ran the simulations I observed very strange oscillations on the flip-flop output.When I zoomed in on the apparent oscillations it appears to be a triangle waveformI am running the latest version of LTSPICE as of today August 21, 2021These results are not giving me much confidence in the LTSPICE's built-in digital models.If you want to try it, here are links to the files:The LT spice schematicA LT spice plot parameters file (not needed but nice to have)The MAX985 comparator modelI will email a link to this post to Analog Devices bug reporting email.Chris Grossman

author: RoGeorge
author_rank: Super Contributor
timestamp: August 21, 2021, 07:53:03 pm
content: I don't think that's a bug. Looks more like numerical artifacts caused by SPICE trying to optimize for a minimum number of steps to compute, yet the duration is very long (20 seconds) and the digital circuit is millions times faster when compared with those 20 seconds.SPICE needs a little guidance in this situation.Specify a maximum allowed timestep (for example 1 microseconds). Use ".tran 0 20 0 1us uic" instead of ".tran 0 20 0 uic", and the ringing at each edge will appear reasonably OK.

author: graybeard
author_rank: Frequent Contributor
timestamp: August 21, 2021, 08:18:43 pm
content: That only changes the period of the ringing. It should not be there in the first place.

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 21, 2021, 08:28:43 pm
content: Quote from: RoGeorge on August 21, 2021, 07:53:03 pmYes, it's exactly that. If you zoom in on the "oscillations", you can see that those are jumps of discrete values (it looks like a 'triangle' wave). This is typical of an integration error, which comes from the fact that there are very sharp edges relative to the total simulation time. Spice will try adjusting the simulation steps automatically but there are limits to this.Quote from: RoGeorge on August 21, 2021, 07:53:03 pmYes, this is how you can work around this.Note that I'm a bit surprised here, because I would have expected the logic primitives in LTSpice to be pure digital simulation - LTSpice is a mixed signal simulator - so that I wouldn't have expected integration errors on a digital primitive output, but I don't know how it's really implemented behind the scenes. Possibly it's the "analog-to-digital" interface of the primitive that causes this.

author: graybeard
author_rank: Frequent Contributor
timestamp: August 21, 2021, 08:29:33 pm
content: It is much happier with Gear integration since it does a much better job of varying the size of the time step. However there is still a bit of input state dependent overshooot I would not expect from a simple digital model.Chris

author: RoGeorge
author_rank: Super Contributor
timestamp: August 21, 2021, 09:35:39 pm
content: Quote from: graybeard on August 21, 2021, 08:29:33 pmWow, that ran so much faster than forcing a max time step!I didn't know about the Gear method, thank you.