Combining LTSpice Simulations with ALICE Scope traces

Circuit simulators like LTSpice, and others, are useful tools for testing out electronic circuit experiments before actually constructing the circuit. The ADALM1000 and ALICE 1.2 Desktop is a multi-purpose and incredibly useful set of measurement tools for testing electronics projects and experiments. In this Blog entry we are going to go over a simple example showing how to run a simulation in LTSpice, export the simulated voltage waveforms and then load them into ALICE so they can be compared to the measured voltage waveform you get on the actual circuit. By comparing simulated and actual results you can get the most out of this powerful combination of software and hardware.

The first thing to do is enter the following simple RC circuit into LTSpice. The resistor, R1, we are using is 10K ohms and the capacitor, C1, is 0.22 uF. A PULSE source is used to simulate the CHA output of the ADALM1000 and a 2.5 V DC source is used to simulate the fixed 2.5 V rail. We will name the output of the pulse as CHA and the voltage on the capacitor as CHB to match the ADALM1000 connections.

The transient simulation will be run from 0 to 20 mSec. Which will be exactly 2 cycles at 100 Hz (10 mSec period).

We will use the .wave directive to output the two node voltages of interest. The sample rate is set to 100KSPS to match the sample rate of the ADALM1000. The data values saved in the wave output will be 16 bit integers scaled from -1 to 1 volt. So the pulse high and low values are set to -0.8 and 0.8. When ALICE imports these integers it offsets and scales the values to 0 to 5 V to fit exactly in the ADALM1000 voltage range. So -0.8 V becomes 0.5 V. 0.0V becomes 2.5 V and +0.8 V becomes 4.5 V.

After running the simulation the results should look like the following plot.

There should also be the saved output.wav file that now contains the two simulated waveforms.

Now we can open ALICE and measure the actual circuit. With a 10 K resistor and 0.22uF capacitor connected to the ADALM1000 as shown in the schematic. We can setup CHA to output the 100 Hz square wave. In CHA, set the Min value to 0.5 and the Max value to 4.5 with the Mode set to SVMI and the shape to Square. For right now we can set CHB mode to Hi-Z.

With the Horz time scale set to 2 mSec/Div we can run ALICE and see the measure results of the circuit.

This plot looks a lot like the simulation but just how close are the two? To compare the two we next save snap-shots of the live waveforms and turn them on. The saved reference traces are drawn in a darker color so the plots will look like this.

We can load in the output.wav file and play the simulation data back through the arbitrary waveform generators of the ADALM1000. Under the AWG CH A Shape drop down menu we can click on Read WAV File. It will prompt you for the file to load. Navigate to where output.wav was saved and click on it. The wave file contains two signals so the program puts the first one (the node named CHA) in the AWGAwaveform buffer and the second one (the node named CHB) in the AWGBwaveform buffer. The buffer lengths should be at least 2000 points.

If we now set the CH B mode to SVMI and temporarily disconnect it from the capacitor and hit Run we should see something like this.

The brighter green and orange traces will now be the simulation results and the darker traces will be the actual measured results we just saved. As we can see the two results align closely but not exactly. This is most likely because the actual resistor and capacitor are not exactly 10 K ohms and 0.22uF.

There are other ways to display the waveform buffers loaded from the file and you can explore how to do that by reading through the ALICE Desktop Users Guide.

Hopefully this overview is enough to get you familiar with using these useful tools. If you have any additional questions please head over to the Virtual Classroom section of the EngineerZone Forum.

As always I welcome comments and suggestions from the user community out there on how to improve ALICE.