Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5273

Automation, sensing and robotics • Re: Can't measure resistors

$
0
0
I've been trying to measure the supply voltage on this version of the circuit. I don't know if there's something wrong with how I'm measuring it or the calculations, but it still isn't working.

The measurements are:

Shunt resistance is 330 ohms.

Pin13
Supply Voltage: 3.268
Shunt Voltage: 0.238
Load Voltage: 3.030
Load Resistance: 4201

Pin15
Supply Voltage: 3.256
Shunt Voltage: 0.212
Load Voltage: 3.046
Load Resistance: 4738

Each side is consistent across repeated readings.


Code:

while True:
PiGPIO.output(23, PinSwitch)
PiGPIO.output(27, PinSwitch)
PiGPIO.output(24, not PinSwitch)
PiGPIO.output(22, not PinSwitch)

time.sleep(.5)
chan = AnalogIn(ads, ADS.P0)
chan2 = AnalogIn(ads, ADS.P1)
chan3 = AnalogIn(ads, ADS.P2)

if PinSwitch == True:

MaxVoltage1= chan3.voltage
loadVoltage1 = chan.voltage
shuntVoltage1 = MaxVoltage1 - loadVoltage1
loadRes1 = shunt * (loadVoltage1 / shuntVoltage1)
print("load res1", loadRes1, "MaxVoltage 1", MaxVoltage1, "LoadVoltage1", loadVoltage1, chan2.voltage)
print(" ")

else:

MaxVoltage2 = chan2.voltage
shuntVoltage2 = chan.voltage
loadVoltage2 = MaxVoltage2 - shuntVoltage2
loadRes2 = shunt*(loadVoltage2/ shuntVoltage2)
print("load res1", loadRes1, "MaxVoltage 1", MaxVoltage1, "LoadVoltage1", loadVoltage1, chan2.voltage)
print(" ")


I'm attaching a screenshot of a simulation. I can attach a photo of the real circuit if that would be more helpful.
Res Meter Circuit.png

Statistics: Posted by TTSB — Fri May 03, 2024 12:46 am



Viewing all articles
Browse latest Browse all 5273

Trending Articles