Commit 0878b3d6 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

sw: Changed pulsetest.py to avoid unnecessary user input

Also added channel frequency in output file.
Signed-off-by: Theodor-Adrian Stana's avatarTheodor Stana <t.stana@cern.ch>
parent d117dd4c
#===============================================================================
# CERN (BE-CO-HT)
# EI2C global definitions file
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
#
# date of creation: 2014-03-05
#
# version: 1.0
#
# description:
#
# This module defines some global constants that are used by other scripts in
# the software suite. The constants and their definitions are in the code
# below.
#
#===============================================================================
# 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-03-05 Theodor Stana File created
#===============================================================================
# TODO: -
#===============================================================================
# Hostname, username and password
HNAME = ""
USER = ""
PWD = ""
# Boolean to tell the ei2c.py module whether to create a dump file for the ELMA
# command replies
DUMP = False
......@@ -9,31 +9,31 @@ To run, you first need a CONV-TTL-BLO with a pulsetest gateware. Then:
%> ./pulsetest.py
Slot no.: <give the slot number of the pulsetest CONV-TTL-BLO>
Enable channel 1? (y/n) y
freq (Hz): 1
Enable channel 2? (y/n) n
Enable channel 3? (y/n) n
Enable channel 4? (y/n) y
freq (Hz): 2
Enable channel 5? (y/n) n
Enable channel 6? (y/n) y
freq (Hz): 4
CH1 freq (Hz): <pulse frequency, number >0; 0 disables the channel >
CH2 freq (Hz): <pulse frequency, number >0; 0 disables the channel >
CH3 freq (Hz): <pulse frequency, number >0; 0 disables the channel >
CH4 freq (Hz): <pulse frequency, number >0; 0 disables the channel >
CH5 freq (Hz): <pulse frequency, number >0; 0 disables the channel >
CH6 freq (Hz): <pulse frequency, number >0; 0 disables the channel >
How long would you like to run the test?
hrs: <give the number of hours>
mins: <give the number of minutes>
secs: <give the number of seconds>
For each channel you want to enable, it writes the frequency value to the
appropriate register in the pulsetest gateware, then sets the appropriate bits
in the control register to enable pulse generation. For more information on
the pulsetest gateware and the registers the script is writing, see:
For each channel you set a frequency value greater than 0, the script writes the
frequency value to the appropriate register in the pulsetest gateware, then sets
the appropriate bits to the control register to enable pulse generation. For
more information on the pulsetest gateware and the registers the script is
writing, see:
http://www.ohwr.org/projects/conv-ttl-blo-gw/wiki/pulsetest
Note that the output frequency is limited to 166 kHz _in software_, to avoid
damage to the output transformers.
Note that the output pulse frequency is limited to the MAXFREQ value in the script
_in software_, to avoid damage to the output stage MOSFET. The gateware employs
no limitation on this value.
When the script finishes execution, it will store the output to a file it
When the script finishes execution, the script stores the output to a file it
specifies at the end. The name of this file is based on the date and time
the script started execution.
......@@ -7,7 +7,7 @@
#
# date of creation:
#
# version: 1.0
# version: 1.1
#
# description:
# This script works in conjunction with the pulsetest (v15.15) FPGA gateware
......@@ -27,6 +27,8 @@
# source; if not, download it from http://www.gnu.org/licenses/lgpl-2.1.html
#===============================================================================
# last changes:
# 2014-07-02 Theodor Stana Setting the frequency to 0 Hz does not
# enable the channel
#===============================================================================
# TODO: -
#===============================================================================
......@@ -104,7 +106,7 @@ if __name__ == "__main__":
fwvers = testelma.read(slot, 0x04) & 0xFF
if ( bloid != 0x54424c4f ) or ( fwvers != 0xff ):
print "Wrong version number (0x%02x)" % fwvers
print("Wrong version number (0x%02x)" % fwvers)
sys.exit(1)
testelma.write(slot, CHENREG, 0x00);
......@@ -125,104 +127,95 @@ if __name__ == "__main__":
# Setup channel delays and frequencies
farr = [0,0,0,0,0,0]
inp = ""
while (inp != 'y') and (inp != 'n'):
inp = raw_input("Enable channel 1? (y/n) ")
print("")
if (inp == 'y'):
chen |= (1 << 0);
freq = input(" freq (Hz): ")
freq = input("CH1 freq (Hz): ")
if (freq == 0):
print(" CH1 not enabled")
else:
chen |= (1 << 0)
if (freq > MAXFREQ):
freq = MAXFREQ
print "Automatically setting channel frequency to %d Hz" % MAXFREQ
print(" Automatically setting channel frequency to %d Hz" % MAXFREQ)
farr[0] = freq
freq = 1/(freq * CTB_CLK_PER)
testelma.write(slot, C1FREQREG, int(freq))
#print freq
#print hex(int(freq))
inp = ""
while (inp != 'y') and (inp != 'n'):
inp = raw_input("Enable channel 2? (y/n) ")
if (inp == 'y'):
chen |= (1 << 1);
freq = input(" freq (Hz): ")
#print(freq)
#print(hex(int(freq)))
freq = input("CH2 freq (Hz): ")
if (freq == 0):
print(" CH2 not enabled")
else:
chen |= (1 << 1)
if (freq > MAXFREQ):
freq = MAXFREQ
print "Automatically setting channel frequency to %d Hz" % MAXFREQ
print(" Automatically setting channel frequency to %d Hz" % MAXFREQ)
farr[1] = freq
freq = 1/(freq * CTB_CLK_PER)
testelma.write(slot, C2FREQREG, int(freq))
#print freq
#print hex(int(freq))
inp = ""
while (inp != 'y') and (inp != 'n'):
inp = raw_input("Enable channel 3? (y/n) ")
if (inp == 'y'):
chen |= (1 << 2);
freq = input(" freq (Hz): ")
#print(freq)
#print(hex(int(freq)))
freq = input("CH3 freq (Hz): ")
if (freq == 0):
print(" CH3 not enabled")
else:
chen |= (1 << 2)
if (freq > MAXFREQ):
freq = MAXFREQ
print "Automatically setting channel frequency to %d Hz" % MAXFREQ
print(" Automatically setting channel frequency to %d Hz" % MAXFREQ)
farr[2] = freq
freq = 1/(freq * CTB_CLK_PER)
testelma.write(slot, C3FREQREG, int(freq))
#print freq
#print hex(int(freq))
inp = ""
while (inp != 'y') and (inp != 'n'):
inp = raw_input("Enable channel 4? (y/n) ")
if (inp == 'y'):
chen |= (1 << 3);
freq = input(" freq (Hz): ")
#print(freq)
#print(hex(int(freq)))
freq = input("CH4 freq (Hz): ")
if (freq == 0):
print(" CH4 not enabled")
else:
chen |= (1 << 3)
if (freq > MAXFREQ):
freq = MAXFREQ
print "Automatically setting channel frequency to %d Hz" % MAXFREQ
print(" Automatically setting channel frequency to %d Hz" % MAXFREQ)
farr[3] = freq
freq = 1/(freq * CTB_CLK_PER)
testelma.write(slot, C4FREQREG, int(freq))
#print freq
#print hex(int(freq))
#print(freq)
#print(hex(int(freq)))
inp = ""
while (inp != 'y') and (inp != 'n'):
inp = raw_input("Enable channel 5? (y/n) ")
if (inp == 'y'):
freq = input("CH5 freq (Hz): ")
if (freq == 0):
print(" CH5 not enabled")
else:
chen |= (1 << 4);
freq = input(" freq (Hz): ")
if (freq > MAXFREQ):
freq = MAXFREQ
print "Automatically setting channel frequency to %d Hz" % MAXFREQ
print(" Automatically setting channel frequency to %d Hz" % MAXFREQ)
farr[4] = freq
freq = 1/(freq * CTB_CLK_PER)
testelma.write(slot, C5FREQREG, int(freq))
#print freq
#print hex(int(freq))
inp = ""
while (inp != 'y') and (inp != 'n'):
inp = raw_input("Enable channel 6? (y/n) ")
#print(freq)
#print(hex(int(freq)))
if (inp == 'y'):
freq = input("CH6 freq (Hz): ")
if (freq == 0):
print(" CH6 not enabled")
else:
chen |= (1 << 5);
freq = input(" freq (Hz): ")
if (freq > MAXFREQ):
freq = MAXFREQ
print "Automatically setting channel frequency to %d" % MAXFREQ
print(" Automatically setting channel frequency to %d Hz" % MAXFREQ)
farr[5] = freq
freq = 1/(freq * CTB_CLK_PER)
testelma.write(slot, C6FREQREG, int(freq))
#print freq
#print hex(int(freq))
#print(freq)
#print(hex(int(freq)))
# Ask how long to run the test
print "How long would you like to run the test?"
print("")
print("How long would you like to run the test?")
while 1:
try:
hrs = raw_input(" hrs: ")
......@@ -233,7 +226,7 @@ if __name__ == "__main__":
except KeyboardInterrupt:
sys.exit()
except:
print " Hours must be a decimal number >= 0!"
print(" Hours must be a decimal number >= 0!")
while 1:
try:
......@@ -245,7 +238,7 @@ if __name__ == "__main__":
except KeyboardInterrupt:
sys.exit()
except:
print " Minutes must be a decimal number >= 0!"
print(" Minutes must be a decimal number >= 0!")
while 1:
try:
......@@ -257,7 +250,7 @@ if __name__ == "__main__":
except KeyboardInterrupt:
sys.exit()
except:
print " Seconds must be a decimal number >= 0!"
print(" Seconds must be a decimal number >= 0!")
# Compute test end time according to current time
#
......@@ -271,10 +264,10 @@ if __name__ == "__main__":
f = open(fname, "w")
# Write current time and start of test to output file
f.write("------------------------------------------------------------\r\n")
f.write("------------------------------------------------------------\n")
f.write("%s: starting test\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")
print("%s: starting test" % time.strftime("%Y-%m-%d-%Hh%Mm%Ss", time.localtime()))
f.write("------------------------------------------------------------\n")
# Enable the needed channels and start generating pulses
testelma.write(slot, CHENREG, chen)
......@@ -289,44 +282,44 @@ if __name__ == "__main__":
f.write("%s: ending test\n" % time.strftime("%Y-%m-%d-%Hh%Mm%Ss", time.localtime()))
print "%s: ending test" % time.strftime("%Y-%m-%d-%Hh%Mm%Ss", time.localtime())
f.write("------------------------------------------------------------\r\n")
print("%s: ending test" % time.strftime("%Y-%m-%d-%Hh%Mm%Ss", time.localtime()))
f.write("------------------------------------------------------------\n")
secs = int(end_time - start_time)
f.write("pulses sent and received:\n")
# Read counter registers
i = testelma.read(slot, C1IREG)
o = testelma.read(slot, C1OREG)
f.write("ch %d / i: %d / o: %d\n" % (1, i, o))
f.write("ch %d (f = %d) / i: %d / o: %d\n" % (1, farr[0], i, o))
i = testelma.read(slot, C2IREG)
o = testelma.read(slot, C2OREG)
f.write("ch %d / i: %d / o: %d\n" % (2, i, o))
f.write("ch %d (f = %d) / i: %d / o: %d\n" % (2, farr[1], i, o))
i = testelma.read(slot, C3IREG)
o = testelma.read(slot, C3OREG)
f.write("ch %d / i: %d / o: %d\n" % (3, i, o))
f.write("ch %d (f = %d) / i: %d / o: %d\n" % (3, farr[2], i, o))
i = testelma.read(slot, C4IREG)
o = testelma.read(slot, C4OREG)
f.write("ch %d / i: %d / o: %d\n" % (4, i, o))
f.write("ch %d (f = %d) / i: %d / o: %d\n" % (4, farr[3], i, o))
i = testelma.read(slot, C5IREG)
o = testelma.read(slot, C5OREG)
f.write("ch %d / i: %d / o: %d\n" % (5, i, o))
f.write("ch %d (f = %d) / i: %d / o: %d\n" % (5, farr[4], i, o))
i = testelma.read(slot, C6IREG)
o = testelma.read(slot, C6OREG)
f.write("ch %d / i: %d / o: %d\n" % (6, i, o))
f.write("ch %d (f = %d) / i: %d / o: %d\n" % (6, farr[5], i, o))
testelma.close()
f.write("------------------------------------------------------------\r\n")
f.write("------------------------------------------------------------\n")
# Close output file
f.close()
# Print output file name
print
print "Test results can be found in " + fname
print("")
print("Test results can be found in " + fname)
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