Skip to content

Commit 59b4485

Browse files
author
neil.hamilton
committed
Add adc2mVV2 and mV2adcV2 functions to functions.py for working with psospa functions
1 parent 9004c46 commit 59b4485

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
@@ -172,3 +172,30 @@ def assert_pico2000_ok(status):
172172
else:
173173
errorCheck = False
174174
raise PicoSDKCtypesError("Unsuccessful API call")
175+
176+
def mV2adcV2(millivolts, rangeMax, maxADC):
177+
"""
178+
mV2adcV2(
179+
float millivolts
180+
int rangeMax
181+
c_int32 maxADC
182+
)
183+
Takes a voltage value and converts it into adc counts for psospa driver scopes
184+
"""
185+
adcValue = round((millivolts * maxADC.value)/rangeMax)
186+
187+
return adcValue
188+
189+
def adc2mVV2(bufferADC, rangeMax, maxADC):
190+
"""
191+
adc2mVV2(
192+
c_short_Array bufferADC
193+
int rangeMax
194+
c_int32 maxADC
195+
)
196+
197+
Takes a buffer of raw adc count values and converts it into millivolts for psospa driver scopes
198+
"""
199+
bufferV = [(x * rangeMax) / maxADC.value for x in bufferADC]
200+
201+
return bufferV

0 commit comments

Comments
 (0)