Here is an example of a VFCADC used during fly measurements. This mode requires the stop/start sequence before the VFC is read, see (1). This way the VFCADC can measure its sample time. Notice that thereby the active time is increased by roughly 1%. But the ratio of the counter and the VFCADC reading is in the order of 1 per mille.
#!/usr/bin/env python3 from PyTango import * import sys import time try : c1 = DeviceProxy( "p09/counter/eh.01") dac1 = DeviceProxy( "p09/dac/eh.01") vfc1 = DeviceProxy( "p09/vfc/eh.01") t1 = DeviceProxy( "p09/dgg2/eh.01") # # set the DAC output # dac1.voltage = 1. # # Prepare the VFC. Gain, offset and polarity are memorized attributes. # After they have been set once the are automatically written to the # device when the server is initialized. # if vfc1.Gain != 1.0: vfc1.Gain = 1.0 vfc1.SetGain() if vfc1.Offset != 0.: vfc1.Offset = 0.0 vfc1.SetOffset() if vfc1.Polarity != 1: vfc1.Polarity = 1 vfc1.SetPolarity() # # reset the VFC # vfc1.Reset() # # start the timer # c1.Counts = 0 sampleTime = 0.1 t1.sampleTime = sampleTime t1.Start() for i in range( 10): vfc1.Reset() c1.Counts = 0 t1.start() while t1.state() != DevState.ON: time.sleep( 0.1) print( "Start-Stop: VFC, counts %g C1 %g" % ( vfc1.Counts, c1.Counts)) vfc1.reset() c1.Counts = 0 sampleTime = 1. t1.sampleTime = sampleTime t1.Start() startTime = time.time() offVFC1 = 0 offC1 = 0 sleepTime = 0.1 while (time.time() - startTime) < sampleTime: time.sleep( sleepTime) # (1) t1.stop() t1.start() vfc1Counts = vfc1.Counts c1Counts = c1.Counts print( "Fly: VFC, counts %g C1 %g, R %g" % ( (vfc1Counts - offVFC1)/sleepTime, c1Counts - offC1, (vfc1Counts - offVFC1)/sleepTime/(c1Counts - offC1))) offVFC1 = vfc1Counts offC1 = c1Counts except Exception as e: print( "Failed with exception !") print( repr( e))
The output:
Start-Stop: VFC, counts 9999 C1 99849 Start-Stop: VFC, counts 10006 C1 100000 Start-Stop: VFC, counts 10006.5 C1 100000 Start-Stop: VFC, counts 10006.5 C1 100000 Start-Stop: VFC, counts 10006.5 C1 99999 Start-Stop: VFC, counts 10006 C1 99999 Start-Stop: VFC, counts 10006 C1 100000 Start-Stop: VFC, counts 10006 C1 100000 Start-Stop: VFC, counts 10006 C1 99999 Start-Stop: VFC, counts 10006 C1 99999 Fly: VFC, counts 100540 C1 100951, R 0.995929 Fly: VFC, counts 101345 C1 101232, R 1.00112 Fly: VFC, counts 101300 C1 101250, R 1.00049 Fly: VFC, counts 100990 C1 100902, R 1.00087 Fly: VFC, counts 101005 C1 100944, R 1.0006 Fly: VFC, counts 101020 C1 100987, R 1.00033 Fly: VFC, counts 101040 C1 100925, R 1.00114 Fly: VFC, counts 100960 C1 100884, R 1.00075 Fly: VFC, counts 101220 C1 101182, R 1.00038 Fly: VFC, counts 101005 C1 100921, R 1.00083