Commit 12b7c021 authored by Jan Pospisil's avatar Jan Pospisil

relax bunch boundary check, fix continuous pulses (25 ns pulse in two subsequent…

relax bunch boundary check, fix continuous pulses (25 ns pulse in two subsequent bunches) -> constraint to the help
parent f71211b1
#!/usr/bin/env python
# coding: utf8
# TODO:
# - relax bunch boundary check, fix continuous pulses (25 ns puls in two subsequent bunches) -> constraint to the help
import sys
from Ffpg import *
......@@ -33,7 +30,7 @@ if len(sys.argv) is not 4 and len(sys.argv) < 7:
print " <fmcSlot (LUN)> - 0 | 1"
print " <channel> - 1 | 2"
print " <polarity> - 0 | 1"
print " <pulseWidth> - positive float number in [ns]"
print " <pulseWidth> - positive float number in [ns], has to be < LHC bunch period (25 ns)"
print " <pulseDelay> - non-negative float number in [ns]"
print " <triggerLatency> - non-negative float number in [ns], or -1 (calibration disabled)"
print " <bunches> - space separated list of bunch numbers, each 0-3563"
......
......@@ -366,10 +366,12 @@ class Ffpg(object):
clockPeriod = self.GetClockPeriod()
lhcBunchPeriod = 24.95
pulseStop = pulseDelay + pulseWidth
assert (pulseDelay >= 0) and (pulseDelay < lhcBunchPeriod), "Pulse starts out of the LHC bunch period!"
assert (pulseStop > pulseDelay) and (pulseStop <= lhcBunchPeriod), "Pulse stops out of the LHC bunch period!"
if (pulseWidth > lhcBunchPeriod):
warnings.warn("Pulse width cannot be > the LHC bunch period! LHC bunch period will be used for a pulse width.", stacklevel=2)
pulseWidth = lhcBunchPeriod
pulseStop = pulseDelay + pulseWidth
assert (pulseStop > pulseDelay), "Pulse starts after its end!"
if polarity == 0: # Swap `pulseDelay` and `pulseStop` for inverted mode
tmp = pulseDelay
......@@ -392,8 +394,18 @@ class Ffpg(object):
self.SetFineDelay(channel, "res", pulseStopFineDelay)
# configure pulse positions
for bunch in bunches:
self._ConfigurePulse(channel, (bunch * rfToBunchRatio)+pulseStartBit, (bunch * rfToBunchRatio)+pulseStopBit, 1)
if pulseWidth < lhcBunchPeriod:
# normal pulse configuration
for bunch in bunches:
self._ConfigurePulse(channel, (bunch * rfToBunchRatio)+pulseStartBit, (bunch * rfToBunchRatio)+pulseStopBit, 1)
else:
# special check for continuous pulses
for bunch in bunches:
print "Setting bunch "+str(bunch)
if (polarity == 1 and (bunch-1) not in bunches) or (polarity == 0 and (bunch+1) not in bunches):
self._ConfigurePulse(channel, (bunch * rfToBunchRatio)+pulseStartBit, (bunch * rfToBunchRatio)+pulseStopBit, 1, 1) # only one set bit
if (polarity == 1 and (bunch+1) not in bunches) or (polarity == 0 and (bunch-1) not in bunches):
self._ConfigurePulse(channel, (bunch * rfToBunchRatio)+pulseStartBit, (bunch * rfToBunchRatio)+pulseStopBit, 1, 2) # only one reset bit
# if there are no bunches configured, just maintain the right output level
if len(bunches) == 0:
......
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