MCPcopy Create free account
hub / github.com/LabPy/lantz / bitsToVolts

Method bitsToVolts

lantz/drivers/labjack/_internal/u12.py:2384–2406  ·  view source on GitHub ↗

Name: U12.bitsToVolts(chnum, chgain, bits) Args: See section 4.14 of the User's Guide Desc: Converts a 12-bit (0-4095) binary value into a LabJack voltage. No hardware communication is involved. >>> dev = U12() >>> dev.bitsToVolts(0, 0, 2662) >>> {'v

(self, chnum, chgain, bits)

Source from the content-addressed store, hash-verified

2382
2383 GainMapping = [ 1.0, 2.0, 4.0, 5.0, 8.0, 10.0, 16.0, 20.0 ]
2384 def bitsToVolts(self, chnum, chgain, bits):
2385 """
2386 Name: U12.bitsToVolts(chnum, chgain, bits)
2387 Args: See section 4.14 of the User's Guide
2388 Desc: Converts a 12-bit (0-4095) binary value into a LabJack voltage. No hardware communication is involved.
2389
2390 >>> dev = U12()
2391 >>> dev.bitsToVolts(0, 0, 2662)
2392 >>> {'volts': 2.998046875}
2393 """
2394 if ON_WINDOWS:
2395 volts = ctypes.c_float()
2396 ecode = staticLib.BitsToVolts(chnum, chgain, bits, ctypes.byref(volts))
2397
2398 if ecode != 0: print(ecode)
2399
2400 return volts.value
2401 else:
2402 if chnum < 8:
2403 return ( float(bits) * 20.0 / 4096.0 ) - 10.0
2404 else:
2405 volts = ( float(bits) * 40.0 / 4096.0 ) - 20.0
2406 return volts / self.GainMapping[chgain]
2407
2408 def voltsToBits(self, chnum, chgain, volts):
2409 """

Callers 2

rawAISampleMethod · 0.95
rawAIBurstMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected