# Shunt Amplifier with Shunt (`shuntAmplifier`)

> A shunt resistor and amplifier that read current in both directions.

![shuntAmplifier](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/shuntAmplifier.svg)

[Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/shuntAmplifier/)

**Group:** ICs · **Kind:** `{"definition":"shuntAmplifier","kind":"subsystem"}`

## When to use it

Use it to measure a current that flows both ways with a shunt. Use Current-Sense Amplifier for one direction, and Isolated Amplifier with Shunt for isolation.

## Pins

| Pin | Domain | Meaning |
|---|---|---|
| `IPP` | electrical | Primary current in, positive reading |
| `IPN` | electrical | Primary current out |
| `OUT` | electrical | Output, measured against GND |
| `GND` | electrical | Ground reference of the output |

## Common parameters

- `rSense`: The shunt resistor between IPP and IPN (your choice, not part of the IC) (Default: 0.005)
- `gain`: Gain (the A1 device: 20 V/V) (Default: 20)
- `bw`: Bandwidth: the single pole of the response (-3 dB, all gains) (Default: 400000)
- `vref`: Output at zero current: both reference pins at VS / 2 for a bidirectional output (Default: 2.5)
- `noise`: RMS output noise; 0 = a noiseless amplifier (Default: 0)

## Parameters

| Key | Unit | Default | Typical range | Description | Datasheet source |
|---|---|---|---|---|---|
| `rSense` | Ω | 0.005 | 1u – 10 Ω | The shunt resistor between IPP and IPN (your choice, not part of the IC) | assumption |
| `gain` | V/V | 20 | 1 – 10k V/V | Gain (the A1 device: 20 V/V) | Section 7.5 G, INA240A1, p.5 |
| `gainErr` | — | 0 | -100m – 100m | Gain error as a fraction (typically +/-0.05 %; 0 = nominal) | Section 7.5 gain error typ +/-0.05 %, p.5 (set to 0 here) |
| `bw` | Hz | 400000 | 1k – 100meg Hz | Bandwidth: the single pole of the response (-3 dB, all gains) | Section 7.5 BW typ, p.5 |
| `vos` | V | 0.000005 | -1m – 1m V | Input offset voltage (the datasheet gives it as +/-) | Section 7.5 VOS typ +/-5 uV, p.5 |
| `vref` | V | 2.5 | 0 – 5.5 V | Output at zero current: both reference pins at VS / 2 for a bidirectional output | Section 7.5 test conditions VREF1 = VREF2 = VS / 2, p.5 |
| `vs` | V | 5 | 2.7 – 5.5 V | Supply voltage: sets the upper output limit | Section 7.5 test conditions VS = 5 V, p.5 |
| `swingHi` | V | 0.05 | 0 – 1 V | Output swing below the VS rail | Section 7.5 swing to VS power-supply rail typ, RL = 10 kOhm, p.5 |
| `swingLo` | V | 0.001 | 0 – 1 V | Output swing above GND | Section 7.5 swing to GND typ, VREF = 0 V, p.5 |
| `noise` | V | 0 | 0 – 1 V | RMS output noise; 0 = a noiseless amplifier | Section 7.5 voltage noise density 40 nV/sqrt(Hz) input referred, p.5 (about 0.6 mV rms at the output over 400 kHz with gain 20) |
| `seed` | — | 1 | 0 – 9007t | Whole-number seed of the noise | model parameter |

_Parameter descriptions are in English in both languages._

## Model

The primary path is the shunt rSense in series with a current meter, so it drops rSense * i. The output is a controlled voltage source driven by vref + gain * (1 + gainErr) * (rSense * i + vos), then a first-order low-pass at bw, then seeded Gaussian noise of noise volts rms, then a limit to GND + swingLo ... vs - swingHi. The supply and the reference are parameters (vs, vref), not pins. Input bias currents, common-mode range, PWM rejection, slew rate and drift are not modelled.

## Common mistakes

- The output saturates when the current is too large, which is near 24 A with the default gain and shunt. Use a smaller shunt or a lower gain when the current is larger.
- rSense is your own shunt and not a datasheet value, so check its voltage drop and heating yourself. gain and bw belong together, and the step must stay below about a tenth of the response time.
- The noise is 0 by default. Set about 0.6 mV rms to see the datasheet noise at the default gain, and use another seed for another noise.

Problems rules: `step.too_large`, `param.out_of_range`

## Datasheet and sources

gain is the gain of your variant (20, 50, 100 or 200 V/V), bw is the -3 dB bandwidth, and vos is the typical input offset. gainErr is the gain error as a fraction (0.05 % is 0.0005). swingHi and swingLo are the typical output swing to the supply and to ground, and vref is half the supply for a bidirectional output. rSense and vs are your design values. Pass them to ic.fromSpec with the shuntAmplifier template and rename the pins to the datasheet names, or place the INA181A1 to INA181A4 presets (SBOS793H: gain 20, 50, 100, 200 V/V, 350, 210, 150, 105 kHz).

## Example

Open the example with the command `file.openExample` and the name `demo:shuntAmplifier`.

---
Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand.
