Commit 1bf826b6 authored by Cyril Guilloud's avatar Cyril Guilloud

improvements on e753 controller

*code comments
*new config xml for NA
*move measured flag into read_postion canonical function
*added _get_target_pos()
parent a0e403c9
......@@ -8,6 +8,13 @@ import time
import pi_gcs
from bliss.comm import tcp
"""
Bliss controller for ethernet PI E753 piezo controller.
Closed-loop mode.
Cyril Guilloud ESRF BLISS January 2014
"""
class PI_E753(Controller):
def __init__(self, name, config, axes):
Controller.__init__(self, name, config, axes)
......@@ -24,18 +31,20 @@ class PI_E753(Controller):
# Init of each axis.
def initialize_axis(self, axis):
# Enables closed-loop
# Enables the closed-loop.
self.sock.write("SVO 1 1\n")
def read_position(self, axis, measured=False):
return self._get_pos(measured)
if measured:
_ans = self._get_pos()
else:
_ans = self._get_target_pos()
return _ans
def read_velocity(self, axis):
return self.axis_settings.get(axis, "velocity")
def read_state(self, axis):
if self._get_closed_loop_status():
if self._get_on_target_status():
......@@ -59,17 +68,27 @@ class PI_E753(Controller):
self.sock.write("STP\n")
'''
"""
E753 specific communication
'''
"""
def _get_pos(self):
'''
Returns real position read by capcitive captor.
'''
_ans = self.sock.write_readline("POS?\n")
def _get_pos(self, measured=False):
if measured:
_ans = self.sock.write_readline("POS?\n")
else:
_ans = self.sock.write_readline("MOV?\n")
# _ans should looks like "1=-8.45709419e+01\n"
# "\n" removed by tcp lib.
_pos = float(_ans[2:])
return _pos
def _get_target_pos(self):
'''
Returns last target position (setpoint value).
'''
_ans = self.sock.write_readline("MOV?\n")
# _ans should looks like "1=-8.45709419e+01\n"
# "\n" removed by tcp lib.
......@@ -112,28 +131,32 @@ class PI_E753(Controller):
def _set_velocity(self, velocity):
self.sock.write("VEL 1 %f\n"%velocity)
'''
Returns a set of usefull information about controller.
Can be helpful to tune the device.
'''
def _get_infos(self):
_infos = [
("identifier ", "IDN?\n"),
("com level ", "CCL?\n"),
("Identifier ", "IDN?\n"),
("Com level ", "CCL?\n"),
("Real Position ", "POS?\n"),
("Setpoint Position ", "MOV?\n"),
("Position low limit ", "SPA? 1 0x07000000\n"),
("Position High limit ", "SPA? 1 0x07000001\n"),
("Velocity ", "VEL?\n"),
("On target ", "ONT?\n"),
("target tolerance ", "SPA? 1 0X07000900\n"),
("Target tolerance ", "SPA? 1 0X07000900\n"),
("Settling time ", "SPA? 1 0X07000901\n"),
("Sensor Offset ", "SPA? 1 0x02000200\n"),
("Sensor Gain ", "SPA? 1 0x02000300\n"),
("Motion status ", "#5\n"),
("Closed loop status ", "SVO?\n"),
("Auto Zero Calibration ? ", "ATZ?\n"),
("Analog input setpoint ", "AOS?\n"),
("Low Voltage Limit ", "SPA? 1 0x07000A00\n"),
("High Voltage Limit ", "SPA? 1 0x07000A01\n")
]
self.sock.flush()
_txt = ""
for i in _infos:
......@@ -149,8 +172,5 @@ class PI_E753(Controller):
_txt = _txt + " %s \n%s\n"%("ADC value of analog input",
"\n".join(self.sock.write_readlines("TAD?\n", 2)))
return _txt
......@@ -59,7 +59,7 @@ if __name__ == '__main__':
'''
Interactive test :
NI Interactive test :
load_cfg_fromstring("""<config>
<controller class="PI_E753" name="testid16">
......@@ -77,4 +77,25 @@ print a.controller._get_infos()
'''
'''
NA Interactive test :
load_cfg_fromstring("""<config>
<controller class="PI_E753" name="testid16">
<host value="e753id16na-dmir"/>
<axis name="pz">
</axis>
</controller>
</config>
""")
a=get_axis("pz")
print a.controller.sock.write_readline("IDN?\n")
print a.controller._get_infos()
'''
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment