From a2a243421d08507916490ac881341151eebaf0e6 Mon Sep 17 00:00:00 2001 From: Sharanya Samanta Date: Thu, 17 Sep 2026 02:32:46 +0530 Subject: [PATCH] Improve wheatstone docs (#14275) * docs: Add circuit diagram and improve Wheatstone bridge documentation * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix docstring in wheatstone_solver function Corrected docstring formatting in wheatstone_solver function. * Add reference link for Wheatstone bridge Added a comment to reference the Wheatstone bridge Wikipedia page. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Christian Clauss --- electronics/wheatstone_bridge.py | 43 ++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/electronics/wheatstone_bridge.py b/electronics/wheatstone_bridge.py index edf0a3488..42107be98 100644 --- a/electronics/wheatstone_bridge.py +++ b/electronics/wheatstone_bridge.py @@ -1,27 +1,50 @@ -# https://en.wikipedia.org/wiki/Wheatstone_bridge +# ruff: noqa: RUF002 -- ambiguous-unicode-character-docstring from __future__ import annotations def wheatstone_solver( resistance_1: float, resistance_2: float, resistance_3: float ) -> float: - """ + r""" + Calculate the unknown resistance (Rx) in a Wheatstone bridge circuit. + Wheatstone Bridge is an electrical circuit used to accurately measure an unknown resistance by balancing two legs of a bridge circuit. - The bridge is said to be balanced when no current flows - through the galvanometer connected between the midpoints - of the two voltage dividers. - Balance condition: - R1 / R2 = R3 / R4 + This function calculates Rx when the three other resistances in the + bridge are known. The bridge is said to be balanced when no current + flows through the galvanometer connected between the midpoints of the + two voltage dividers. + * # https://en.wikipedia.org/wiki/Wheatstone_bridge + + Circuit Diagram: + + R1 R2 + +--/\/\/--+--/\/\/--+ + | | | + Vin Vg Vout + | | | + +--/\/\/--+--/\/\/--+ + R3 Rx + + Balance condition: + R1 / R2 = R3 / R4 + + This solver uses the balanced bridge formula: + Rx = (R2/R1) × R3 + + Args: + resistance_1 (R1): First known resistance + resistance_2 (R2): Second known resistance + resistance_3 (R3): Third known resistance + + Returns: + float: The calculated unknown resistance (Rx) Applications: - Measurement of unknown resistance - Strain gauge circuits - Sensor calibration - This function can calculate the unknown resistance in a Wheatstone - network, given that the three other resistances - in the network are known. Usage examples: >>> wheatstone_solver(resistance_1=2, resistance_2=4, resistance_3=5)