From 38c3cbec0164ecdc6d20c4e9a6f8d920ccb5a510 Mon Sep 17 00:00:00 2001 From: tmacinc <64554516+tmacinc@users.noreply.github.com> Date: Mon, 21 Dec 2020 13:07:33 -0500 Subject: [PATCH 1/2] Update diol.py Added functions to return frequency directly --- maq20/modules/diol.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/maq20/modules/diol.py b/maq20/modules/diol.py index 1adaec7..ff45880 100644 --- a/maq20/modules/diol.py +++ b/maq20/modules/diol.py @@ -170,7 +170,12 @@ def read_special_function_1_pulse_frequency_counter(self, timer): "Internal Trigger : {0[10]}\n" \ "External Enable : {0[11]}\n" \ "External Enable Status: {0[12]}\n".format(response, pulse_count, frequency) - + + def read_special_function_1_pulse_frequency_counter_countonly(self, timer): + response = self.read_registers({0: 1100, 1: 1200}[timer], 13) + pulse_count = utils.int16_to_int32(response[4:6]) + return pulse_count + def write_special_function_2_pulse_frequency_counter_with_debounce(self, timer, internal_trigger=0, @@ -247,6 +252,12 @@ def read_special_function_2_pulse_frequency_counter_with_debounce(self, timer): "Low Time (x 100us) : {0[10]}\n" \ "High Time (x 100us) : {0[11]}\n".format(response, pulse_count, frequency) + def read_special_function_2_pulse_frequency_counter_with_debounce_frequency(self, timer): + response = self.read_registers({0: 1100, 1: 1200}[timer], 12) + pulse_count = utils.int16_to_int32(response[4:6]) + frequency = utils.int16_to_int32(response[6:8]) + return frequency + def write_special_function_3_waveform_measurement(self, timer, timebase=1, From 837a3d2815d2272884f84195608279e1d4ea35af Mon Sep 17 00:00:00 2001 From: tmacinc <64554516+tmacinc@users.noreply.github.com> Date: Mon, 21 Dec 2020 13:30:28 -0500 Subject: [PATCH 2/2] Update diol.py Changed return statements in read_special_function_1 and 2 to return dictionary instead of string. --- maq20/modules/diol.py | 57 +++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/maq20/modules/diol.py b/maq20/modules/diol.py index ff45880..f119261 100644 --- a/maq20/modules/diol.py +++ b/maq20/modules/diol.py @@ -159,23 +159,18 @@ def read_special_function_1_pulse_frequency_counter(self, timer): response = self.read_registers({0: 1100, 1: 1200}[timer], 13) pulse_count = utils.int16_to_int32(response[4:6]) frequency = utils.int16_to_int32(response[6:8]) - return "Function : 1 = Pulse/Frequency Counter\n" \ - "Arm/Disarm : {0[1]}\n" \ - "Function Status : {0[2]}\n" \ - "Alarm Status : {0[3]}\n" \ - "Pulse Count : {1}\n" \ - "Frequency : {2}\n" \ - "RPM : {0[8]}\n" \ - "Pulses Per Revolution : {0[9]}\n" \ - "Internal Trigger : {0[10]}\n" \ - "External Enable : {0[11]}\n" \ - "External Enable Status: {0[12]}\n".format(response, pulse_count, frequency) - - def read_special_function_1_pulse_frequency_counter_countonly(self, timer): - response = self.read_registers({0: 1100, 1: 1200}[timer], 13) - pulse_count = utils.int16_to_int32(response[4:6]) - return pulse_count - + return {"Function": "1 = Pulse/Frequency Counter".format(response, pulse_count, frequency), + "Arm/Disarm": "{0[1]}".format(response, pulse_count, frequency), + "Function Status": "{0[2]}".format(response, pulse_count, frequency), + "Alarm_Status": "{0[3]}".format(response, pulse_count, frequency), + "Pulse_Count": "{1}".format(response, pulse_count, frequency), + "Frequency": "{2}".format(response, pulse_count, frequency), + "RPM": "{0[8]}".format(response, pulse_count, frequency), + "Pulses Per Revolution": "{0[9]}".format(response, pulse_count, frequency), + "Internal Trigger": "{0[10]}".format(response, pulse_count, frequency), + "External Enable": "{0[11]}".format(response, pulse_count, frequency), + "External Enable Status": "{0[12]}".format(response, pulse_count, frequency)} + def write_special_function_2_pulse_frequency_counter_with_debounce(self, timer, internal_trigger=0, @@ -241,23 +236,17 @@ def read_special_function_2_pulse_frequency_counter_with_debounce(self, timer): response = self.read_registers({0: 1100, 1: 1200}[timer], 12) pulse_count = utils.int16_to_int32(response[4:6]) frequency = utils.int16_to_int32(response[6:8]) - return "Function : 2 = Pulse/Frequency Counter w/ Debounce\n" \ - "Arm/Disarm : {0[1]}\n" \ - "Function Status : {0[2]}\n" \ - "Alarm Status : {0[3]}\n" \ - "Pulse Count : {1}\n" \ - "Frequency : {2}\n" \ - "Internal Trigger : {0[8]}\n" \ - "Debounce Output Enable: {0[9]}\n" \ - "Low Time (x 100us) : {0[10]}\n" \ - "High Time (x 100us) : {0[11]}\n".format(response, pulse_count, frequency) - - def read_special_function_2_pulse_frequency_counter_with_debounce_frequency(self, timer): - response = self.read_registers({0: 1100, 1: 1200}[timer], 12) - pulse_count = utils.int16_to_int32(response[4:6]) - frequency = utils.int16_to_int32(response[6:8]) - return frequency - + return {"Function": "2 = Pulse/Frequency Counter w/ Debounce".format(response, pulse_count, frequency), + "Arm/Disarm": "{0[1]}".format(response, pulse_count, frequency), + "Function Status": "{0[2]}".format(response, pulse_count, frequency), + "Alarm Status": "{0[3]}".format(response, pulse_count, frequency), + "Pulse Count": "{1}".format(response, pulse_count, frequency), + "Frequency": "{2}".format(response, pulse_count, frequency), + "Internal Trigger": "{0[8]}".format(response, pulse_count, frequency), + "Debounce Output Enable": "{0[9]}".format(response, pulse_count, frequency), + "Low Time (x 100us)": "{0[10]}".format(response, pulse_count, frequency), + "High Time (x 100us)": "{0[11]}".format(response, pulse_count, frequency)} + def write_special_function_3_waveform_measurement(self, timer, timebase=1,