Commit 689cba91 authored by Jan Pospisil's avatar Jan Pospisil

added bunch-wise configuration possibility

parent 36aac099
......@@ -461,6 +461,9 @@ def Init(memoryPart = -1):
SetVcxoFrequency(-0.2105) # 125.0000 MHz
ClearMemory(0, '*', memoryPart)
# how much is RF clock faster than bunch clock
RF_2_BUNCH_RATIO = 5
# time 't' is in [ns] - same as other times
# output: (bit, delay)
# bit - position of the bit to set
......@@ -469,6 +472,9 @@ def CalculateParams(t):
rfPeriod = 4.99
delayOffset = 3.739
if (t < 0) or (t > RF_2_BUNCH_RATIO * rfPeriod):
raise Exception("Parameter t can be just in one bunch clock period!")
bit = int(t/rfPeriod) # bit position
rest = t - bit * rfPeriod # in ns
rest += delayOffset
......@@ -476,55 +482,37 @@ def CalculateParams(t):
return (bit, delay)
# delay and width (both in [ns]) of thi pulse within one bunch clock
# output: (setBit, resBit) - bit offset within one bunch clock
def SetPulseShape(channel, delay, width):
# calculate bitt shifts and delays
(setBit, setDelay) = CalculateParams(delay)
(resBit, resDelay) = CalculateParams(delay + width)
# set delays
WbWrite('ch'+str(channel)+'_delay_set', setDelay)
WbWrite('ch'+str(channel)+'_delay_res', resDelay+18)
# return bit shifts
return (setBit, resBit)
def TestPulse(channel = 1, overflow = 17820):
# configure channel
WbWrite('overflow', overflow)
WbWrite('trig_latency', 11)
# start = 5
# length = 20
# stop = start + length
# CreatePulse(channel, start + 2*channel, stop + 2*channel)
# start += 1
# CreatePulse(channel, start + 2*channel, stop + 2*channel)
# start += 1
# CreatePulse(channel, start + 2*channel, stop + 2*channel)
# start += 1
# CreatePulse(channel, start + 2*channel, stop + 2*channel)
# start += 1
# CreatePulse(channel, start + 2*channel, stop + 2*channel)
# CreatePulse(channel, 10, 20)
# CreatePulse(channel, 11, 21)
# CreatePulse(channel, 12, 22)
# CreatePulse(channel, 13, 23)
# CreatePulse(channel, 14, 24)
# CreatePulse(channel, 5, 10)
# CreatePulse(channel, 20, 50)
# CreatePulse(channel, 100, 300)
# all times in ns
pulseDelay = 4.87
pulseWidth = 12.3
(setBit, setDelay) = CalculateParams(pulseDelay)
(resBit, resDelay) = CalculateParams(pulseDelay + pulseWidth)
CreatePulse(channel, setBit, resBit)
WbWrite('trig_latency', 10)
WbWrite('ch'+str(channel)+'_delay_set', setDelay)
WbWrite('ch'+str(channel)+'_delay_res', resDelay+18)
pulseDelay = 0 # inter-bunch pulse delay in [ns]
pulseWidth = 12.5 # inter-bunch pulse width in [ns]
bunches = (0,1,2,10,50) # in which bunches pulse should be
(setBit, resBit) = SetPulseShape(channel, pulseDelay, pulseWidth)
for bunch in bunches:
CreatePulse(channel, (bunch * RF_2_BUNCH_RATIO)+setBit, (bunch * RF_2_BUNCH_RATIO)+resBit)
Enable(channel)
Start(channel)
# Init(15)
Init()
Control()
Status()
# TestPulse(1, 600)
TestPulse(1)
# TestPulse(2)
Control()
......
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