Commit 96dc00c3 authored by Jan Pospisil's avatar Jan Pospisil

added option for negative pulses

parent 9c53d4f4
......@@ -34,6 +34,7 @@
## 2016-08-24 1.0 Jan Pospisil
## 2016-09-01 1.1 Jan Pospisil added version numbers (major.minor.rev)
## added clock_stable status bit
## added option for negative pulses
##-----------------------------------------------------------------------------
# TODO: proper BUSY bits checking
......@@ -238,16 +239,17 @@ def ClearMemory(channel, memory, memoryPart = -1):
WbWriteMulti(address, (0,)*partToClear, to = to)
# channel: 1, 2, 0 (for both)
# pulse: 0, 1
# pulse: 0 - delete, 1 - create
# which: 0 - both, 1 - set, 2 - reset
def ConfigurePulse(channel, start, stop, pulse, which = 0):
# polarity: 0 - negative pulse, 1 - positive pulse
def ConfigurePulse(channel, start, stop, pulse, which = 0, polarity = 1):
if channel == 1:
address = 'ch1_'
elif channel == 2:
address = 'ch2_'
elif channel == 0:
ConfigurePulse(1, start, stop, pulse)
ConfigurePulse(2, start, stop, pulse)
ConfigurePulse(1, start, stop, pulse, which, polarity)
ConfigurePulse(2, start, stop, pulse, which, polarity)
return
else:
raise Exception("Bad channel!")
......@@ -261,6 +263,11 @@ def ConfigurePulse(channel, start, stop, pulse, which = 0):
pulse &= 1
if polarity == 0:
tmp = start
start = stop
stop = tmp
if which < 2:
position = start/32
shift = start%32
......@@ -271,8 +278,8 @@ def ConfigurePulse(channel, start, stop, pulse, which = 0):
shift = stop%32
WbSetBitsMulti(address+'res_mem', ((1<<shift),), ((pulse<<shift),), start=position, to=position+1)
def CreatePulse(channel, start, stop, which = 0):
ConfigurePulse(channel, start, stop, 1, which)
def CreatePulse(channel, start, stop, which = 0, polarity = 1):
ConfigurePulse(channel, start, stop, 1, which, polarity)
def DeletePulse(channel, start, stop):
ConfigurePulse(channel, start, stop, 0)
......@@ -484,7 +491,7 @@ def SetPulseShape(channel, delay, width):
# return bit shifts
return (setBit, resBit)
def TestPulse(channel = 1, overflow = 17820):
def TestPulse(channel = 1, overflow = 17820, polarity = 1):
# configure channel
WbWrite('overflow', overflow)
WbWrite('trig_latency', 12)
......@@ -497,7 +504,7 @@ def TestPulse(channel = 1, overflow = 17820):
(setBit, resBit) = SetPulseShape(channel, pulseDelay, pulseWidth)
for bunch in bunches:
CreatePulse(channel, (bunch * RF_2_BUNCH_RATIO)+setBit, (bunch * RF_2_BUNCH_RATIO)+resBit)
CreatePulse(channel, (bunch * RF_2_BUNCH_RATIO)+setBit, (bunch * RF_2_BUNCH_RATIO)+resBit, polarity = polarity)
Enable(channel)
Start(channel)
......@@ -505,10 +512,11 @@ def TestPulse(channel = 1, overflow = 17820):
Init()
Control()
Status()
TestPulse(1)
TestPulse(1, polarity = 0)
# TestPulse(2)
Control()
Status()
Version()
Debug()
......
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