# Current-Sense Amplifier (`currentSenseAmp`)

> Turns the small voltage across a shunt into a larger ground-referenced signal.

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

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

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

## When to use it

Use it to feed a controller or comparator from a shunt, with the real bandwidth and supply limits. Use Single-Pole Operational Amplifier when you want your own feedback network.

## Pins

| Pin | Domain | Meaning |
|---|---|---|
| `INP` | electrical | Positive sense input, the bus side of the shunt |
| `INN` | electrical | Negative sense input, the load side of the shunt |
| `OUT` | electrical | Output, measured against GND |
| `VS` | electrical | Supply, sets the top of the output |
| `GND` | electrical | Ground reference of output and supply |

## Common parameters

- `gain`: Gain (the A3 device) (Default: 100)
- `bw`: Bandwidth: the single pole of the response (Default: 150000)
- `sr`: Slew rate (2 V/us) (Default: 2000000)
- `vos`: Input offset voltage (the datasheet gives it as +/-) (Default: 0.000025)

## Parameters

| Key | Unit | Default | Typical range | Description | Datasheet source |
|---|---|---|---|---|---|
| `gain` | V/V | 100 | 100m – 100k V/V | Gain (the A3 device) | Section 7.5 G, A3 devices, p.8 |
| `gainErr` | — | 0 | -100m – 100m | Gain error as a fraction (the datasheet gives +/-0.1 % typical; 0 = nominal) | Section 7.5 EG typ +/-0.1 %, p.8 (set to 0 here) |
| `bw` | Hz | 150000 | 1 – 1g Hz | Bandwidth: the single pole of the response | Section 7.5 BW, A3 devices, CLOAD = 10 pF, p.8 |
| `sr` | V/s | 2000000 | 1k – 10g V/s | Slew rate (2 V/us) | Section 7.5 SR typ, p.8 |
| `vos` | V | 0.000025 | -100m – 100m V | Input offset voltage (the datasheet gives it as +/-) | Section 7.5 VOS typ +/-25 uV, p.8 |
| `swingHi` | V | 0.02 | 0 – 10 V | Output swing below the VS rail | Section 7.5 VSP typ, RL = 10 kOhm, p.8 |
| `swingLo` | V | 0.0005 | 0 – 10 V | Output swing above GND | Section 7.5 VSN typ, RL = 10 kOhm, p.8 |

_Parameter descriptions are in English in both languages._

## Model

The target is gain * (1 + gainErr) * (V(INP) - V(INN) + vos), clamped to GND + swingLo ... VS - swingHi. The output follows the clamped target through a single pole dy/dt = 2*pi*bw*(target - y) limited to plus or minus sr, so it never winds up beyond the rails. The inputs draw nothing and see only their difference. Common-mode range and CMRR, bias currents, output impedance, noise and bidirectional (reference pin) variants are not modelled. The output only swings between GND and VS, so a negative sense voltage clips at swingLo.

## Common mistakes

- gain and bw belong together, because the datasheet lists a different bandwidth for each gain variant. Also check that the gain times the full-scale sense voltage stays below the supply, or the output clips and the current reads too low.
- The output reaches the circuit one to two solver steps late. Keep the step below about a tenth of the response time, which is about 1 us at 150 kHz, and finer for an accurate settling time.
- Wire INP to the supply side of the shunt and INN to the load side. Otherwise the sense voltage is negative and the output sits at its lowest level, and VS and GND must share the circuit ground.

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

## Datasheet and sources

gain is the nominal gain of your variant, and bw is its small-signal bandwidth at the load capacitance listed. sr is the typical slew rate in V/s (2 V/us is 2e6). vos is the typical input offset. gainErr is the gain error as a fraction (0.001 for 0.1 percent, and 0 means nominal). swingHi and swingLo are how far the output stays from the supply and from ground at the stated load.

## Example

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

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