diff --git a/docs/advanced/spice-simulation.mdx b/docs/advanced/spice-simulation.mdx deleted file mode 100644 index 67e42cd..0000000 --- a/docs/advanced/spice-simulation.mdx +++ /dev/null @@ -1,218 +0,0 @@ ---- -title: SPICE Simulation -sidebar_position: 4 -description: >- - Run SPICE simulations on your circuits to analyze their analog behavior. ---- - -import CircuitPreview from "@site/src/components/CircuitPreview" - -## Overview - -tscircuit supports SPICE simulation to analyze the analog behavior of your circuits. You can define voltage sources with various waveforms, place probes to measure voltages, and configure the simulation parameters. The results can be visualized to understand how your circuit performs over time. - -## Simulation Components - -### `` - -This component configures and enables the analog simulation for the board. - -| Property | Type | Description | -| ------------- | ------ | ----------------------------------------------------- | -| `duration` | number | The total duration of the simulation (e.g., in seconds). | -| `timePerStep` | number | The time interval between simulation steps (e.g., in seconds). | -| `spiceEngine` | string | The SPICE engine to use. Can be `"spicey"` (default) or `"ngspice"`. | - -Example: - -```tsx - -``` - -### Probes - -Probes are used to specify which parts of the circuit you want to measure. These do not have a physical representation on the PCB. - -#### `` - -Measures the voltage at a specific point in the circuit. - -| Property | Type | Description | -| ------------ | ------ | ------------------------------------------------------------------------------------------------------- | -| `connectsTo` | string | A [port selector](../guides/tscircuit-essentials/port-and-net-selectors.md) indicating where to place the probe. | - -Example: - -```tsx - -``` - -### `` - -For simulations, `` can be configured to produce various waveforms beyond a simple DC voltage. - -| Property | Type | Description | -| ----------- | ---------------- | ------------------------------------------------------------------------------ | -| `waveShape` | string | Shape of the voltage wave. Can be `"dc"`, `"sine"`, `"square"`, `"triangle"`. | -| `frequency` | string or number | Frequency of the waveform (e.g., `"1kHz"` or `1000`). | -| `amplitude` | string or number | Amplitude of the AC signal. For square waves, this is the peak voltage. | -| `offset` | string or number | DC offset of the waveform. | -| `dutyCycle` | number | For square waves, the fraction of the period the signal is high (0 to 1). | - -## Example: Boost Converter - -Here is an example of a boost converter circuit configured for SPICE simulation. It uses one voltage source (`V2`) with a square wave to drive a MOSFET, boosting the voltage from a 5V DC source (`V1`) to a higher level. Voltage probes are placed at the input and output to observe the results. - - ( - - - .pin1"} to={".L1 > .pin1"} /> - .pin2"} to={".D1 > .anode"} /> - .cathode"} to={".C1 > .pin1"} /> - .cathode"} to={".R1 > .pin1"} /> - .pin2"} to={".R1 > .pin2"} /> - .pin2"} to={".V1 > .pin2"} /> - .pin2"} to={".M1 > .drain"} /> - .source"} to={".V1 > .pin2"} /> - .source"} to={"net.GND"} /> - .gate"} to={".V2 > .pin1"} /> - .pin2"} to={".V1 > .pin2"} /> - - - - - - - .pin1"} /> - .pin1"} /> - - - -) -`} /> - -The simulation results would show the output voltage across `R1` successfully "boosted" compared to the 5V input from `V1`. The specific output voltage depends on the duty cycle of the MOSFET driver `V2` and the component values. - -## Example: RC Charging Circuit - -Here's an example of an RC circuit that forms a voltage divider with a capacitor. This also functions as a low-pass filter. Since no `spiceEngine` is specified in ``, it uses the default `spicey` engine. Voltage probes are placed at the input and output to observe the charging behavior. - - ( - - - - - - - .pin1"} to={".R1 > .pin1"} /> - .pin2"} to={".R2 > .pin1"} /> - .pin2"} to={".C1 > .pin1"} /> - .pin2"} to={"net.GND"} /> - .pin2"} to={"net.GND"} /> - .pin2"} to={"net.GND"} /> - - .pin1"} /> - .pin2"} /> - - - -) -`} /> - -The simulation results will show the voltage at the junction of `R1`, `R2`, and `C1` charging towards the Thevenin equivalent voltage of the R1-R2 divider. diff --git a/docs/guides/spice-simulation/_category_.json b/docs/guides/spice-simulation/_category_.json new file mode 100644 index 0000000..c8f5d66 --- /dev/null +++ b/docs/guides/spice-simulation/_category_.json @@ -0,0 +1,10 @@ +{ + "label": "SPICE Simulation", + "position": 5, + "link": { + "type": "generated-index", + "description": "Learn how to use tscircuit to run SPICE simulations and analyze analog circuit behavior." + }, + "collapsible": true, + "collapsed": true +} diff --git a/docs/guides/spice-simulation/boost-converter.mdx b/docs/guides/spice-simulation/boost-converter.mdx new file mode 100644 index 0000000..e33374d --- /dev/null +++ b/docs/guides/spice-simulation/boost-converter.mdx @@ -0,0 +1,106 @@ +--- +title: Boost Converter Example +sidebar_label: Boost Converter +sidebar_position: 2 +description: An example of a boost converter circuit configured for SPICE simulation. +--- +import CircuitPreview from "@site/src/components/CircuitPreview" + +

