Commit e58bd375 authored by Denia Bouhired-Ferrag's avatar Denia Bouhired-Ferrag

Added scripts for testing the pulse rejection mechanism

parents f8d6788d 283b0325
*pyc
*swp
......@@ -7,3 +7,6 @@
[submodule "conv-ttl-blo-hw"]
path = conv-ttl-blo-hw
url = git@ohwr.org:level-conversion/conv-ttl-blo/conv-ttl-blo-hw.git
[submodule "software/PyBECO"]
path = software/PyBECO
url = https://gitlab.cern.ch/cohtdrivers/PyBECO.git
conv-ttl-blo-gw @ f7e79ef8
Subproject commit 103510645fb5ebdffccb1d2ef5894d832d947da5
Subproject commit f7e79ef83f572ffa778b9cf0a9c06901ed02ba61
PyBECO @ 5978d872
Subproject commit 5978d872aecf76f6842136be225fe5f40aa84bfa
#!/usr/bin/python
#===============================================================================
# CERN (BE-CO-HT)
# Memory map for CONV-TTL-BLO
#===============================================================================
# author: Maciej Suminski (maciej.suminski@cern.ch)
#
# date of creation: 02.02.2017
#
# version: 1.0
#
# description:
# This script contains memory map for CONV-TTL-BLO, gateware v4.
#
#===============================================================================
# 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
#===============================================================================
# last changes:
#===============================================================================
# TODO: -
#===============================================================================
# Memory map for gateware v4
SR = 0x04
ERR = 0x08
CR = 0x0c
CH1TTLPCR = 0x10
CH2TTLPCR = 0x14
CH3TTLPCR = 0x18
CH4TTLPCR = 0x1c
CH5TTLPCR = 0x20
CH6TTLPCR = 0x24
CH1BLOPCR = 0x28
CH2BLOPCR = 0x2c
CH3BLOPCR = 0x30
CH4BLOPCR = 0x34
CH5BLOPCR = 0x38
CH6BLOPCR = 0x3c
TVLR = 0x40
TVHR = 0x44
TBMR = 0x48
TBCYR = 0x4c
TBTLR = 0x50
TBTHR = 0x54
TBCSR = 0x58
CH1LTSCYR = 0x5c
UIDLR = 0xac
UIDHR = 0xb0
TEMPR = 0xb4
......@@ -6,6 +6,6 @@ clrchxpcr.py -- Clears the channel pulse counter registers
getsr.py -- Read the board's SR and print the list of fields
mantrig.py -- Manually trigger a pulse on a selected channel
rdchxpcr.py -- Read the channel pulse counter registers
setsr.py -- Set the board's SR, typically for clearing error bits
seterr.py -- Set the board's ERR, typically for clearing error bits
therm.py -- Get the unique ID and temperature from the
DS18B20 thermometer on-board the CONV-TTL-BLO
DS18B20 thermometer on-board the CONV-TTL-BLO
......@@ -4,10 +4,11 @@
# Clear CHxPCR registers on CONV-TTL-BLO
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
# Maciej Suminski (maciej.suminski@cern.ch)
#
# date of creation:
#
# version: 1.0
# version: 1.1
#
# description:
# This script is used to clear the input channel counters on the CONV-TTL-BLO
......@@ -27,8 +28,10 @@
# source; if not, download it from http://www.gnu.org/licenses/lgpl-2.1.html
#===============================================================================
# last changes:
# 2017-02-02 M. Suminski Updated mem map to match v4 gateware
# 2017-02-17 M. Suminski Use SLOT configuration from ei2cdefine
#===============================================================================
# TODO: -
# TODO: -
#===============================================================================
import time
import sys
......@@ -36,6 +39,8 @@ import time
sys.path.append("../ei2c")
from ei2c import *
import ei2cdefine
sys.path.append("..")
import convttl_regs as regs
if __name__ == "__main__":
......@@ -46,45 +51,26 @@ if __name__ == "__main__":
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
else:
ip = raw_input("ELMA crate IP or hostname : ")
user = raw_input("ELMA crate user name : ")
pwd = raw_input("ELMA crate password : ")
slot = int(raw_input("ELMA crate slot number : "))
testelma = EI2C(ip, user, pwd)
testelma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Print which board is detected in the selected slot
bid = testelma.get_bid(slot)
# Clear channel
testelma.write(slot, 0x0c, 0)
testelma.write(slot, 0x10, 0)
testelma.write(slot, 0x14, 0)
testelma.write(slot, 0x18, 0)
testelma.write(slot, 0x1c, 0)
testelma.write(slot, 0x20, 0)
# Clear counters
for i in range(6):
testelma.write(slot, regs.CH1TTLPCR + 4 * i, 0)
testelma.write(slot, regs.CH1BLOPCR + 4 * i, 0)
# Print channel counter values, close and exit
print("CH1: %d" % testelma.read(slot, 0x0c))
print("CH2: %d" % testelma.read(slot, 0x10))
print("CH3: %d" % testelma.read(slot, 0x14))
print("CH4: %d" % testelma.read(slot, 0x18))
print("CH5: %d" % testelma.read(slot, 0x1c))
print("CH6: %d" % testelma.read(slot, 0x20))
testelma.close()
# Print channel counter values
for i in range(6):
print("CH%d\tTTL: %d" % (i + 1, testelma.read(slot, regs.CH1TTLPCR + i*4)))
print(" \tBLO: %d" % (testelma.read(slot, regs.CH1BLOPCR + i*4)))
testelma.close()
#!/usr/bin/python
#===============================================================================
# CERN (BE-CO-HT)
# Set converter board status register
# Clear bits in the error register
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
# Maciej Suminski (maciej.suminski@cern.ch)
#
# date of creation: 2014-05-02
#
# version: 1.0
# version: 1.1
#
# description:
# Set the converter board status register, typically for clearing set error
# bits.
# Set the converter board errors register, typically for clearing set error
# bits. Note that typically to clear an error, one has to set it to logical
# one.
#
# dependencies:
# ../ei2c/ei2c.py
......@@ -32,6 +34,9 @@
#===============================================================================
# last changes:
# 2014-05-02 Theodor Stana File created
# 2017-02-02 M. Suminski Updated mem map to match v4 gateware,
# renamed from setsr.py to seterr.py
# 2017-02-17 M. Suminski Use SLOT configuration from ei2cdefine
#===============================================================================
# TODO: -
#===============================================================================
......@@ -41,6 +46,8 @@ import sys
sys.path.append("../ei2c")
from ei2c import *
import ei2cdefine
sys.path.append("..")
import convttl_regs as regs
if __name__ == "__main__":
......@@ -51,40 +58,23 @@ if __name__ == "__main__":
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
else:
ip = raw_input("ELMA crate IP or hostname : ")
user = raw_input("ELMA crate user name : ")
pwd = raw_input("ELMA crate password : ")
slot = int(raw_input("ELMA crate slot number : "))
testelma = EI2C(ip, user, pwd)
testelma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Print which board is detected in the selected slot
bid = testelma.get_bid(slot)
# Get status register value, set and re-print
v = testelma.read(slot, 0x4)
print("SR (pre-set) : 0x%08x" % v)
print("==========================")
v = raw_input("Value to set : 0x")
v = int(v, 16)
testelma.write(slot, 0x4, v)
print("==========================")
v = testelma.read(slot, 0x4)
print("SR (post-set) : 0x%08x" % v)
# Get error register value, set and re-print
v = testelma.read(slot, regs.ERR)
print("ERR (pre-set) : 0x%08x" % v)
testelma.write(slot, regs.ERR, v)
v = testelma.read(slot, regs.ERR)
print("ERR (post-set) : 0x%08x" % v)
testelma.close()
......@@ -4,10 +4,11 @@
# Retrieve gateware version from CONV-TTL-BLO board
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
# Maciej Suminski (maciej.suminski@cern.ch)
#
# date of creation:
#
# version: 1.0
# version: 1.1
#
# description:
# This script retrieves the value of the CONV-TTL-BLO status register and
......@@ -29,14 +30,18 @@
# last changes:
# 2014-05-02 Theodor Stana Changed to print the bits of the SR
# in turn.
# 2017-02-02 M. Suminski Updated mem map to match v4 gateware
# 2017-02-17 M. Suminski Use SLOT configuration from ei2cdefine
# Updated HWVERS mask & offset
#===============================================================================
# TODO: -
# TODO: -
#===============================================================================
import sys
sys.path.append("../ei2c")
from ei2c import *
import ei2cdefine
sys.path.append("..")
import convttl_regs as regs
if __name__ == "__main__":
......@@ -46,40 +51,31 @@ if __name__ == "__main__":
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
else:
ip = raw_input("ELMA crate IP or hostname : ")
user = raw_input("ELMA crate user name : ")
pwd = raw_input("ELMA crate password : ")
slot = int(raw_input("ELMA crate slot number : "))
testelma = EI2C(ip, user, pwd)
testelma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Print which board is detected in the selected slot
bid = testelma.get_bid(slot)
# Get status register value and print
v = testelma.read(slot, 0x4)
v = testelma.read(slot, regs.SR)
print("Status register : 0x%08x" % v)
print("===============================")
# Strip GWVERS and print
maj = (v & 0xf0) >> 4
min = v & 0x0f
print("Gateware version : v%d.%d (0x%02x)" % (maj, min, v & 0xff))
gwmaj = (v & 0xf0) >> 4
gwmin = v & 0x0f
print("Gateware version : v%d.%d (0x%02x)" % (gwmaj, gwmin, v & 0xff))
if gwmaj < 4:
print("This tool works with gateware v4. Please upgrade your gateware.")
sys.exit()
# Strip SWITCHES and print
switches = (v & 0xff00) >> 8
......@@ -89,12 +85,16 @@ if __name__ == "__main__":
# Gateware versions below these two had the switches active-low.
# This negation is done to allow correct printing of ON or OFF states.
if ((bid == "TBLO") and
(((maj == 0) and (min < 2)) or ((maj != 0) and (maj < 3)))):
(((gwmaj == 0) and (gwmin < 2)) or ((gwmaj != 0) and (gwmaj < 3)))):
switches ^= 0xff
if (switches & 0x80):
print(" TTL repetition : on")
print(" TTL mode : TTL")
else:
print(" TTL repetition : off")
print(" TTL mode : TTL-BAR")
if (switches & 0x02):
print(" Pulse length : short (250 ns)")
else:
print(" Pulse length : long (1.25 us)")
if (switches & 0x01):
print(" Glitch filter : on")
else:
......@@ -105,25 +105,46 @@ if __name__ == "__main__":
rtmm = rtm & 0x7
rtmp = (rtm & 0x3f) >> 3
if ((bid == "TBLO") and
(((maj == 0) and (min < 2)) or ((maj != 0) and (maj < 3)))):
(((gwmaj == 0) and (gwmin < 2)) or ((gwmaj != 0) and (gwmaj < 3)))):
print("-------------------------------")
print("Note: negated w.r.t. latest user guide version")
print("RTM detection : 0x%02x" % rtm)
print(" RTMM[2:0] : %s" % ("{0:#05b}".format(rtmm)[2:]))
print(" RTMP[2:0] : %s" % ("{0:#05b}".format(rtmp)[2:]))
if ((maj == 0) and (min < 2)) or (maj < 3):
if ((gwmaj == 0) and (gwmin < 2)) or (gwmaj < 3):
print("-------------------------------")
# Strip the other status bits and print
print("I2C timeout error : %s" % ("{0:#01b}".format(int(bool(v & (1 << 22))))[2]))
print("White Rabbit pres. : %s" % ("{0:#01b}".format(int(bool(v & (1 << 23))))[2]))
print("I2C address error : %s" % ("{0:#01b}".format(int(bool(v & (1 << 24))))[2]))
print("Pulse miss error : 0x%02x" % ((v & 0x7e000000) >> 24))
print(" CH1 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 25))))[2]))
print(" CH2 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 26))))[2]))
print(" CH3 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 27))))[2]))
print(" CH4 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 28))))[2]))
print(" CH5 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 29))))[2]))
print(" CH6 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 30))))[2]))
# Hardware version
hwmaj = (v & 0x0f000000) >> 24
hwmin = (v & 0x00c00000) >> 22
print("Hardware version : %s"
% ("%d.%d" % (hwmaj, hwmin) if hwmaj >= 4 else "3 or below" ))
# White Rabbit present
wrpres = (v & 0x04000000) >> 8
print("White Rabbit : %s" % ("present" if wrpres else "absent"))
# Get error register value and print
v = testelma.read(slot, regs.ERR)
print("Error register : 0x%08x" % v)
print("===============================")
print("I2C timeout error : %s" % ("{0:#01b}".format(int(bool(v & (1 << 0))))[2]))
print("I2C address error : %s" % ("{0:#01b}".format(int(bool(v & (1 << 1))))[2]))
print("Pulse frequency limit error : 0x%02x" % ((v & 0x000000fc) >> 2))
print(" CH1 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 2))))[2]))
print(" CH2 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 3))))[2]))
print(" CH3 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 4))))[2]))
print(" CH4 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 5))))[2]))
print(" CH5 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 6))))[2]))
print(" CH6 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 7))))[2]))
print("Pulse watchdog error : 0x%02x" % ((v & 0x00003f00) >> 8))
print(" CH1 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 8))))[2]))
print(" CH2 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 9))))[2]))
print(" CH3 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 10))))[2]))
print(" CH4 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 11))))[2]))
print(" CH5 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 12))))[2]))
print(" CH6 : %s" % ("{0:#01b}".format(int(bool(v & (1 << 13))))[2]))
testelma.close()
......@@ -4,10 +4,11 @@
# Manually trigger a pulse
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
# Maciej Suminski (maciej.suminski@cern.ch)
#
# date of creation:
#
# version: 1.0
# version: 1.1
#
# description:
# This script can be used to manually trigger a pulse on the CONV-TTL-BLO
......@@ -27,8 +28,10 @@
# source; if not, download it from http://www.gnu.org/licenses/lgpl-2.1.html
#===============================================================================
# last changes:
# 2017-02-02 M. Suminski Updated mem map to match v4 gateware
# 2017-02-17 M. Suminski Use SLOT configuration from ei2cdefine
#===============================================================================
# TODO: -
# TODO: -
#===============================================================================
import time
import sys
......@@ -36,6 +39,8 @@ import time
sys.path.append("../ei2c")
from ei2c import *
import ei2cdefine
sys.path.append("..")
import convttl_regs as regs
if __name__ == "__main__":
......@@ -46,39 +51,24 @@ if __name__ == "__main__":
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
else:
ip = raw_input("ELMA crate IP or hostname : ")
user = raw_input("ELMA crate user name : ")
pwd = raw_input("ELMA crate password : ")
slot = int(raw_input("ELMA crate slot number : "))
testelma = EI2C(ip, user, pwd)
testelma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Print which board is detected in the selected slot
bid = testelma.get_bid(slot)
# Send magic sequence
testelma.write(slot, 0x8, 0xde << 2)
testelma.write(slot, 0x8, 0xad << 2)
testelma.write(slot, 0x8, 0xbe << 2)
testelma.write(slot, 0x8, 0xef << 2)
# Ask for which channel to trigger on, trigger, close and exit
# Ask for which channel to trigger on
chan = input("chan (1..6): ")
testelma.write(slot, 0x8, chan << 2)
testelma.close()
# Send the magic sequence & the channel number
sequence = (0xde, 0xad, 0xbe, 0xef, chan) # password and then channel
for b in sequence:
testelma.write(slot, regs.CR, (b << 2) & 0x3FC)
testelma.close()
......@@ -4,10 +4,11 @@
# Read CHxPCR registers on CONV-TTL-BLO
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
# Maciej Suminski (maciej.suminski@cern.ch)
#
# date of creation:
#
# version: 1.0
# version: 1.1
#
# description:
# This script is used to read the input channel counters on the CONV-TTL-BLO
......@@ -27,8 +28,10 @@
# source; if not, download it from http://www.gnu.org/licenses/lgpl-2.1.html
#===============================================================================
# last changes:
# 2017-02-02 M. Suminski Updated mem map to match v4 gateware
# 2017-02-17 M. Suminski Use SLOT configuration from ei2cdefine
#===============================================================================
# TODO: -
# TODO: -
#===============================================================================
import time
import sys
......@@ -36,6 +39,8 @@ import time
sys.path.append("../ei2c")
from ei2c import *
import ei2cdefine
sys.path.append("..")
import convttl_regs as regs
if __name__ == "__main__":
......@@ -46,37 +51,21 @@ if __name__ == "__main__":
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
else:
ip = raw_input("ELMA crate IP or hostname : ")
user = raw_input("ELMA crate user name : ")
pwd = raw_input("ELMA crate password : ")
slot = int(raw_input("ELMA crate slot number : "))
testelma = EI2C(ip, user, pwd)
testelma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Print which board is detected in the selected slot
bid = testelma.get_bid(slot)
# Print channel counter values, close and exit
print("CH1: %d" % testelma.read(slot, 0x0c))
print("CH2: %d" % testelma.read(slot, 0x10))
print("CH3: %d" % testelma.read(slot, 0x14))
print("CH4: %d" % testelma.read(slot, 0x18))
print("CH5: %d" % testelma.read(slot, 0x1c))
print("CH6: %d" % testelma.read(slot, 0x20))
testelma.close()
# Print channel counter values
for i in range(6):
print("CH%d\tTTL: %d" % (i + 1, testelma.read(slot, regs.CH1TTLPCR + i*4)))
print(" \tBLO: %d" % (testelma.read(slot, regs.CH1BLOPCR + i*4)))
testelma.close()
#!/usr/bin/python
#===============================================================================
# CERN (BE-CO-HT)
# Set converter board error register
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
# Maciej Suminski (maciej.suminski@cern.ch)
#
# date of creation: 2014-05-02
#
# version: 1.1
#
# description:
# Set the converter board errors register, typically for clearing set error
# bits. Note that typically to clear an error, one has to set it to logical
# one.
#
# dependencies:
# ../ei2c/ei2c.py
# ../ei2c/ei2cdefine.py
#
#===============================================================================
# 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
#===============================================================================
# last changes:
# 2014-05-02 Theodor Stana File created
# 2017-02-02 M. Suminski Updated mem map to match v4 gateware,
# renamed from setsr.py to seterr.py
# 2017-02-17 M. Suminski Use SLOT configuration from ei2cdefine
#===============================================================================
# TODO: -
#===============================================================================
import sys
sys.path.append("../ei2c")
from ei2c import *
import ei2cdefine
sys.path.append("..")
import convttl_regs as regs
if __name__ == "__main__":
# Get the IP, user and password for the ELMA crate from either user input,
# or ei2cdefine.py
if (ei2cdefine.ENABLED):
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
else:
ip = raw_input("ELMA crate IP or hostname : ")
user = raw_input("ELMA crate user name : ")
pwd = raw_input("ELMA crate password : ")
slot = int(raw_input("ELMA crate slot number : "))
testelma = EI2C(ip, user, pwd)
testelma.open()
# Print which board is detected in the selected slot
bid = testelma.get_bid(slot)
# Get error register value, set and re-print
v = testelma.read(slot, regs.ERR)
print("ERR (pre-set) : 0x%08x" % v)
print("===========================")
v = raw_input("Value to set : 0x")
v = int(v, 16)
testelma.write(slot, regs.ERR, v)
print("===========================")
v = testelma.read(slot, regs.ERR)
print("ERR (post-set) : 0x%08x" % v)
testelma.close()
......@@ -4,10 +4,11 @@
# Read the CONV-TTL-BLO board ID and current temperature from DS18B20 chip
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
# Maciej Suminski (maciej.suminski@cern.ch)
#
# date of creation:
#
# version: 1.0
# version: 1.1
#
# description:
# The script implements some classes to communicate to the OpenCores One-Wire
......@@ -28,8 +29,11 @@
# source; if not, download it from http://www.gnu.org/licenses/lgpl-2.1.html
#===============================================================================
# last changes:
# 2017-02-02 M. Suminski Updated to work with gateware v4
# (read regs storing UID & temperature)
# 2017-02-17 M. Suminski Use SLOT configuration from ei2cdefine
#===============================================================================
# TODO: -
# TODO: -
#===============================================================================
# Import system modules
import sys
......@@ -40,33 +44,9 @@ import os
sys.path.append("../ei2c")
from ei2c import *
import ei2cdefine
sys.path.append("..")
import convttl_regs as regs
##------------------------------------------------------------------------------
## DS18B20 class
##------------------------------------------------------------------------------
class CDS18B20:
OFFSET_UIDLR = 0xA8
OFFSET_UIDHR = 0xAC
OFFSET_TEMPR = 0xB0
def __init__(self, elma, slot):
self.elma = elma
self.slot = slot
def read_serial_number(self):
l = self.elma.read(self.slot, self.OFFSET_UIDHR)
h = self.elma.read(self.slot, self.OFFSET_UIDLR)
return (h << 32 | l)
def read_temp(self):
temp = self.elma.read(self.slot, self.OFFSET_TEMPR) & 0xffff
return temp / 16.0
##------------------------------------------------------------------------------
## main
##------------------------------------------------------------------------------
if __name__ == "__main__":
FAMILY_CODE = 0x28
......@@ -77,44 +57,22 @@ if __name__ == "__main__":
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
else:
ip = raw_input("ELMA crate IP or hostname : ")
user = raw_input("ELMA crate user name : ")
pwd = raw_input("ELMA crate password : ")
elma = EI2C(ip, user, pwd)
elma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
slot = int(raw_input("ELMA crate slot number : "))
testelma = EI2C(ip, user, pwd)
testelma.open()
# Print which board is detected in the selected slot
bid = elma.get_bid(slot)
# CONV-TTL-BLO gateware changed memory map in v3.0 and golden v0.2
gwvers = elma.read(slot, 0x04) & 0xff
baseaddr = 0x200
if (bid == "TBLO"):
if ((gwvers >= 0x10) and (gwvers <= 0x22)):
baseaddr = 0x080
# Create onewire and thermometer objects
onewire = COpenCoresOneWire(elma, slot, baseaddr, 99, 19)
ds18b20 = CDS18B20(elma, slot)
bid = testelma.get_bid(slot)
# Reading of unique ID
unique_id = ds18b20.read_serial_number()
unique_id = ((testelma.read(slot, regs.UIDHR) << 32)
| testelma.read(slot, regs.UIDLR))
if(unique_id == -1):
msg = "ERROR: TempID IC20: Unable to read 1-wire thermometer"
print(msg)
......@@ -122,12 +80,12 @@ if __name__ == "__main__":
print("Unique ID: %.12X" % (unique_id))
# Reading of temperature
temp = ds18b20.read_temp(unique_id)
print("Current temperature: %3.3f" % temp)
temp = testelma.read(slot, regs.TEMPR) / 16.0
print("Current temperature: %3.3f *C" % temp)
# Cheking if received values are reasonable
if temp < 10.0 or temp > 50.0:
msg = "ERROR: TempID IC20: Temperature: %d out of range[10 .. 50oC]" % (temp)
msg = "ERROR: TempID IC20: Temperature: %d out of range[10 .. 50*C]" % (temp)
print(msg)
if((unique_id & 0xFF) != FAMILY_CODE):
......@@ -135,5 +93,4 @@ if __name__ == "__main__":
msg = "ERROR: TempID IC20: Invalid family code: 0x%.8X" % (family_code)
print(msg)
elma.close()
testelma.close()
......@@ -37,11 +37,11 @@ following:
(<USEDW>) <channel mask> : <TAI value>.<seconds value>
where
<USEDW> -- the TFCSR.USED field
<channel mask> -- the TFMR.CHAN field
<USEDW> -- the TBCSR.USED field
<channel mask> -- the TBMR.CHAN field
<TAI value> -- TAI value obtained by concatenating the bit fields of the
TFTLR and TFTHR registers
<seconds value> -- TFCYR * 8
TBTLR and TBTHR registers
<seconds value> -- TBCYR * 8
tsdiff.py
---------
......
......@@ -7,7 +7,7 @@
#
# date of creation: 2014-08-18
#
# version: 1.0
# version: 1.1
#
# description:
#
......@@ -29,6 +29,8 @@
#===============================================================================
# last changes:
# 2014-08-18 Theodor Stana File created
# 2017-02-02 M. Suminski Updated mem map to match v4 gateware
# 2017-02-17 M. Suminski Use SLOT configuration from ei2cdefine
#===============================================================================
# TODO: -
#===============================================================================
......@@ -36,6 +38,8 @@ import sys
sys.path.append("../../ei2c")
from ei2c import *
import ei2cdefine
sys.path.append("../..")
import convttl_regs as regs
if __name__ == "__main__":
......@@ -45,41 +49,27 @@ if __name__ == "__main__":
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
else:
ip = raw_input("ELMA crate IP or hostname : ")
user = raw_input("ELMA crate user name : ")
pwd = raw_input("ELMA crate password : ")
slot = int(raw_input("ELMA crate slot number : "))
testelma = EI2C(ip, user, pwd)
testelma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Print which board is detected in the selected slot
bid = testelma.get_bid(slot)
# Get and print latest timestamps
addr = 0x40
addr = regs.CH1LTSCYR
for i in range(6):
cyc = testelma.read(slot, addr)
tail = testelma.read(slot, addr + 4)
taih = testelma.read(slot, addr + 8) & 0x000000ff
cyc = testelma.read(slot, addr) # LTSCYR
tail = testelma.read(slot, addr + 4) # LTSTLR
taih = testelma.read(slot, addr + 8) & 0x000000ff # LTSTHR
ns = cyc * 8
s = (taih << 32) | tail
print("CH%d: %d.%09d sec" % (i+1, s, ns))
addr += 0x0c
testelma.close()
......@@ -4,10 +4,11 @@
# Read the CONV-TTL-BLO timetag buffer
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
# Maciej Suminski (maciej.suminski@cern.ch)
#
# date of creation:
#
# version: 1.0
# version: 1.1
#
# description:
# This script demonstrates reading the CONV-TTL-BLO timetag buffer down to the
......@@ -27,14 +28,18 @@
# source; if not, download it from http://www.gnu.org/licenses/lgpl-2.1.html
#===============================================================================
# last changes:
# 2017-02-02 M. Suminski Updated mem map to match v4 gateware
# 2017-02-17 M. Suminski Use SLOT configuration from ei2cdefine
#===============================================================================
# TODO: -
# TODO: -
#===============================================================================
import sys
sys.path.append("../../ei2c")
from ei2c import *
import ei2cdefine
import math
sys.path.append("../..")
import convttl_regs as regs
if __name__ == "__main__":
......@@ -44,28 +49,15 @@ if __name__ == "__main__":
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
else:
ip = raw_input("ELMA crate IP or hostname : ")
user = raw_input("ELMA crate user name : ")
pwd = raw_input("ELMA crate password : ")
slot = int(raw_input("ELMA crate slot number : "))
testelma = EI2C(ip, user, pwd)
testelma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Print which board is detected in the selected slot
bid = testelma.get_bid(slot)
......@@ -86,7 +78,7 @@ if __name__ == "__main__":
print("Error: " + sys.exc_info()[0]);
# Read while FIFO is not empty
csr = testelma.read(slot, 0x3c)
csr = testelma.read(slot, regs.TBCSR)
empty = csr & (1 << 17)
used = csr & 0x7f
......@@ -94,9 +86,9 @@ if __name__ == "__main__":
while not empty:
# Read cycles and seconds counters
cyc = testelma.read(slot, 0x30)
sl = testelma.read(slot, 0x34)
sh = testelma.read(slot, 0x38)
cyc = testelma.read(slot, regs.TBCYR)
sl = testelma.read(slot, regs.TBTLR)
sh = testelma.read(slot, regs.TBTHR)
# The seconds counter indicates actual seconds; the cycles counter
# indicates 8-ns cycles, so convert to ns
......@@ -104,14 +96,14 @@ if __name__ == "__main__":
ns = cyc*8
# Get contents of TBCSR
csr = testelma.read(slot, 0x3c)
csr = testelma.read(slot, regs.TBCSR)
empty = csr & (1 << 17)
if (empty):
break
used = csr & 0x7f
# Get channel mask from meta register
ch = testelma.read(slot, 0x2c) & 0x3f
ch = testelma.read(slot, regs.TBMR) & 0x3f
# Increment channel counters if channel bit is set in FIFO
i = 0
......
......@@ -4,10 +4,11 @@
# Get the current timestamp counter value
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
# Maciej Suminski (maciej.suminski@cern.ch)
#
# date of creation:
#
# version: 1.0
# version: 1.1
#
# description:
# This script reads the TVLR and TVHR registers and prints their value to stdout.
......@@ -26,14 +27,18 @@
# source; if not, download it from http://www.gnu.org/licenses/lgpl-2.1.html
#===============================================================================
# last changes:
# 2017-02-02 M. Suminski Updated mem map to match v4 gateware
# 2017-02-17 M. Suminski Use SLOT configuration from ei2cdefine
#===============================================================================
# TODO: -
# TODO: -
#===============================================================================
import sys
sys.path.append("../../ei2c")
import time
from ei2c import *
import ei2cdefine
sys.path.append("../..")
import convttl_regs as regs
if __name__ == "__main__":
......@@ -43,33 +48,20 @@ if __name__ == "__main__":
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
else:
ip = raw_input("ELMA crate IP or hostname : ")
user = raw_input("ELMA crate user name : ")
pwd = raw_input("ELMA crate password : ")
slot = int(raw_input("ELMA crate slot number : "))
testelma = EI2C(ip, user, pwd)
testelma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Print which board is detected in the selected slot
bid = testelma.get_bid(slot)
tail = testelma.read(slot, 0x24)
taih = testelma.read(slot, 0x28)
tail = testelma.read(slot, regs.TVLR)
taih = testelma.read(slot, regs.TVHR)
print("TAI counter value: %d" % ((taih << 32) | tail))
......
......@@ -4,10 +4,11 @@
# Set the timestamp counter value
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
# Maciej Suminski (maciej.suminski@cern.ch)
#
# date of creation:
#
# version: 1.0
# version: 1.1
#
# description:
# This script writes the TVLR and TVHR registers to set the new internal
......@@ -27,14 +28,18 @@
# source; if not, download it from http://www.gnu.org/licenses/lgpl-2.1.html
#===============================================================================
# last changes:
# 2017-02-02 M. Suminski Updated mem map to match v4 gateware
# 2017-02-17 M. Suminski Use SLOT configuration from ei2cdefine
#===============================================================================
# TODO: -
# TODO: -
#===============================================================================
import sys
sys.path.append("../../ei2c")
import time
from ei2c import *
import ei2cdefine
sys.path.append("../..")
import convttl_regs as regs
if __name__ == "__main__":
......@@ -45,41 +50,26 @@ if __name__ == "__main__":
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
else:
ip = raw_input("ELMA crate IP or hostname : ")
user = raw_input("ELMA crate user name : ")
pwd = raw_input("ELMA crate password : ")
slot = int(raw_input("ELMA crate slot number : "))
testelma = EI2C(ip, user, pwd)
testelma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Print which board is detected in the selected slot
bid = testelma.get_bid(slot)
# Set time stamp, close and exit
s = int(raw_input("Number of seconds: "))
testelma.write(slot, 0x24, s & 0xffffffff)
if s > 2**32-1:
testelma.write(slot, 0x28, s >> 32)
testelma.write(slot, regs.TVLR, s & 0xffffffff)
testelma.write(slot, regs.TVHR, s >> 32)
tail = testelma.read(slot, 0x24)
taih = testelma.read(slot, 0x28)
tail = testelma.read(slot, regs.TVLR)
taih = testelma.read(slot, regs.TVHR)
print("TAI counter value: %d" % ((taih << 32) | tail))
testelma.close()
......@@ -29,6 +29,7 @@
#===============================================================================
# last changes:
# 2014-03-05 Theodor Stana File created
# 2017-02-15 Maciej Suminski Added 'SLOT' parameter
#===============================================================================
# TODO: -
#===============================================================================
......@@ -40,6 +41,7 @@ ENABLED = False
HNAME = ""
USER = ""
PWD = ""
SLOT = 0
# Boolean to tell the ei2c.py module whether to create a dump file for the ELMA
# command replies
......
......@@ -42,6 +42,7 @@
#===============================================================================
# last changes:
# 2013-08-13 Theodor Stana File created
# 2017-02-17 M. Suminski Use SLOT configuration from ei2cdefine
#===============================================================================
# TODO: -
#===============================================================================
......@@ -72,30 +73,15 @@ if __name__ == "__main__":
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
else:
ip = raw_input("ELMA crate IP or hostname : ")
user = raw_input("ELMA crate user name : ")
pwd = raw_input("ELMA crate password : ")
slot = int(raw_input("ELMA crate slot number : "))
elma = EI2C(ip, user, pwd)
elma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except ValueError as e :
print ("%s is not a valid integer." % e.args[0].split(": ")[1])
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Print which board is detected in the selected slot
bid = elma.get_bid(slot)
......
......@@ -12,24 +12,10 @@ if __name__ == "__main__":
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
testelma = EI2C(ip, user, pwd)
testelma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Get board ID and gateware version, fail if incorrect
bloid = testelma.read(slot, 0x00)
fwvers = testelma.read(slot, 0x04) & 0xFF
......
......@@ -29,6 +29,7 @@
# last changes:
# 2014-07-02 Theodor Stana Setting the frequency to 0 Hz does not
# enable the channel
# 2017-02-17 M. Suminski Use SLOT configuration from ei2cdefine
#===============================================================================
# TODO: -
#===============================================================================
......@@ -85,24 +86,10 @@ if __name__ == "__main__":
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
testelma = EI2C(ip, user, pwd)
testelma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Get board ID and gateware version, fail if incorrect
bloid = testelma.read(slot, 0x00)
fwvers = testelma.read(slot, 0x04) & 0xFF
......
......@@ -12,24 +12,10 @@ if __name__ == "__main__":
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
testelma = EI2C(ip, user, pwd)
testelma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Get board ID and gateware version, fail if incorrect
bloid = testelma.read(slot, 0x00)
fwvers = testelma.read(slot, 0x04) & 0xFF
......
......@@ -37,6 +37,7 @@
# last changes:
# 2013-08-13 Theodor Stana File created
# 2014-03-06 Theodor Stana Added description above
# 2017-02-17 M. Suminski Use SLOT configuration from ei2cdefine
#===============================================================================
# TODO: -
#===============================================================================
......@@ -58,24 +59,10 @@ if __name__ == "__main__":
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
testelma = EI2C(ip, user, pwd)
testelma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Ask how long to run the test
print "How long would you like to run the test?"
while 1:
......@@ -130,7 +117,7 @@ if __name__ == "__main__":
f.write("Nr. slots: %d\n" % nrslots)
f.write("Runtime: %d hrs, %d mins, %d s\n" % (hrs, mins, secs))
f.write("------------------------------------------------------------\r\n")
f.write("%s: starting test\r\n" % time.strftime("%Y-%m-%d-%Hh%Mm%Ss", time.localtime()))
f.write("%s: starting test\r\n" % time.strftime("%Y-%m-%d-%Hh%Mm%Ss", time.localtime()))
print "%s: starting test" % time.strftime("%Y-%m-%d-%Hh%Mm%Ss", time.localtime())
f.write("------------------------------------------------------------\r\n")
......
This script connects to a create and checks that the values of the CHxPCR and
This script connects to a crate and checks that the values of the CHxPCR and
CHxLTS*R registers are not written with wrong values.
Basically, its purpose is to check that no 'sync' errors occur when the
......
......@@ -4,6 +4,7 @@
# Long-term register update test
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
# Maciej Suminski (maciej.suminski@cern.ch)
#
# date of creation: 2014-08-25
#
......@@ -29,8 +30,11 @@
#===============================================================================
# last changes:
# 2014-08-25 Theodor Stana File created
# 2017-02-02 M. Suminski Updated mem map to match v4 gateware
# 2017-02-17 M. Suminski Use SLOT configuration from ei2cdefine
#===============================================================================
# TODO: -
# TODO: - It was not tested with gateware v4, there are now separate counters
# for TTL and blocking pulses. Blocking pulse counters are not handled.
#===============================================================================
import sys
......@@ -38,6 +42,8 @@ sys.path.append("../ei2c");
from ei2c import *
import ei2cdefine
import time
sys.path.append("..");
import convttl_regs as regs
if __name__ == "__main__":
......@@ -45,24 +51,10 @@ if __name__ == "__main__":
ip = ei2cdefine.HNAME
user = ei2cdefine.USER
pwd = ei2cdefine.PWD
slot = ei2cdefine.SLOT
elma = EI2C(ip, user, pwd)
elma.open()
# Ask for slot number
while 1:
try:
slot = raw_input("Slot no.: ")
slot = int(slot)
break
except TypeError as e:
print("Please input a decimal slot number.")
except SlotError as e:
print(e.strerror)
except KeyboardInterrupt:
sys.exit();
except:
print("Unexpected error: ", sys.exc_info()[0])
# Ask how long to run the test
print("")
print("How long would you like to run the test?")
......@@ -138,18 +130,19 @@ if __name__ == "__main__":
chltstlr_p[3] = []
chltsthr_p[3] = []
for i in range(0, 6):
chpcr[1].append(elma.read(slot, 0x0c + 4*i))
chltscyr[1].append(elma.read(slot, 0x40 + 0xc*i))
chltstlr[1].append(elma.read(slot, 0x44 + 0xc*i))
chltsthr[1].append(elma.read(slot, 0x48 + 0xc*i) & 0xff)
chpcr[1].append(elma.read(slot, regs.CH1TTLPCR + 4*i))
chltscyr[1].append(elma.read(slot, regs.CH1LTSCYR + 0xc*i))
chltstlr[1].append(elma.read(slot, regs.CH1LTSTLR + 0xc*i))
chltsthr[1].append(elma.read(slot, regs.CH1LTSTHR + 0xc*i) & 0xff)
chpcr_p[1].append(chpcr[1][i])
chltscyr_p[1].append(chltscyr[1][i])
chltstlr_p[1].append(chltstlr[1][i])
chltsthr_p[1].append(chltsthr[1][i])
chpcr[3].append(elma.read(slot+2, 0x0c + 4*i))
chltscyr[3].append(elma.read(slot+2, 0x40 + 0xc*i))
chltstlr[3].append(elma.read(slot+2, 0x44 + 0xc*i))
chltsthr[3].append(elma.read(slot+2, 0x48 + 0xc*i) & 0xff)
chpcr[3].append(elma.read(slot+2, regs.CH1TTLPCR + 4*i))
chltscyr[3].append(elma.read(slot+2, regs.CH1LTSCYR+ 0xc*i))
chltstlr[3].append(elma.read(slot+2, regs.CH1LTSTLR + 0xc*i))
chltsthr[3].append(elma.read(slot+2, regs.CH1LTSTHR + 0xc*i) & 0xff)
chpcr_p[3].append(chpcr[1][i])
chltscyr_p[3].append(chltscyr[3][i])
chltstlr_p[3].append(chltstlr[3][i])
......@@ -172,18 +165,18 @@ if __name__ == "__main__":
for i in range(0, 6):
# Read values
chpcr[slot][i] = elma.read(slot, 0x0c + 4*i)
chltscyr[slot][i] = elma.read(slot, 0x40 + 0xc*i)
chltstlr[slot][i] = elma.read(slot, 0x44 + 0xc*i)
chltsthr[slot][i] = elma.read(slot, 0x48 + 0xc*i) & 0xff
chpcr[slot][i] = elma.read(slot, regs.CH1TTLPCR + 4*i)
chltscyr[slot][i] = elma.read(slot, regs.CH1LTSCYR + 0xc*i)
chltstlr[slot][i] = elma.read(slot, regs.CH1LTSTLR + 0xc*i)
chltsthr[slot][i] = elma.read(slot, regs.CH1LTSTHR + 0xc*i) & 0xff
# check CHxPCR not lower and within a tolerance limit of value before
# check CHxTTLPCR not lower and within a tolerance limit of value before
if (chpcr[slot][i] < chpcr_p[slot][i]) or (chpcr[slot][i] > chpcr_p[slot][i] + 14000):
print("ERROR (%d / %s): CH%dPCR unexpected value (%d / %d)" % (
print("ERROR (%d / %s): CH%dTTLPCR unexpected value (%d / %d)" % (
slot, time.strftime("%Y-%m-%d-%Hh%Mm%Ss", time.localtime()),
i+1, chpcr_p[slot][i], chpcr[slot][i]))
elif (chpcr[slot][i] > chpcr_p[slot][i]+4200):
print("WARNING (%d / %s): CH%dPCR value: (%d / %d)" % (
print("WARNING (%d / %s): CH%dTTLPCR value: (%d / %d)" % (
slot, time.strftime("%Y-%m-%d-%Hh%Mm%Ss", time.localtime()),
i+1, chpcr_p[slot][i], chpcr[slot][i]))
......@@ -212,7 +205,7 @@ if __name__ == "__main__":
chltsthr_p[slot][i] = chltsthr[slot][i]
# print(slot)
# print("CH%dPCR=%d" % (i+1, chpcr[slot][i]) )
# print("CH%dTTLPCR=%d" % (i+1, chpcr[slot][i]) )
# print("CH%dPLTSCYR=%d" % (i+1, chltscyr[slot][i]) )
# print("CH%dPLTSTLR=%d" % (i+1, chltstlr[slot][i]) )
# print("CH%dPLTSTHR=%d" % (i+1, chltsthr[slot][i]) )
......@@ -222,18 +215,18 @@ if __name__ == "__main__":
for i in range(0, 6):
# Read values
chpcr[slot][i] = elma.read(slot, 0x0c + 4*i)
chltscyr[slot][i] = elma.read(slot, 0x40 + 0xc*i)
chltstlr[slot][i] = elma.read(slot, 0x44 + 0xc*i)
chltsthr[slot][i] = elma.read(slot, 0x48 + 0xc*i) & 0xff
chpcr[slot][i] = elma.read(slot, regs.CH1TTLTTLPCR + 4*i)
chltscyr[slot][i] = elma.read(slot, regs.CH1LTSCYR + 0xc*i)
chltstlr[slot][i] = elma.read(slot, regs.CH1LTSTLR + 0xc*i)
chltsthr[slot][i] = elma.read(slot, regs.CH1LTSTHR + 0xc*i) & 0xff
# check CHxPCR not lower and within a tolerance limit of value before
# check CHxTTLPCR not lower and within a tolerance limit of value before
if (chpcr[slot][i] < chpcr_p[slot][i]) or (chpcr[slot][i] > chpcr_p[slot][i] + 14000):
print("ERROR (%d / %s): CH%dPCR unexpected value (%d / %d)" % (
print("ERROR (%d / %s): CH%dTTLPCR unexpected value (%d / %d)" % (
slot, time.strftime("%Y-%m-%d-%Hh%Mm%Ss", time.localtime()),
i+1, chpcr_p[slot][i], chpcr[slot][i]))
elif (chpcr[slot][i] > chpcr_p[slot][i]+4200):
print("WARNING (%d / %s): CH%dPCR value: (%d / %d)" % (
print("WARNING (%d / %s): CH%dTTLPCR value: (%d / %d)" % (
slot, time.strftime("%Y-%m-%d-%Hh%Mm%Ss", time.localtime()),
i+1, chpcr_p[slot][i], chpcr[slot][i]))
......@@ -263,7 +256,7 @@ if __name__ == "__main__":
chltsthr_p[slot][i] = chltsthr[slot][i]
# print(slot)
# print("CH%dPCR=%d" % (i+1, chpcr[slot][i]) )
# print("CH%dTTLPCR=%d" % (i+1, chpcr[slot][i]) )
# print("CH%dPLTSCYR=%d" % (i+1, chltscyr[slot][i]) )
# print("CH%dPLTSTLR=%d" % (i+1, chltstlr[slot][i]) )
# print("CH%dPLTSTHR=%d" % (i+1, chltsthr[slot][i]) )
......
......@@ -4,6 +4,7 @@
# Long-term "no pulses at startup" test script
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
# Maciej Suminski (maciej.suminski@cern.ch)
#
# date of creation: 2014-05-09
#
......@@ -42,8 +43,10 @@
#===============================================================================
# last changes:
# 2014-05-09 Theodor Stana File created
# 2017-02-02 M. Suminski Updated mem map to match v4 gateware
#===============================================================================
# TODO: -
# TODO: - It was not tested with gateware v4, there are now separate counters
# for TTL and blocking pulses. Blocking pulse counters are not handled.
#===============================================================================
import time
......@@ -52,6 +55,8 @@ sys.path.append("../ei2c")
from ei2c import *
import subprocess
import os
sys.path.append("..")
import convttl_regs as regs
#===============================================================================
# Change IPs/hostnames and logon credentials as appropriate
......@@ -153,13 +158,13 @@ if __name__ == "__main__":
switch.append("OFF")
f.write("TTL switch readout\n")
if not (dutelma.read(1, 0x04) & (0x8000)):
if not (dutelma.read(1, regs.SR) & (0x8000)):
switch[0] = "ON"
if not (dutelma.read(2, 0x04) & (0x8000)):
if not (dutelma.read(2, regs.SR) & (0x8000)):
switch[1] = "ON"
if not (chkelma.read(1, 0x04) & (0x8000)):
if not (chkelma.read(1, regs.SR) & (0x8000)):
switch[2] = "ON"
if not (chkelma.read(2, 0x04) & (0x8000)):
if not (chkelma.read(2, regs.SR) & (0x8000)):
switch[3] = "ON"
f.write(" DUT1: TTL switch %s\n" % switch[0])
......@@ -200,12 +205,8 @@ if __name__ == "__main__":
dut_elma_on()
# Read counters and print errors
chcnt1[0] = chkelma.read(1, 0x0c)
chcnt1[1] = chkelma.read(1, 0x10)
chcnt1[2] = chkelma.read(1, 0x14)
chcnt1[3] = chkelma.read(1, 0x18)
chcnt1[4] = chkelma.read(1, 0x1c)
chcnt1[5] = chkelma.read(1, 0x20)
for ch in range(6):
chcnt1[ch] = chkelma.read(1, regs.CH1TTLPCR + i*4)
if not (chcnt1 == cntcmp):
errcnt1 += 1
......@@ -216,12 +217,8 @@ if __name__ == "__main__":
f.write(errmsg + "\n")
#print(errmsg)
chcnt2[0] = chkelma.read(2, 0x0c)
chcnt2[1] = chkelma.read(2, 0x10)
chcnt2[2] = chkelma.read(2, 0x14)
chcnt2[3] = chkelma.read(2, 0x18)
chcnt2[4] = chkelma.read(2, 0x1c)
chcnt2[5] = chkelma.read(2, 0x20)
for ch in range(6):
chcnt2[ch] = chkelma.read(2, regs.CH1TTLPCR + i*4)
if not (chcnt2 == cntcmp):
errcnt2 += 1
......@@ -233,19 +230,9 @@ if __name__ == "__main__":
#print(errmsg)
# Clear counters
chkelma.write(1, 0x0c, 0)
chkelma.write(1, 0x10, 0)
chkelma.write(1, 0x14, 0)
chkelma.write(1, 0x18, 0)
chkelma.write(1, 0x1c, 0)
chkelma.write(1, 0x20, 0)
chkelma.write(2, 0x0c, 0)
chkelma.write(2, 0x10, 0)
chkelma.write(2, 0x14, 0)
chkelma.write(2, 0x18, 0)
chkelma.write(2, 0x1c, 0)
chkelma.write(2, 0x20, 0)
for ch in range(6):
chkelma.write(1, regs.CH1TTLPCR + i*4, 0)
chkelma.write(2, regs.CH1TTLPCR + i*4, 0)
f.write("------------------------------------------------------------\n")
......
#! /usr/bin/python
"""
Author: Maciej Suminski <maciej.suminski@cern.ch>
Copyright: CERN 2017
License: GPLv3
Tests CONV-TTL-BLO pulse rejection module.
"""
import os
import sys
import time
sys.path.append("../PyBECO")
from PyBECO.boards import PyConvTTLBLO, PyConvTTLException
from PyBECO.fec import Elma, ElmaException
# crate credentials
sys.path.append("../ei2c")
import ei2cdefine as cfg
# settings
address = cfg.HNAME if cfg.ENABLED and cfg.HNAME else raw_input("Hostname: ")
user = cfg.USER if cfg.ENABLED and cfg.USER else raw_input("User: ")
password = cfg.PWD if cfg.ENABLED and cfg.PWD else raw_input("Password: ")
slot = cfg.SLOT if cfg.ENABLED and cfg.SLOT else int(input("Slot number: "))
cooldown_time = 8 # number seconds of cool down time between tests
elma = Elma(address, user, password)
convttl = PyConvTTLBLO(slot, elma)
convttl.reset()
# display status
print(convttl.status)
# verify gateware and hardware number
if convttl.status.hw_version[0] != 4:
print("ERROR: Expected hardware version 4.x, but it is %d.%d" % convttl.status.hw_version)
# sys.exit(1) # TODO uncomment
if convttl.status.gw_version[0] != 4:
print("ERROR: Expected gateware version 4.x, but it is %d.%d" % convttl.status.gw_version)
sys.exit(1)
# selectt the test data set depending on the pulse duration switch
if(convttl.status.switch[1]):
# short pulse
mode = "short"
max_freq = 2e6
pulse_len = 250e-9
tests = (
{'freq': 2000000, 'pulses': 2e6},
{'freq': 1333330, 'pulses': 8.65e6},
{'freq': 1000000, 'pulses': 1e7},
{'freq': 800000, 'pulses': 2.08e7},
{'freq': 666670, 'pulses': 2.439e7},
{'freq': 571000, 'pulses': 571000 * 120, 'continuous': True}
)
else:
# long pulse
mode = "long"
max_freq = 105e3
pulse_len = 1.2e-6
tests = (
# {'freq': 104166, 'pulses': 104166},
# {'freq': 92592, 'pulses': 277000},
{'freq': 83333, 'pulses': 541000},
{'freq': 75757, 'pulses': 75757 * 10},
{'freq': 69444, 'pulses': 69444 * 20},
{'freq': 55555, 'pulses': 55555 * 60},
{'freq': 52083, 'pulses': 52083 * 120, 'continuous': True},
)
print("Running %s pulse tests" % mode)
# run tests
for test in tests:
old_counters = None
freq = test['freq']
pulses = int(test['pulses'])
continuous = True if 'continuous' in test and test['continuous'] else False
#############################################################################################
# test if the guaranteed number of pulses is repeated
# clear counters
for ch in convttl.CHANNELS:
convttl.pulse_counter_set(ch, (0, 0))
# clear errors (including missed pulse flags)
convttl.error.error_reg = convttl.error.ERRORS_MASK
print("------")
print("TEST: repeat %d pulses at %d Hz" % (pulses, freq))
print("Start the pulse burst generator (%d pulses)" % int(pulses))
print(" ./pulsegen.py -c %d -f %F -w %G" % (pulses, freq, pulse_len))
print("")
print("Pulse counters:")
test_run = True
# test if all pulses pass through
while(test_run):
errors = convttl.error.error_reg
counters = convttl.pulse_counters
if(old_counters != counters):
for ch in convttl.CHANNELS:
print("CH%d" % ch),
print("[TTL:%7d BLO:%7d] " % counters[ch-1]),
print("")
old_counters = counters
for ch in convttl.CHANNELS:
# set of missed pulse error flags for this channel
pulse_missed_errors = (convttl.error.ERRORS_MASK_FLIM_MISSED(ch),
convttl.error.ERRORS_MASK_FWDG_MISSED(ch))
if counters[ch - 1][0] != 0 and counters[ch - 1][1] != 0:
print("WARNING: Both pulse counters are increasing, check if it is ok")
pulse_count = max(old_counters[ch - 1])
# check if there were any pulses missed
if any(error_bit & errors for error_bit in pulse_missed_errors):
if(pulse_count <= pulses):
print("TEST FAILED: channel %d missed a pulse (%d)" % (ch, pulse_count))
sys.exit(2)
test_run = False
break
# check if we have reached the number of guaranteed pulses
if pulse_count >= pulses:
print("TEST PASSED: repeated %d pulses at frequency %d Hz" % (pulse_count, freq))
test_run = False
break
print("waiting %d seconds of cool-down period" % cooldown_time)
time.sleep(cooldown_time)
#############################################################################################
# test if pulses are rejected after the counter threshold has been reached
if continuous: # we cannot perform this test for frequencies that
continue # are meant to repeat pulses without rejecting any
# clear counters
for ch in convttl.CHANNELS:
convttl.pulse_counter_set(ch, (0, 0))
# clear errors (including missed pulse flags)
convttl.error.error_reg = convttl.error.ERRORS_MASK
print("")
print("------")
print("")
print("TEST: reject pulses after repeating %d pulses at %d Hz" % (pulses, freq))
print("Start the pulse burst generator (%d pulses)" % (pulses * 2))
print(" ./pulsegen.py -c %d -f %F -w %G" % (pulses * 2, freq, pulse_len))
print("")
print("Pulse counters:")
test_run = True
passed = [False for _ in convttl.CHANNELS] # passed test flags for each channel
# test if pulses are rejected after a certain threshold
while(test_run):
errors = convttl.error.error_reg
counters = convttl.pulse_counters
if(old_counters != counters):
for ch in convttl.CHANNELS:
print("CH%d" % ch),
print("[TTL:%7d BLO:%7d] " % counters[ch-1]),
print("")
old_counters = counters
for ch in convttl.CHANNELS:
# set of missed pulse error flags for this channel
pulse_missed_errors = (convttl.error.ERRORS_MASK_FLIM_MISSED(ch),
convttl.error.ERRORS_MASK_FWDG_MISSED(ch))
if old_counters[ch - 1][0] != 0 and old_counters[ch - 1][1] != 0:
print("WARNING: Both pulse counters are increasing, check if it is ok")
pulse_count = max(old_counters[ch - 1])
# check if there were any pulses missed
if any(error_bit & errors for error_bit in pulse_missed_errors):
if(pulse_count <= pulses):
print("TEST FAILED: channel %d missed a pulse too early (%d)" % (ch, pulse_count))
sys.exit(2)
elif not passed[ch - 1]:
if convttl.error.ERRORS_MASK_FLIM_MISSED(ch) & errors:
print("TEST FAILED: pulse rejected on channel %d, but FLIM_MISSED bit is set" % (ch))
sys.exit(2)
else:
print("TEST PASSED: rejected %d pulse on channel %d" % (pulse_count, ch))
passed[ch - 1] = True
# even if the test was passed, wait for the end of current pulse burst
if(pulse_count >= pulses * 2):
if not any(error & errors for error in pulse_missed_errors):
print("TEST FAILED: repeated %d pulses, none rejected" % (pulse_count))
sys.exit(2)
test_run = False
if any(passed):
print("TEST PASSED")
print("waiting %d seconds of cool-down period" % cooldown_time)
time.sleep(cooldown_time)
###############################################################################
# test FLIM_MISSED bit (pulses with too high frequency)
pulses = 10000
freq = max_freq * 1.2
# clear counters
for ch in convttl.CHANNELS:
convttl.pulse_counter_set(ch, (0, 0))
# clear errors (including missed pulse flags)
convttl.error.error_reg = convttl.error.ERRORS_MASK
print("")
print("------")
print("")
print("TEST: reject pulses at too high frequency (FLIM_MISSED bit)")
print("Start the pulse burst generator (%d pulses at %d Hz" % (pulses, freq))
print(" ./pulsegen.py -c %d -f %F -w %G" % (pulses, freq, pulse_len))
print("")
test_run = True
while(test_run):
counters = convttl.pulse_counters
errors = convttl.error.error_reg
if(old_counters != counters):
print(counters)
old_counters = counters
for ch in convttl.CHANNELS:
if old_counters[ch - 1][0] != 0 and old_counters[ch - 1][1] != 0:
print("WARNING: Both pulse counters are increasing, check if it is ok")
pulse_count = max(old_counters[ch - 1])
# check if there were any pulses missed
if convttl.error.ERRORS_MASK_FLIM_MISSED(ch) & errors:
if convttl.error.ERRORS_MASK_FWDG_MISSED(ch) & errors:
print("WARNING: FLIM_WDG bit is set for channel %d" % (ch))
print("TEST PASSED: FLIM_MISSED flag set on channel %d" % (ch))
test_run = False
break
if(pulse_count >= pulses):
print("TEST FAILED: repeated %d pulses, FLIM_MISSED flag has not been set" % (pulse_count))
sys.exit(2)
print("ALL TESTS PASSED!")
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