change ea_control to remote and add rudimentary processing

This commit is contained in:
acereca 2018-04-09 19:26:57 +02:00
parent 9558602d9c
commit d01cd5d9f7
3 changed files with 16 additions and 60 deletions

View File

@ -1,60 +0,0 @@
from labcontrol.ea import EA_PS8080
from labcontrol.ea import EA_EL9080
from labcontrol.ea import EA_interface
import time
def identify(devlist):
for dev in devlist:
devid = EA_interface(dev).write(12, 0, [])
if devid[1] == []:
devid = EA_interface(dev).write(15, 0, [])
devtype = "el"
else:
devtype = "ps"
outdict[devtype] = {"id":devid, "address":dev, "type":devtype}
return outdict
def init(tree):
for dev, dat in tree:
if dat['type'] == "el":
devobj = EA_EL9080(dev)
else:
devobj = EA_PS8080(dev)
tree[dev]['dev'] = devobj
tree[dev]['dev'].remote(True)
def deinit(tree):
for dev, dat intree:
tree[dev]['dev'].remote(False)
tree[dev]['dev'].close()
starttime = time.time()
devicetree = identify(["/dev/ttyUSB0","/dev/ttyUSB1"])
init(devicetree)
devicetree['ps']['dev'].set_current(0)
devicetree['ps']['dev'].set_voltage(48)
devicetree['ps']['dev'].output(True)
log_str = "{time},{set_vals},{actual_ps},{actual_el}\n"
for i in range(0, 10, 2):
log += log_str
log.format(
time=time.time()-starttime,
set_vals={'i':i, 'v':48.0},
actual_ps=devicetree['ps']['dev'].get_actual_values(),
actual_el=devicetree['el']['dev'].get_actual_values()
)
with open('./log.csv', 'w') as f:
f.write(log)
devicetree['ps']['dev'].output(False)
deinit(devicetree)

1
data/ea_control.py Symbolic link
View File

@ -0,0 +1 @@
/remote_media/m03/home/pi/ea_control.py

1
data/log.csv Symbolic link
View File

@ -0,0 +1 @@
/remote_media/m03/home/pi/log.csv
1 /remote_media/m03/home/pi/log.csv

View File

@ -1 +1,15 @@
#! /usr/bin/python3 #! /usr/bin/python3
import pandas as pd
import matplotlib.pyplot as plt
plt.style.use('bmh')
data = pd.read_csv("log.csv")
print(data)
plt.errorbar(data['time'],data['act_curr_ps'], yerr=data['act_curr_ps']*.002, fmt='.')
plt.errorbar(data['time'],data['act_curr_el'], yerr=data['act_curr_el']*.002, fmt='.')
plt.ylabel('I/A')
plt.xlabel('t/s')
plt.show()