import time 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) # Set Coefficients value 1..12 in order for idx, value in enumerate(commands.exp_coeff, start=1): # Update coefficient idx and read response in ASCII format commands.cmd_setcal(cond1, idx, value) 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, commands.exp_hw_ver) time.sleep(sleep_time) # Update Serial Number and read response in ASCII format commands.cmd_set_serial_num(cond1, commands.exp_sn) 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) ######################################################################################################################## # Below code is for data analysis # commands.cmd_stop_poll_bin(cond1) # time.sleep(sleep_time) # commands.cmd_frequency(cond1,10000.0) # time.sleep(sleep_time) # commands.cmd_poll(cond1) # time.sleep(sleep_time) # # # Reading Auto polled data for different durations # read_durations = [30, 60, 120, 240, 480] # for read_duration in read_durations: # print("Read Duration:", read_duration) # commands.cmd_start_poll_bin(cond1) # time.sleep(sleep_time) # commands.printTimestamp() # commands.read_autopoll(cond1, read_duration) # commands.printTimestamp() # time.sleep(sleep_time) # commands.cmd_stop_poll_bin(cond1) # time.sleep(sleep_time)