From 94b562eb7d73773af6d7b9352e99f96a7dac66e0 Mon Sep 17 00:00:00 2001 From: ShiboSoftwareDev Date: Wed, 12 Nov 2025 22:24:14 +0200 Subject: [PATCH 1/4] refactor: Reorganize SPICE simulation documentation --- docs/advanced/spice-simulation.mdx | 218 ------------------ .../spice-simulation/boost-converter.mdx | 107 +++++++++ docs/guides/spice-simulation/introduction.mdx | 63 +++++ .../spice-simulation/rc-charging-circuit.mdx | 78 +++++++ 4 files changed, 248 insertions(+), 218 deletions(-) delete mode 100644 docs/advanced/spice-simulation.mdx create mode 100644 docs/guides/spice-simulation/boost-converter.mdx create mode 100644 docs/guides/spice-simulation/introduction.mdx create mode 100644 docs/guides/spice-simulation/rc-charging-circuit.mdx 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/boost-converter.mdx b/docs/guides/spice-simulation/boost-converter.mdx new file mode 100644 index 0000000..51998aa --- /dev/null +++ b/docs/guides/spice-simulation/boost-converter.mdx @@ -0,0 +1,107 @@ +--- +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" + +## 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. +

diff --git a/docs/guides/spice-simulation/introduction.mdx b/docs/guides/spice-simulation/introduction.mdx new file mode 100644 index 0000000..1f33b2d --- /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](/docs/guides/tscircuit-essentials/port-and-net-selectors) 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..4bfed1b --- /dev/null +++ b/docs/guides/spice-simulation/rc-charging-circuit.mdx @@ -0,0 +1,78 @@ +--- +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" + +## 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. +

From 4572c1a928621a5189ec09c87683c72cf69d466a Mon Sep 17 00:00:00 2001 From: ShiboSoftwareDev Date: Wed, 12 Nov 2025 22:25:18 +0200 Subject: [PATCH 2/4] cleanup --- docs/guides/spice-simulation/boost-converter.mdx | 1 - docs/guides/spice-simulation/rc-charging-circuit.mdx | 1 - 2 files changed, 2 deletions(-) diff --git a/docs/guides/spice-simulation/boost-converter.mdx b/docs/guides/spice-simulation/boost-converter.mdx index 51998aa..e33374d 100644 --- a/docs/guides/spice-simulation/boost-converter.mdx +++ b/docs/guides/spice-simulation/boost-converter.mdx @@ -6,7 +6,6 @@ description: An example of a boost converter circuit configured for SPICE simula --- import CircuitPreview from "@site/src/components/CircuitPreview" -## 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 diff --git a/docs/guides/spice-simulation/rc-charging-circuit.mdx b/docs/guides/spice-simulation/rc-charging-circuit.mdx index 4bfed1b..fdc7eac 100644 --- a/docs/guides/spice-simulation/rc-charging-circuit.mdx +++ b/docs/guides/spice-simulation/rc-charging-circuit.mdx @@ -6,7 +6,6 @@ description: An example of an RC charging circuit configured for SPICE simulatio --- import CircuitPreview from "@site/src/components/CircuitPreview" -## 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{" "} From bc2565c0a43b0fdd8980dac71b2c4d6400875efd Mon Sep 17 00:00:00 2001 From: ShiboSoftwareDev Date: Wed, 12 Nov 2025 22:33:00 +0200 Subject: [PATCH 3/4] fix build error --- docs/guides/spice-simulation/introduction.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/spice-simulation/introduction.mdx b/docs/guides/spice-simulation/introduction.mdx index 1f33b2d..dd49410 100644 --- a/docs/guides/spice-simulation/introduction.mdx +++ b/docs/guides/spice-simulation/introduction.mdx @@ -43,7 +43,7 @@ Example:

Measures the voltage at a specific point in the circuit.

| Property | Type | Description | | :--- | :--- | :--- | -| `connectsTo` | string | A [port selector](/docs/guides/tscircuit-essentials/port-and-net-selectors) indicating where to place the probe. | +| `connectsTo` | string | A port selector indicating where to place the probe. |
Example: ```tsx From 980d965f25caf483e2915157e8c8704119ea6858 Mon Sep 17 00:00:00 2001 From: ShiboSoftwareDev Date: Wed, 12 Nov 2025 22:42:35 +0200 Subject: [PATCH 4/4] renambe tab --- docs/guides/spice-simulation/_category_.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docs/guides/spice-simulation/_category_.json 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 +}