Commit ec8069e1 authored by Jan Pospisil's avatar Jan Pospisil

added calibration example code and GetFmcSlot and LED test methods

parent b0c7b8f7
......@@ -47,11 +47,23 @@
## convert to OOP
## divided into more files
## simplified interface
## 2016-09-21 1.5 Jan Pospisil added calibration example code
##-----------------------------------------------------------------------------
from Ffpg import *
# triggerPhase = 53.76 # same for both channels in the test setup
calibrationData = [ # -1 = uncalibrated
# channel 1, channel 2
[51.29, 51.03], # FMC slot 0
[51.29, 51.11] # FMC slot 1
]
fmcSlot = 1 # 0 | 1
channel = 2 # 1 | 2
def Init(pg):
global calibrationData
pg.Reset()
pg.SelectClock("external", 400.789)
pg.SetRatio(2)
......@@ -59,14 +71,19 @@ def Init(pg):
pg.Ad9512Sync()
pg.SetTriggerThreshold(0.5)
pg.SetVcxoFrequency(-0.2105) # 125.0000 MHz
triggerPhase = 53.76 # same for both channels in the test setup
triggerPhase = 0
pg.SetTriggerPhase(1, triggerPhase)
pg.SetTriggerPhase(2, triggerPhase)
# calibration
fmcSlot = pg.GetFmcSlot()
for channel in [1,2]:
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)
else:
print(" (Skipping this calibration, no calibration data (-1) provided.)")
def TestSinglePulse(pg, channel):
pg.ResetBadState(channel)
pg.CreateSinglePulse(channel, start = 10, width = 50, polarity = 1)
pg.CreateSinglePulse(channel, start = 0, width = 50, polarity = 1)
pg.EnableChannel(channel)
pg.StartChannel(channel)
......@@ -88,7 +105,7 @@ def PrintFrequency(pg):
print("RF clock frequency: (unstable)")
# create FFPG driver for FMC slot
pg = Ffpg(fmcSlot = 0)
pg = Ffpg(fmcSlot)
# activate low-level debug output
# pg.wb.SetDebug(True)
......@@ -100,13 +117,13 @@ pg = Ffpg(fmcSlot = 0)
Init(pg)
# create single pulse
TestSinglePulse(pg, channel = 1)
TestSinglePulse(pg, channel)
# create bunched pulses
# TestBunchPulses(pg, channel = 1)
# TestBunchPulses(pg, channel)
# stop and disable channel
# StopAndDisable(pg, channel = 1)
# StopAndDisable(pg, channel)
# print some info
pg.PrintVersion()
......
......@@ -30,6 +30,7 @@
## Date Version Author Comment
## 2016-09-06 1.0 Jan Pospisil Derived from the initial example driver
## 2016-09-07 1.1 Jan Pospisil added AD9512 OUT4 fine delay
## 2016-09-21 1.2 Jan Pospisil added GetFmcSlot and LED test methods
##-----------------------------------------------------------------------------
import time
......@@ -45,14 +46,19 @@ class Ffpg(object):
inputClockFrequency = None # frequency (in MHz) of the selected clock
fineTriggerPhase = {1: 0, 2: 0} # individual for each channel, in [ns]
temp = None # DS18B20 OneWire temperature chip
fmcSlot = None
def __init__(self, fmcSlot):
""" fmcSlot = 0 | 1 """
assert (fmcSlot&1) == fmcSlot, "fmcSlot can be just 0 or 1!"
self.fmcSlot = fmcSlot
self.wb = WbOverlay("fmc_fpg", fmcSlot)
self.temp = DS18B20(wbOverlay = self.wb)
assert self.CompareVersion(1, 2, 0) == 0, "Bad gateware version detected! Get the appropriate driver from http://www.ohwr.org/projects/fmc-del-1ns-2cha/repository/revisions/master/show/sw"
def GetFmcSlot(self):
return self.fmcSlot
def GetVersion(self):
version = self.wb.Read("version")
major = (version >> 22) & ((2**10)-1)
......@@ -119,7 +125,7 @@ class Ffpg(object):
def Ad9512Sync(self):
""" synchronize AD9512 dividers """
self.wb.SetBits("control", 0x200)
self.wb.SetBits("control", 1<<9)
def SetTriggerThreshold(self, voltage):
""" voltage in [V] """
......@@ -403,3 +409,9 @@ class Ffpg(object):
def DisableClockFineDelay(self):
self.wb.SetBits("control", (1<<10), 0)
def LedModeTest(self):
self.wb.SetBits("control", (1<<8))
def LedModeNormal(self):
self.wb.SetBits("control", (1<<8), 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