I have an H-bridge circuit that is meant to measure the voltage across the shunt (330 resistor) and load (pictured as 4700, but variable) to calculate the resistance of the load (I have added the 10k to lower the voltage across the other two components). The H-bridge reverses the direction of the current every .01 seconds, and the transistors are activated by GPIO pins from a Raspberry Pi. I am measuring the voltage using an ADC differential Pi. (https://www.abelectronics.co.uk/p/65/adc-differential-pi) When measured the voltages across the shunt and the load are not in the same ratio between flips, e.g (0.070984375 V and 1.013546875 V in one direction and 0.0710781250000001 and 1.01421875 V in the other direction).

The voltages being different between different directions is not my issue, so much as the fact that the ratio between the voltages is inconsistent. The voltages in a given direction are consistent between handheld voltmeters and multiple ADC boards that are run using the Pi. I have tried changing the base resistors for all four transistors and changing the input voltage but nothing fixes the problem.

enter image description here

  • \$\begingroup\$ Did you match the transistors before measuring? \$\endgroup\$
    – user55924
    Commented Nov 25, 2023 at 21:30
  • \$\begingroup\$ At what point in the overall cycle (with reference to the alternation switch points) do you sample the signals and how many samples do you average? Or, is my question misunderstanding what your problem is (maybe be more explicit). \$\endgroup\$
    – Andy aka
    Commented Nov 25, 2023 at 22:15
  • 2
    \$\begingroup\$ Do us a favour and compute and post the ratios. Do yourself a favour and round off some of those spurious decimal places to leave an engineeringly appropriate number of significant figures on your voltage readings. Are those the settled readings, or do they change some more as you continue to read? \$\endgroup\$
    – Neil_UK
    Commented Nov 25, 2023 at 22:31
  • \$\begingroup\$ @user55924 I have matched the PNPs and NPNs (e.g. two 2N3904s) respectively by their product code. If I need to do something different could you advise? Thank you. \$\endgroup\$
    – TTSB
    Commented Nov 27, 2023 at 16:13
  • \$\begingroup\$ @Andyaka The circuit is run on Python, there is a while loop in which the transistors are activated by the GPIO pins, the readings are taking using the ADC and transistor are turned off. There is a flag in the while loop to activate each pair of transistors alternately. In other words the readings are taken as soon as possible after the transistors are turned on and there is no time delay in the loop. The sample rate is 3.75 SPS. \$\endgroup\$
    – TTSB
    Commented Nov 27, 2023 at 17:05

1 Answer 1


My hypothesis is that your transistors are slightly mismatched. The beta (hfe) on transistors can range between 30 and 400, which affects the effective emitter resistance.

I've simulated the scenario:

Modelling the beta mismatch as a small varying resistance R4 over Q2, we can see the difference in the plot of a few millivolts. Binning your transistors so that their beta and output resistance matches better might improve the situation. Larger current might also make things better, but you're limited by voltage here ofc.. .

unbalanced sim

  • \$\begingroup\$ I tried to measure the HFE values of the transistors using the Ic= HFE*Ib calculation and got fractional values for each of them (around 0.081). Don't know if that's because Vcc is too low. Should the transistors be in saturation or active to make the circuit work, and is that possible using only the Raspberry Pi. I have assumed that they should be in saturation. I have also measured a circuit that is just the three resistors using the ADC board and manually swapped the power and ground, and the difference in calculated resistance was the same. Does this mean the problem is the ADC \$\endgroup\$
    – TTSB
    Commented Nov 29, 2023 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.