Helpers¶
Here’s some utility functions used to simplify the TRGen Device interaction
Reset TrgenPort¶
In order to reset a specific TrgenPort program, the following static functions can be used:
resetTrgenPort(trgenport)resetAllTrgenPorts()
bnco = TrgenPort(TrgenPin.BNCO)
client.resetTrgenPort(bnco) # reset just bnco
# it basically does
# bnco.setInstruction(0, istrEnd())
# for i in range(1, 31):
# bnco.setInstruction(i,istrNotAdmissible())
client.resetAllTrgenPorts() # reset all TrgenPorts
Set Default Duration¶
In this and this section is explained how to send a default trigger to BNCO or multiple TrgenPorts
Default duration is 20µs, but it can be changed using setDefaultDuration(duration_us) like this:
client.setDefaultDuration(100)
client.sendTrigger() # now this default trigger lasts 100µs
Get Default Duration¶
To get standard new duration use getDefaultDuration() like this:
new_duration = client.getDefaultDuration() # returns an int value
Get Implementation¶
The TRGenDevice has its own “settings” stored into the impl object defined by class TrgenImplementation.
impl is a TrgenClient property and can be reached invoking the static function getImplementation() like this:
client = TrgenClient()
impl = client.getImplementation()
TrgenImplementation contains informations about:
TRGen Cardinality¶
Its a bunch of properties describing the maximum number of TrgenPort by type:
ns_num(8)sa_num(8)bnco_num(1)bnci_num(1)gpio_num(8)
Max TRGen Memory Length (mtml)¶
Each TrgenPort can support a list of N instructions, where N = 2^MTML (Max TrgenPort Memory Length).
the Memory Length is a “magic number” hardcoded inside the triggerbox firmware. In the current versions is 5
You can access to the mtml value by
# Add this in try block to manage errors
try:
impl = client.getImplementation()
mtml = impl.mtml
except InvalidAckError as e:
print(f"⚠️ ACK sbagliato: {e}")
except AckFormatError as e:
print(f"⚠️ ACK malformato: {e}")
except TimeoutError as e:
print(f"⏱️ Timeout: {e}")
Memory Length¶
memory_length is the max number of instructions per TrgenPort, that is 2^mtml.