Python examples
Connecting to the board
from ams_messages import *
from ams_module import AMSSerialModule
module = AMSSerialModule(port="COM1")
Temperature setting
module.workmode_stop()
module.set_detector_temperature(263)
module.save_config()
Waiting for temperature stabilization
module.wait_for_temperature_stabilization()
Signal measurement with mechanical chopper
module.workmode_stop()
module.processing_disable()
# By default AMS-DIG-PROC produces 7Msamples per second in 2048-samples buffers.
# This means that one single buffer takes approx. 0.3ms.
# The chopper has usually 1kHz (period: 1ms) and we would like to capture couple periods.
# Oversampling ratio can be calculated as 1ms / 0.3ms * N ~= 3*N
# We choose N=10 periods, so ratio will be set to 32.
module.processing_oversampling(0, 32, 2048)
module.processing_buffer_iir(1, 0.95) # Adjust second parameter. The closer to 1, the better (and slower) averaging.
module.workmode_trigger_input(samples_count=32*2048, delay=0)
module.flush_input() # To avoid reading old messages
while True:
msg = module.read_one_message(msgClasses=MessageOutputData)
if not msg:
continue
print(msg.voltages) # data contains all samples
Peak-peak measurements with mechanical chopper
module.workmode_stop()
module.processing_disable()
module.processing_oversampling(0, 32, 2048)
module.processing_buffer_iir(1, 0.95) # Adjust second parameter. The closer to 1, the better (and slower) averaging.
module.processing_peak_peak(2)
module.workmode_trigger_input(samples_count=32*2048, delay=0)
module.flush_input() # To avoid reading old messages
while True:
msg = module.read_one_message(msgClasses=MessageOutputData)
if not msg:
continue
print(msg.voltages[0])
Freerunning average voltage measurement with oversampling
module.workmode_stop()
module.processing_disable()
module.processing_oversampling(0, 2048, 2048)
module.processing_simple_average(1)
module.workmode_freerunning()
module.flush_input() # To avoid reading old messages
while True:
msg = module.read_one_message(msgClasses=MessageOutputData)
if not msg:
continue
print(msg.voltages[0])
Resetting the board
module.reset()
Clearing reset flag
module.clear_reset_flag()
Checking wheter the board has rebooted
module.flush_input() # To avoid reading old messages
while True:
msg = module.read_one_message(msgClasses=MessageStatus)
if msg:
break
print(msg.reset_flag)