+ Here is an example of a boost converter circuit configured for SPICE + simulation. It uses one voltage source (`V2`) with a square wave to drive + a MOSFET, boosting the voltage from a 5V DC source (`V1`) to a higher + level. Voltage probes are placed at the input and output to observe the + results. +

+ ( + + + .pin1"} to={".L1 > .pin1"} /> + .pin2"} to={".D1 > .anode"} /> + .cathode"} to={".C1 > .pin1"} /> + .cathode"} to={".R1 > .pin1"} /> + .pin2"} to={".R1 > .pin2"} /> + .pin2"} to={".V1 > .pin2"} /> + .pin2"} to={".M1 > .drain"} /> + .source"} to={".V1 > .pin2"} /> + .source"} to={"net.GND"} /> + .gate"} to={".V2 > .pin1"} /> + .pin2"} to={".V1 > .pin2"} /> + + + + + + + .pin1"} /> + .pin1"} /> + + + +) +`} +/> +

+ The simulation results would show the output voltage across `R1` + successfully "boosted" compared to the 5V input from `V1`. The specific + output voltage depends on the duty cycle of the MOSFET driver `V2` and the + component values. +

diff --git a/docs/guides/spice-simulation/introduction.mdx b/docs/guides/spice-simulation/introduction.mdx new file mode 100644 index 0000000..dd49410 --- /dev/null +++ b/docs/guides/spice-simulation/introduction.mdx @@ -0,0 +1,63 @@ +--- +title: SPICE Simulation Introduction +sidebar_label: Introduction +sidebar_position: 1 +description: >- + Run SPICE simulations on your circuits to analyze their analog behavior. +--- +import CircuitPreview from "@site/src/components/CircuitPreview" + +## Overview +

+ tscircuit supports SPICE simulation to analyze the analog behavior of your + circuits. You can define voltage sources with various waveforms, place + probes to measure voltages, and configure the simulation parameters. The + results can be visualized to understand how your circuit performs over + time. +

+## Simulation Components +### {""} +

+ This component configures and enables the analog simulation for the board. +

+| Property | Type | Description | +| :--- | :--- | :--- | +| `duration` | number | The total duration of the simulation (e.g., in seconds). | +| `timePerStep` | number | The time interval between simulation steps (e.g., in seconds). | +| `spiceEngine` | string | The SPICE engine to use. Can be `"spicey"` (default) or `"ngspice"`. | +
+Example: +```tsx + +``` +### Probes +

+ Probes are used to specify which parts of the circuit you want to measure. + These do not have a physical representation on the PCB. +

+#### {""} +

Measures the voltage at a specific point in the circuit.

+| Property | Type | Description | +| :--- | :--- | :--- | +| `connectsTo` | string | A port selector indicating where to place the probe. | +
+Example: +```tsx + +``` +### {""} +

+ For simulations, {""} can be configured to produce + various waveforms beyond a simple DC voltage. +

+| Property | Type | Description | +| :--- | :--- | :--- | +| `waveShape` | string | Shape of the voltage wave. Can be `"dc"`, `"sine"`, `"square"`, `"triangle"`. | +| `frequency` | string or number | Frequency of the waveform (e.g., `"1kHz"` or `1000`). | +| `amplitude` | string or number | Amplitude of the AC signal. For square waves, this is the peak voltage. | +| `offset` | string or number | DC offset of the waveform. | +| `dutyCycle` | number | For square waves, the fraction of the period the signal is high (0 to 1). | diff --git a/docs/guides/spice-simulation/rc-charging-circuit.mdx b/docs/guides/spice-simulation/rc-charging-circuit.mdx new file mode 100644 index 0000000..fdc7eac --- /dev/null +++ b/docs/guides/spice-simulation/rc-charging-circuit.mdx @@ -0,0 +1,77 @@ +--- +title: RC Charging Circuit Example +sidebar_label: RC Charging Circuit +sidebar_position: 3 +description: An example of an RC charging circuit configured for SPICE simulation. +--- +import CircuitPreview from "@site/src/components/CircuitPreview" + +

+ Here's an example of an RC circuit that forms a voltage divider with a + capacitor. This also functions as a low-pass filter. Since no{" "} + spiceEngine is specified in {""}, it uses + the default spicey engine. Voltage probes are placed at the + input and output to observe the charging behavior. +

+ ( + + + + + + + .pin1"} to={".R1 > .pin1"} /> + .pin2"} to={".R2 > .pin1"} /> + .pin2"} to={".C1 > .pin1"} /> + .pin2"} to={"net.GND"} /> + .pin2"} to={"net.GND"} /> + .pin2"} to={"net.GND"} /> + + .pin1"} /> + .pin2"} /> + + + +) +`} +/> +

+ The simulation results will show the voltage at the junction of `R1`, + `R2`, and `C1` charging towards the Thevenin equivalent voltage of the + R1-R2 divider. +