Commit 53efe384 authored by Yoann Sallaz Damaz's avatar Yoann Sallaz Damaz
Browse files

add bac24

parent def2a789
Pipeline #49244 failed with stages
from bliss.config import static as static_config
import serial
from time import sleep
# Following parameters cannot be done remotely
# FREQ: 0 (3.3Mhz)
# QUADR: 1 (quadrature signals used)
# SENS: 0 (counting direction)
# POLREF: 0 (reference signal polarity)
# POLIND: 0 (index signal polarity)
# RS: 1 (Addressed RS232 without echo)
# ADR: A (module address)
# NBOUT: 1 (number of output)
# POLOUT: 0 (output polarity)
# REFIND: 0 (index reset disabled)
class bac24(object):
def __init__(self, name, config, config_objects=None):
self._config_objects = config_objects
devport = config.get("serial")
self.verbose = config.get("verbose")
self.ser = serial.Serial(devport)
def send_and_read(self,cmd, nblines_to_read=1):
self.ser.write(cmd)
resp=""
for i in range(0,nblines_to_read):
sleep(0.2)
resp+=self.ser.readline().decode('utf-8')
if self.verbose:
print(resp)
return resp
def init(self):
verbose = True
# Set up the BAC24-I counter box
# set the display mode to 0, no visualisation - the fastest mode
self.display(0)
# set the encoder resolution in steps, 1 unit/step
self.send_and_read(b"$ARAZPLA;\r\n")
self.send_and_read(b"$ARES1.00;\r\n", 2)
# set the current position and the offset to 0
self.clearpos()
# set the keybord inactive
self.key(0)
# set the display decimal
self.send_and_read(b"$ADEC0;\r\n")
# reset of the internal alarm
# sends back two lines - 2 DevSerReadString
self.send_and_read(b"$ARAZAL;\r\n", 2)
sleep(1);
# flush the rest of the input buffer (if any)
self.ser.flush()
def zero(self):
print("bac24_zero()")
self.send_and_read(b"$APLA1,1,0,0;\r\n")
def ramp(self, start_pos, end_pos):
# Define the start_pos and end_pos for level 1 of output 1
#start_step = start_pos * 12800; # in encoder steps
#end_step = * 12800; # in encoder steps
start_step = -1*end_pos * 12800; # in encoder steps
end_step = -1*start_pos * 12800; # in encoder steps
print("bac24_ramp: start: %d, end: %d"%(start_step, end_step))
self.send_and_read(b"$APLA1,1,%d,%d;\r\n"%(start_step, end_step))
def alarm(self):
# Return the ALARM status
return self.send_and_read(b"$AALARME;\r\n")
def readpos(self):
# Read the position
return self.send_and_read(b"$APOS;\r\n")
def offset(self, val):
# Set the offset to val
self.send_and_read(b"$AOFF%f;\r\n"%val)
def clearpos(self):
# Set the position to 0
self.send_and_read(b"$ARAZPOS;\r\n")
def display(self, val):
# Enable (1) / disable (0) the display
self.send_and_read(b"$AMOD%d;\r\n"%val)
def key(self, val):
# Enable (1) / disable (0) the keyboard
self.send_and_read(b"$APAN%d;\r\n"%val)
def readramp(self):
# Read the actual ramp range (where the shutter is open)
return self.send_and_read(b"$ALIT1,1;\r\n")
Supports Markdown
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