Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC ADC 100M 14b 4cha - Testing
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC ADC 100M 14b 4cha - Testing
Commits
c0bc2bce
Commit
c0bc2bce
authored
May 30, 2012
by
Matthieu Cattin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test09: Uses common modules, added exception handling.
parent
0e3345e7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
161 additions
and
131 deletions
+161
-131
test09.py
test/fmcadc100m14b4cha/python/test09.py
+161
-131
No files found.
test/fmcadc100m14b4cha/python/test09.py
View file @
c0bc2bce
...
...
@@ -5,19 +5,28 @@
# Author: Matthieu Cattin <matthieu.cattin@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
# Last modifications: 30/5/2012
# Import system modules
import
sys
import
rr
import
time
import
os
from
numpy
import
*
from
pylab
import
*
# Add common modules and libraries location to path
sys
.
path
.
append
(
'../../../'
)
sys
.
path
.
append
(
'../../../gnurabbit/python/'
)
sys
.
path
.
append
(
'../../../common/'
)
# Import common modules
from
ptsexcept
import
*
import
rr
import
spec_fmc_adc
import
fmc_adc
import
calibr_box
# Import specific modules
from
fmc_adc_spec
import
*
from
fmc_adc
import
*
from
numpy
import
*
from
pylab
import
*
from
calibr_box
import
*
import
find_usb_tty
from
PAGE.Agilent33250A
import
*
from
PAGE.SineWaveform
import
*
...
...
@@ -30,15 +39,6 @@ test09: Test analogue front-end frequency response,
Note: Requires test00.py to run first to load the firmware!
"""
# Calibration box vendor and product IDs
BOX_USB_VENDOR_ID
=
0x10c4
# Cygnal Integrated Products, Inc.
BOX_USB_PRODUCT_ID
=
0xea60
# CP210x Composite Device
# Agilent AWG serial access vendor and product IDs
AWG_USB_VENDOR_ID
=
0x0403
# Future Technology Devices International, Ltd
AWG_USB_PRODUCT_ID
=
0x6001
# FT232 USB-Serial (UART) IC
AWG_BAUD
=
57600
NB_CHANNELS
=
4
AWG_SET_SLEEP
=
0.3
...
...
@@ -85,16 +85,6 @@ points = [[10E3 , 0 , 1],
[
80E6
,
-
66
,
3
]]
def
load_firmware
(
default_directory
):
print
(
'Load firmware to FPGA'
)
path_fpga_loader
=
'../../../gnurabbit/user/fpga_loader'
;
path_firmware
=
'../firmwares/spec_fmcadc100m14b4cha.bin'
;
firmware_loader
=
os
.
path
.
join
(
default_directory
,
path_fpga_loader
)
bitstream
=
os
.
path
.
join
(
default_directory
,
path_firmware
)
print
firmware_loader
+
' '
+
bitstream
os
.
system
(
firmware_loader
+
' '
+
bitstream
)
time
.
sleep
(
2
);
def
open_all_channels
(
fmc
):
for
i
in
range
(
1
,
NB_CHANNELS
+
1
):
fmc
.
set_input_range
(
i
,
'OPEN'
)
...
...
@@ -132,7 +122,7 @@ def hex2signed(value):
def
digital2volt
(
value
,
full_scale
,
nb_bit
):
return
float
(
value
)
*
float
(
full_scale
)
/
2
**
nb_bit
def
acq_channels
(
fmc
,
spec_fmc
):
def
acq_channels
(
fmc
,
carrier
):
# Make sure no acquisition is running
fmc
.
stop_acq
()
# Start acquisition
...
...
@@ -152,11 +142,11 @@ def acq_channels(fmc, spec_fmc):
# Retrieve data trough DMA
trig_pos
=
fmc
.
get_trig_pos
()
# Enable "DMA done" iinterrupt
spec_fmc
.
set_irq_en_mask
(
0x1
)
carrier
.
set_irq_en_mask
(
0x1
)
# Read ACQ_LENGTH samples after the trigger for all channels
channels_data
=
spec_fmc
.
get_data
((
trig_pos
<<
3
),
ACQ_LENGTH
*
8
)
channels_data
=
carrier
.
get_data
((
trig_pos
<<
3
),
ACQ_LENGTH
*
8
)
# Disable "DMA done" iinterrupt
spec_fmc
.
set_irq_en_mask
(
0x0
)
carrier
.
set_irq_en_mask
(
0x0
)
channels_data
=
[
hex2signed
(
item
)
for
item
in
channels_data
]
channels_data
=
[
digital2volt
(
item
,
1.0
,
16
)
for
item
in
channels_data
]
return
channels_data
...
...
@@ -182,19 +172,49 @@ def show_result_graph(points, ch_att):
def
main
(
default_directory
=
'.'
):
# Load firmware
#load_firmware(default_directory)
# Constants declaration
TEST_NB
=
9
EXPECTED_BITSTREAM_TYPE
=
0x1
# Objects declaration
spec
=
rr
.
Gennum
()
# bind to the SPEC board
spec_fmc
=
spec_fmc_adc
.
CSpecFmcAdc100Ms
(
spec
)
fmc
=
fmc_adc
.
CFmcAdc100Ms
(
spec
)
# Calibration box vendor and product IDs
BOX_USB_VENDOR_ID
=
0x10c4
# Cygnal Integrated Products, Inc.
BOX_USB_PRODUCT_ID
=
0xea60
# CP210x Composite Device
# Agilent AWG serial access vendor and product IDs
AWG_USB_VENDOR_ID
=
0x0403
# Future Technology Devices International, Ltd
AWG_USB_PRODUCT_ID
=
0x6001
# FT232 USB-Serial (UART) IC
AWG_BAUD
=
57600
start_test_time
=
time
.
time
()
print
"================================================================================"
print
"Test
%02
d start
\n
"
%
TEST_NB
# SPEC object declaration
print
"Loading hardware access library and opening device.
\n
"
spec
=
rr
.
Gennum
()
# Carrier object declaration (SPEC board specific part)
# Used to check that the firmware is loaded.
try
:
carrier
=
CFmcAdc100mSpec
(
spec
,
EXPECTED_BITSTREAM_TYPE
)
except
FmcAdc100mSpecOperationError
as
e
:
raise
PtsCritical
(
"Carrier init failed, test stopped:
%
s"
%
e
)
# Mezzanine object declaration (FmcAdc100m14b4cha board specific part)
try
:
fmc
=
CFmcAdc100m
(
spec
)
except
FmcAdc100mOperationError
as
e
:
raise
PtsCritical
(
"Mezzanine init failed, test stopped:
%
s"
%
e
)
try
:
# Others objects declaration
usb_tty
=
find_usb_tty
.
CttyUSB
()
awg_tty
=
usb_tty
.
find_usb_tty
(
AWG_USB_VENDOR_ID
,
AWG_USB_PRODUCT_ID
)
box_tty
=
usb_tty
.
find_usb_tty
(
BOX_USB_VENDOR_ID
,
BOX_USB_PRODUCT_ID
)
gen
=
Agilent33250A
(
device
=
awg_tty
[
0
],
bauds
=
AWG_BAUD
)
sine
=
SineWaveform
()
box
=
calibr_box
.
CCalibr_box
(
box_tty
[
0
])
box
=
CCalibr_box
(
box_tty
[
0
])
# Initialise fmc adc
fmc_adc_init
(
spec
,
fmc
)
...
...
@@ -203,7 +223,7 @@ def main (default_directory='.'):
sine
.
frequency
=
1E6
sine
.
amplitude
=
0.8
sine
.
dc
=
0
#
print('Sine frequency:%3.3fMHz amplitude:%2.3fVp offset:%2.3fV')%(sine.frequency/1E6, sine.amplitude, sine.dc)
#
print('Sine frequency:%3.3fMHz amplitude:%2.3fVp offset:%2.3fV')%(sine.frequency/1E6, sine.amplitude, sine.dc)
# Set AWG
gen
.
connect
()
...
...
@@ -222,7 +242,7 @@ def main (default_directory='.'):
for
j
in
range
(
len
(
points
)):
set_awg_freq
(
gen
,
sine
,
points
[
j
][
0
])
channel_data
=
[]
channels_data
=
acq_channels
(
fmc
,
spec_fmc
)
channels_data
=
acq_channels
(
fmc
,
carrier
)
channel_data
=
channels_data
[
i
-
1
::
4
]
ampl
=
max
(
channel_data
)
-
min
(
channel_data
)
print
"CH
%
d frequency:
%8.0
f Hz amplitude:
%
f V"
%
(
i
,
points
[
j
][
0
],
ampl
)
...
...
@@ -246,7 +266,7 @@ def main (default_directory='.'):
print
"Channel
%
d frequency response is out of range at freq:
%2.3
fMHz"
%
(
ch
+
1
,
points
[
i
][
0
]
/
1E6
)
print
"Attenuation:
%3.3
fdB, expected:
%2.1
f +/-
%2.1
fdB"
%
(
ch_att
[
ch
][
i
],
points
[
i
][
1
],
points
[
i
][
2
])
error
+=
1
#
raise PtsError('Channel %d frequency response is out of range at freq:%2.3fMHz'%(i, points[j][0]/1E6))
#
raise PtsError('Channel %d frequency response is out of range at freq:%2.3fMHz'%(i, points[j][0]/1E6))
if
error
==
0
:
print
"OK!"
...
...
@@ -278,7 +298,7 @@ def main (default_directory='.'):
f
.
close
()
# Plot results -> use test10.py to plot the results!
#
show_result_graph(points, ch_att)
#
show_result_graph(points, ch_att)
# Make sure all switches are OFF
open_all_channels
(
fmc
)
...
...
@@ -291,6 +311,16 @@ def main (default_directory='.'):
if
(
error
!=
0
):
raise
PtsError
(
'An error occured during frequency response test, check log for details.'
)
except
(
FmcAdc100mSpecOperationError
,
FmcAdc100mOperationError
,
CalibrBoxOperationError
)
as
e
:
raise
PtsError
(
"Test failed:
%
s"
%
e
)
print
""
print
"==> End of test
%02
d"
%
TEST_NB
print
"================================================================================"
end_test_time
=
time
.
time
()
print
"Test
%02
d elapsed time:
%.2
f seconds
\n
"
%
(
TEST_NB
,
end_test_time
-
start_test_time
)
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment