Skip to content

Commit 996c3c9

Browse files
author
neil.hamilton
committed
Add adc2mVpl1000 and mV2adcpl1000 functions to functions.py for the pl1000
1 parent a4a8448 commit 996c3c9

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

picosdk/functions.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ def adc2mV(bufferADC, range, maxADC):
2323
bufferV = [(x * vRange) / maxADC.value for x in bufferADC]
2424

2525
return bufferV
26+
27+
def adc2mVpl1000(bufferADC, range, maxADC):
28+
"""
29+
adc2mVpl1000(
30+
c_short_Array bufferADC,
31+
int range,
32+
c_int32 maxADC
33+
)
34+
35+
Takes a buffer of raw adc count values and converts it into millvolts
36+
"""
37+
38+
bufferV = [(x * range) / maxADC.value for x in bufferADC]
39+
40+
return bufferV
2641

2742
def mV2adc(millivolts, range, maxADC):
2843
"""
@@ -39,6 +54,18 @@ def mV2adc(millivolts, range, maxADC):
3954

4055
return adcValue
4156

57+
def mV2adcpl1000(millivolts, range, maxADC):
58+
"""
59+
mV2adc(
60+
float millivolts,
61+
int range,
62+
c_int32 maxADC
63+
)
64+
Takes a voltage value and converts it to adc counts
65+
"""
66+
adcValue = round((millivolts * maxADC.value)/range)
67+
68+
return adcValue
4269

4370

4471
def splitMSOData(dataLength, data):

0 commit comments

Comments
 (0)