Commit 857483c0 authored by Jan Pospisil's avatar Jan Pospisil

added test script; reformatted Ffpg class (added comments)

parent 6e97c2da
......@@ -31,7 +31,7 @@ The "!->" determines what to check further when check fails.
1) Plug FMC mezzanine into SVEC carrier board and into VME crate (and configure properly)
2) When using FMC mezzanine version 2 (EDA-03339-V2), check that all power LEDs (LD1, LD2, LD3) are on (!-> SVEC fuses, power supplies)
3) Connect clock (CLK IN) f_CLK = 400.789 MHz and trigger (TRIG IN) f_TRIG = 11.245 kHz - trigger has to be phase aligned with clock
4) Use /sw/FFPG_driver.py to configure the GW and run some test
4) Use /sw/FFPG_driver.py or /sw/FFPG_test.py to configure the GW and run some test
5) Check:
a) There is f_CLK/2 clock present on CLK OUT (!-> AD9512 divider)
b) LED CLK IN is on (!-> clock source is not stable?)
......
#!/usr/bin/env python
# coding: utf8
##-----------------------------------------------------------------------------
## Title : Test Script
## Project : FMC DEL 1ns 2cha (FFPG)
## URL : http://www.ohwr.org/projects/fmc-del-1ns-2cha
##-----------------------------------------------------------------------------
## File : FFPG_test.py
## Author(s) : Jan Pospisil <j.pospisil@cern.ch>
## Company : CERN (BE-BI-QP)
## Created : 2017-09-14
## Last update: 2017-09-14
## Standard : Python
##-----------------------------------------------------------------------------
## Description: Script for testing new boards
##-----------------------------------------------------------------------------
## Copyright (c) 2017 CERN (BE-BI-QP)
##-----------------------------------------------------------------------------
## GNU LESSER GENERAL PUBLIC LICENSE
##-----------------------------------------------------------------------------
## This source file is free software; you can redistribute it and/or modify it
## under the terms of the GNU Lesser General Public License as published by the
## Free Software Foundation; either version 2.1 of the License, or (at your
## option) any later version. This source is distributed in the hope that it
## will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
## See the GNU Lesser General Public License for more details. You should have
## received a copy of the GNU Lesser General Public License along with this
## source; if not, download it from http://www.gnu.org/licenses/lgpl-2.1.html
##-----------------------------------------------------------------------------
## Revisions :
## Date Version Author Comment
## 2017-09-14 1.0 Jan Pospisil Created (based on FFPG_driver)
##-----------------------------------------------------------------------------
import time
import sys
from Ffpg import *
calibrationData = [ # -1 = uncalibrated
# channel 1, channel 2
[-1, -1], # FMC slot 0
[-1, -1] # FMC slot 1
]
def Init(pg):
global calibrationData
pg.Reset()
pg.SelectClock("external", 400.789)
pg.SetRatio(2)
pg.SetOverflow(17820)
pg.Ad9512Sync()
pg.SetTriggerThreshold(0.5)
pg.SetVcxoFrequency(-0.2105) # 125.0000 MHz
# 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, start, width, polarity):
pg.ResetBadState(channel)
pg.CreateSinglePulse(channel, start, width, polarity)
pg.EnableChannel(channel)
pg.StartChannel(channel)
def StopAndDisable(pg, channel):
pg.StopChannel(channel)
pg.DisableChannel(channel)
def PrintFrequency(pg):
frequency = pg.GetFrequency()
if frequency is not None:
print("RF clock frequency: "+str(frequency/1.0e6) + " MHz")
else:
print("RF clock frequency: (unstable)")
def StrPolarity(polarity):
if polarity == 1:
return "positive polarity"
elif polarity == 0:
return "negative polarity"
else:
return "unknown polarity"
while True:
fmcSlot = -1
while (fmcSlot < 0) or (fmcSlot > 1):
try:
fmcSlot = int(raw_input("Enter FMC slot to test (0 - lower FMC1, 1 - upper FMC2): "))
except KeyboardInterrupt:
print ""
sys.exit()
except:
fmcSlot = -1
channel = -1
while (channel < 1) or (channel > 2):
try:
channel = int(raw_input("Enter channel number to test (1, 2): "))
except KeyboardInterrupt:
print ""
sys.exit()
except:
channel = -1
# create FFPG driver for FMC slot
pg = Ffpg(fmcSlot)
# initialize the driver
Init(pg)
# test LEDs
pg.LedModeTest()
raw_input("All LEDs should be blinking... (press Enter)")
pg.LedModeNormal()
# test pulses
start = 10
width = 10
polarity = 1
TestSinglePulse(pg, channel, start, width, polarity)
raw_input("Basic pulse generated (start = "+str(start)+" ns, width = "+str(width)+" ns, "+StrPolarity(polarity)+") (press Enter)")
for start in range (10, 13+1):
TestSinglePulse(pg, channel, start, width, polarity)
raw_input("Shifting start of the pulse (start = "+str(start)+" ns, width = "+str(width)+" ns, "+StrPolarity(polarity)+") (press Enter)")
for width in range (10, 13+1):
TestSinglePulse(pg, channel, start, width, polarity)
raw_input("Shifting width of the pulse (start = "+str(start)+" ns, width = "+str(width)+" ns, "+StrPolarity(polarity)+") (press Enter)")
# stop and disable channel
StopAndDisable(pg, channel)
# print some info
pg.PrintVersion()
print("Actual temperature: "+str(pg.temp.ReadTemperature()) + " °C")
PrintFrequency(pg)
pg.PrintControl()
pg.PrintStatus()
pg.PrintDebug()
cont = raw_input("Next test? (n - quit, Enter - next test): ")
if cont == "n":
break
This diff is collapsed.
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