LTspice: Generating Triangular & Sawtooth Waveforms

2016-03-16
添加至 myAnalog

将文章添加到 myAnalog 的资源部分、现有项目或新项目。

创建新项目

Some of the most common waveforms needed in simulating voltage and current sources are sine, square, triangular and sawtooth shapes.

Sine, Square, Triangular & Wawtooth Waveform Shapes

Sine, Square, Triangular & Sawtooth Waveform Shapes

LTspice® simulation software has a built-in pulse, sine, exponential, single frequency FM and an arbitrary piece-wise linear functions available in the source component editor. Although it may not look like it, LTspice does have a triangular and sawtooth functions available but they need to be created from either a PULSE or PWL function.

LTspice Voltage Source Fuctions

LTspice Voltage Source Fuctions

PULSE Function

PULSE fuction is often used in transient circuit simulation where we want the source to behave like a square wave. You can omit Ncycles if you need a free-running square waveform.

PULSE(Voff Von Tdelay Trise Tfall Ton Tperiod Ncycles)

A simple approach to creating a triangular and sawtooth waveform is using the PULSE fuction using the source component editor shown above. For the triangular waveform you can set the rise and fall time equal to 1/2 of your desired period in your pulse function. Likewise, to create a sawtooth fuction you cab set the rise time equal to the period and the fall time to zero. The PULSE function can be further modify to best match your simulation needs. Waveforms for these two fuctions are show on the top of the page.

Triangular & Sawtooth Waveform Generated from Pulse Fuction

Triangular & Sawtooth Waveform Generated from Pulse Fuction

PWL Function

For any arbitrary or complex waveform, you can always rely on the piece-wise linear function. The arbitrary piece-wise linear fuction is defined by a sequence of time and voltage pairs.

PWL(t1 v1 t2 v2 t3 v3...)

This specifies that for time before t1, the voltage is v1. For times between t1 and t2, the voltage varies linearly between v1 and v2. There can be any number of time, voltage points given and for times after the last time, the voltage is the last voltage.

To implement a triangular or sawtooth waveform you could use the following piece-wise linear functions. Waveforms for these two fuctions are show on the top of the page.

Triangular & Sawtooth Waveform Generated from Piece-Wise Linear Fuction

Triangular & Sawtooth Waveform Generated from Piece-Wise Linear Fuction

These two examples use an undocumented repeat feature of PWL function. To explore these features you will need to directly edit by right-clicking on the source symbol's text in the schematic editor rather than using the source component editor.

Here are some highlights of the undocumented features for the PWL fuction:

  • Repeat date pairs forever

PWL REPEAT FOREVER (0 0 .5 1 1 0) ENDREPEAT

  • Repeat data pairs for 5 cycles

PWL REPEAT 5 (0 0 .5 1 1 0) ENDREPEAT

  • A trigger expression that turns the source on as long as the expression is true

PWL (0 0 .5 1 1 0) TRIGGER V(node)>1

  • Scaled the time or source values

PWL TIME_SCALE_FACTOR=0.5 VALUE_SCALE_FACTOR=2 (0 0 .5 1 1 0)

More information on the pulse, sine, exponential, single frequency FM and an arbitrary piece-wise linear functions is available in the LTspice help file (F1). An example LTspice simulation is also provided below for your reference.

关于作者

Gabino Alonso
Gabino Alonso目前是Power by Linear™部门的战略营销总监。加入ADI公司之前,Gabino在凌力尔特、德州仪器、加州理工州立大学担任过市场营销、工程、运营和讲师等多个职位。他拥有加州大学圣巴巴拉分校电子和计算机工程硕士学位。

关联至此文章

最新视频 20

Subtitle
了解更多
添加至 myAnalog

将文章添加到 myAnalog 的资源部分、现有项目或新项目。

创建新项目