import numpy as np import time from datetime import datetime import pandas as pd import os from serial import Serial import struct import commands_rev_b as commands # load the Python API for the Analog Devices CN0359 evaluation board # from automatedtesting.instruments.analog_devices_conductivity_board import AnalogDevicesConductivityBoard from modules.analog_devices_conductivity_board import AnalogDevicesConductivityBoard # create an instance of the CN0359 Eval Board cond1 = AnalogDevicesConductivityBoard() #cond1.create_connection('/dev/ttyUSB0', '30') cond1.create_connection('COM6', '30') print("connected") sleep_time = 1 # sleep time after executing a command (in seconds) # At startup the auto publish is one, so read the auto published data commands.read_autopoll(cond1, 30) time.sleep(sleep_time) # Stop auto publishing commands.cmd_stop_poll_bin(cond1) time.sleep(sleep_time) # Start auto publishing commands.cmd_start_poll_bin(cond1) time.sleep(sleep_time) # Read auto published data in binary format commands.read_autopoll(cond1, 30) time.sleep(sleep_time) # Stop auto publishing commands.cmd_stop_poll_bin(cond1) time.sleep(sleep_time) # Read raw data in ASCII format commands.cmd_tx_raw_poll(cond1) time.sleep(sleep_time) # Read Configuration settings in ASCII format commands.cmd_poll(cond1) time.sleep(sleep_time) # Update excitation voltage and read response in ASCII format commands.cmd_voltage(cond1, 0.4) time.sleep(sleep_time) # Update excitation frequency and read response in ASCII format commands.cmd_frequency(cond1,10.3) time.sleep(sleep_time) # Update setup time and read response in ASCII format commands.cmd_setuptime(cond1,0.3) time.sleep(sleep_time) # Update hold time and read response in ASCII format commands.cmd_holdtime(cond1,0.4) time.sleep(sleep_time) # Update temperature coefficient and read response in ASCII format commands.cmd_coefficient(cond1,5.2) time.sleep(sleep_time) # Update cell constant and read response in ASCII format commands.cmd_cellconstant(cond1,0.08) time.sleep(sleep_time) # Read Configuration settings in ASCII format to confirm the changes were made commands.cmd_poll(cond1) time.sleep(sleep_time) # Read Calibration data in ASCII format commands.cmd_get_cal_data(cond1) time.sleep(sleep_time) # Update Coefficient 1 and read response in ASCII format commands.cmd_setcal(cond1, 1, 3.1) time.sleep(sleep_time) # Update Coefficient 2 and read response in ASCII format commands.cmd_setcal(cond1, 2, 0.006) time.sleep(sleep_time) # Update Coefficient 3 and read response in ASCII format commands.cmd_setcal(cond1, 3, 0.6) time.sleep(sleep_time) # Update Coefficient 4 and read response in ASCII format commands.cmd_setcal(cond1, 4, -1.0) time.sleep(sleep_time) # Update Coefficient 5 and read response in ASCII format commands.cmd_setcal(cond1, 5, 3.1) time.sleep(sleep_time) # Update Coefficient 6 and read response in ASCII format commands.cmd_setcal(cond1, 6, 0.03) time.sleep(sleep_time) # Update Coefficient 7 and read response in ASCII format commands.cmd_setcal(cond1, 7, 2.0) time.sleep(sleep_time) # Update Coefficient 8 and read response in ASCII format commands.cmd_setcal(cond1, 8, 999.0) time.sleep(sleep_time) # Update Coefficient 9 and read response in ASCII format commands.cmd_setcal(cond1, 9, 1.5) time.sleep(sleep_time) # Update Coefficient 10 and read response in ASCII format commands.cmd_setcal(cond1, 10, 7.1) time.sleep(sleep_time) # Update Coefficient 11 and read response in ASCII format commands.cmd_setcal(cond1, 11, 100.11) time.sleep(sleep_time) # Update Coefficient 12 and read response in ASCII format commands.cmd_setcal(cond1, 12, 100.12) time.sleep(sleep_time) # Read Calibration data in ASCII format to confirm the changes were made commands.cmd_get_cal_data(cond1) time.sleep(sleep_time) # Read Version information in ASCII format commands.cmd_get_version(cond1) time.sleep(sleep_time) # Update Hardware Version Number and read response in ASCII format commands.cmd_set_hardware_ver(cond1) time.sleep(sleep_time) # Update Serial Number and read response in ASCII format commands.cmd_set_serial_num(cond1) time.sleep(sleep_time) # Read Version information in ASCII format to confirm the changes were made commands.cmd_get_version(cond1) time.sleep(sleep_time) # Read Calibration and Version information in binary format commands.cmd_get_cal_ver_bin(cond1) time.sleep(sleep_time)