From bb6cf9caa194debf4d30ca48c4d5e445d4ddcfc6 Mon Sep 17 00:00:00 2001 From: Paul Neves Date: Tue, 2 Jul 2024 15:54:25 +0200 Subject: [PATCH] Updated the ACM1219 driver --- cfg/razorbillUC220T_cfg.py | 20 ++++++++++++++++++- frappy_psi/ACM1219.py | 39 +++++++++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/cfg/razorbillUC220T_cfg.py b/cfg/razorbillUC220T_cfg.py index f8b792c..b650b73 100644 --- a/cfg/razorbillUC220T_cfg.py +++ b/cfg/razorbillUC220T_cfg.py @@ -33,7 +33,7 @@ Mod('V2', Mod('io2', 'frappy_psi.ACM1219.ACM1219IO', 'communication', - uri='serial:///dev/tty.usbserial-A700fmAI?baudrate=9600+bytesize=8+parity=none+stopbits=1') + uri='serial:///dev/tty.usbserial-A904TGR7?baudrate=9600+bytesize=8+parity=none+stopbits=1') Mod('C1C2', 'frappy_psi.ACM1219.BothChannels', 'Capacitance channels 1 and 2', @@ -58,6 +58,24 @@ Mod('F', Cp=0.0755, f0_curve={'a':38.9,'b':-0.0147,'c':-0.000346,'d':8.96e-7,'e':-1.58e-9}, temp='T') +Mod('stress', + 'frappy_psi.ACM1219.Stress', + 'Sample stress from force', + force='F', + area=0.1, + ) +Mod('strain', + 'frappy_psi.ACM1219.Strain', + 'Sample strain from force', + displacement='d', + L=3, + ) +Mod('YM', + 'frappy_psi.ACM1219.YoungsModulus', + 'Sample youngs modulus from stress and strain', + stress='stress', + strain='strain', + ) Mod('T', 'frappy_psi.dummy.Temp', diff --git a/frappy_psi/ACM1219.py b/frappy_psi/ACM1219.py index 4a49129..3d59a12 100644 --- a/frappy_psi/ACM1219.py +++ b/frappy_psi/ACM1219.py @@ -23,7 +23,7 @@ from frappy.core import Readable, Parameter, FloatRange, HasIO, StringIO, Proper class ACM1219IO(StringIO): """communication with ACM1219""" - end_of_line = '\n' + end_of_line = ('\r\n', '\r') # ('\n', '\r') ('\r\n', '\r') wait_before = 0.05 identification = [('*IDN?', r'.*')] @@ -150,6 +150,43 @@ class Force(Readable): force = alpha / (cap - self.Cp) - self.f0 - f0_T return force + + +class Stress(Readable): + + # attached classes for displacement + force = Attached() + + # modifying a property of inherited parameters (unit is propagated to the FloatRange datatype) + value = Parameter('stress', FloatRange(None, None, unit='GPa'), readonly=True) + area = Parameter('cross sectional area of sample in mm^2', FloatRange(None, None, unit='mm^2'), readonly=False) + + def read_value(self): + return self.force.value / self.area / 1000 +class Strain(Readable): + + # attached classes for displacement + displacement = Attached() + + # modifying a property of inherited parameters (unit is propagated to the FloatRange datatype) + value = Parameter('strain', FloatRange(None, None, unit='m/m'), readonly=True) + L = Parameter('length of sample in mm', FloatRange(None, None, unit='mm'), readonly=False) + + def read_value(self): + return self.displacement.value / (1000*self.L) + + +class YoungsModulus(Readable): + + # attached classes for displacement + stress = Attached() + strain = Attached() + + # modifying a property of inherited parameters (unit is propagated to the FloatRange datatype) + value = Parameter('Young\'s modulus', FloatRange(None, None, unit='GPa'), readonly=True) + + def read_value(self): + return self.stress.value / self.strain.value \ No newline at end of file