Commit 8672b76f authored by Jan Pospisil's avatar Jan Pospisil

triggerLatency as an argument

parent 8bf37ab4
#!/usr/bin/env python
# coding: utf8
# TODO:
# - floats in arguments
# - bunch assert (0-3563)
# - when no bunches are provided, stay in high/low according to polarity
# - fixed sub-bunch period, just check (warning) against "real" input frequency
# - relax bunch boundary check, fix continuous pulses (25 ns puls in two subsequent bunches) -> constraint to the help
import sys
from Ffpg import *
def myInt(s):
if s.isdigit():
try:
return int(s)
else:
except:
return None
calibrationData = [ # -1 = uncalibrated
# channel 1, channel 2
[-1, -1], # FMC slot 0
[-1, -1] # FMC slot 1
]
print("FFPG command line interface")
print("")
if len(sys.argv) is not 4 and len(sys.argv) < 7:
if len(sys.argv) is not 4 and len(sys.argv) < 8:
print "Usage:"
print " "+sys.argv[0]+" <fmcSlot (LUN)> <channel> <polarity> <pulseWidth> <pulseDelay> <bunches>"
print " "+sys.argv[0]+" <fmcSlot (LUN)> <channel> <polarity> <pulseWidth> <pulseDelay> <triggerLatency> <bunches>"
print " Sets and starts selected channel on selected FMC mezzanine"
print " or"
print " "+sys.argv[0]+" <fmcSlot (LUN)> <channel> stop"
......@@ -31,7 +32,8 @@ if len(sys.argv) is not 4 and len(sys.argv) < 7:
print " <channel> - 1 | 2"
print " <polarity> - 0 | 1"
print " <pulseWidth> - positive number in [ns]"
print " <pulseDelay> - nonegative number in [ns]"
print " <pulseDelay> - non-negative number in [ns]"
print " <triggerLatency> - non-negative number in [ns], or -1 (calibration disabled)"
print " <bunches> - space separated list of bunch numbers"
print ""
sys.exit()
......@@ -44,8 +46,9 @@ else:
polarity = myInt(sys.argv[3])
pulseWidth = myInt(sys.argv[4])
pulseDelay = myInt(sys.argv[5])
triggerLatency = myInt(sys.argv[6])
bunches = []
for i in range(6, len(sys.argv)):
for i in range(7, len(sys.argv)):
bunches.append(myInt(sys.argv[i]))
print("Configuration:")
......@@ -60,6 +63,7 @@ else:
print(" polarity = "+str(polarity)+" (negative pulses)")
print(" pulseWidth = "+str(pulseWidth)+" ns")
print(" pulseDelay = "+str(pulseDelay)+" ns")
print(" triggerLatency = "+str(triggerLatency)+" ns")
print(" bunches = "+str(bunches))
print("")
......@@ -74,7 +78,8 @@ if polarity != "stop":
raise Exception("pulseWidth has to be > 0 ns!");
if pulseDelay < 0:
raise Exception("pulseDelay has to be >= 0 ns!");
# TODO: assert for bunches?
if triggerLatency < 0 and triggerLatency != -1:
raise Exception("triggerLatency has to be >= 0 ns or -1!");
def PrintFrequency(pg):
frequency = pg.GetFrequency()
......@@ -109,10 +114,9 @@ pg.Ad9512Sync()
pg.SetTriggerThreshold(0.5)
pg.SetVcxoFrequency(-0.2105) # 125.0000 MHz
# calibration
triggerPhase = calibrationData[fmcSlot][channel-1]
print("Calibrating channel "+str(channel)+" on FMC slot "+str(fmcSlot)+" to "+str(triggerPhase)+" ns")
if triggerPhase > -1:
pg.SetTriggerPhase(channel, triggerPhase)
print("Calibrating channel "+str(channel)+" on FMC slot "+str(fmcSlot)+" to "+str(triggerLatency)+" ns")
if triggerLatency > -1:
pg.SetTriggerPhase(channel, triggerLatency)
else:
print(" (Skipping this calibration, no calibration data (-1) provided.)")
......@@ -125,7 +129,7 @@ pg.StartChannel(channel)
# print some info
pg.PrintVersion()
# print("Actual temperature: "+str(pg.temp.ReadTemperature()) + " °C")
print("Actual temperature: (temparature read-out disabled - it is too slow)")
print("Actual temperature: (temperature read-out disabled - it is too slow)")
PrintFrequency(pg)
pg.PrintControl()
pg.PrintStatus()
......
......@@ -378,7 +378,7 @@ class Ffpg(object):
# calculate pulse shape inside the bunch
rfToBunchRatio = int(round(lhcBunchPeriod / clockPeriod))
if rfToBunchRatio != 5:
warnings.warn("rfToBunchRatio is not 5 - it should be in the 'normal' setup!", stacklevel=2)
warnings.warn("rfToBunchRatio is not 5 - it should be, in the 'normal' setup!", stacklevel=2)
pulseStartBit = int(pulseDelay/clockPeriod)
pulseStartFineDelay = pulseDelay - pulseStartBit * clockPeriod
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment