Monday, May 16, 2022

How to Sweep Resistance During Simulation in Altium

I wanted to simulate an op-amp circuit with Altium Designer to determine the Vout as I sweep through RTD (Resistance Temperature Detector) values.

"But Matthew! Why not just use LTspice like all of us cool kids?"

Well first off, LTspice has the most baffling shortcut key setup. I'm sure it made sense in the late 80s or something, but in this century I expect Ctrl+C to be "copy." Also, if my MSRP $8,000 piece of software includes simulation support, seems like it ought to work.

Unfortunately, by default, Altium does not offer an easy way to simulate the response of sweeping a resistor or potentiometer. A parameter sweep is offered, but this essentially runs a new simulation for each parameter change, rather than a continuous, interpolated output curve. This would be handy if I wanted to see what happens when I sweep Vref from 0 V to 5 V, with the RTD at a few values from 1 kΩ to 1.887 kΩ, but that's not what I want here.

BUT! After some searching, I discovered that SPICE does support using DC Sweep Analysis to change a resistor value, even though Altium does not show this as an option.

Here's my solution:

  1. Create a dummy voltage source. I called it Vrtd to keep track of it, but it doesn't really matter.
  2. Note the name of your resistor you want to vary. In my example, I cleverly named it "RTD".
  3. Set up a DC Sweep Analysis, using Vrtd as the primary source.
    1. Set this up to sweep from 1k to 1.887k, with a step size of 443.5.
  4. Save all, validate project.
  5. Go to Design > Netlist for Project > Xspice.
  6. Open the resulting .nsx file.
  7. Find the line that says ".DC Vrtd 1000 1887 443.5".
  8. Change this to ".DC RTD 1000 1887 443.5".
  9. Save.
  10. Run the simulation from the .nsx file.

If all goes well, you should see the voltage curve of your desired net plotted with the resistor value along the X axis, and the resulting voltage along the Y axis.

Huzzah!