forked from harvie256/MaynuoPy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIV_test_script.py
45 lines (38 loc) · 1.25 KB
/
IV_test_script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#-------------------------------------------------------------------------------
# Name: IV tracking test script for Maynuo eload
# Purpose:
#
# Author: Derryn Harvie
#
# Created: 16/04/2014
# Licence: Public Domain
#-------------------------------------------------------------------------------
import Maynuo, time, sys
def main():
startCurrent = 0.0
stopCurrent = 4.6
stepCurrent = 0.01
stepDelayTime = 0.5
testCurrent = startCurrent
load = Maynuo.Maynuo(19,57600,1)
load.setCCurrent(testCurrent)
load.setInputOn()
time.sleep(stepDelayTime)
print('System Test')
print('Time (ms), Voltage (V), Current (A)')
while(1):
# get the operating point and write out
opPoint = load.getOperatingPoint()
sys.stdout.write(str(int(round(time.time() * 1000))) + ', ')
sys.stdout.write("{0:.4f}".format(opPoint.getVoltage()) + ', ')
print("{0:.4f}".format(opPoint.getCurrent()))
# step the current and test for ending
testCurrent += stepCurrent
if(testCurrent > stopCurrent):
break
load.setCCurrent(testCurrent)
time.sleep(stepDelayTime)
load.setInputOff()
print('IV sweep complete')
if __name__ == '__main__':
main()