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
b17887c5
Commit
b17887c5
authored
May 29, 2012
by
Matthieu Cattin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test06: Uses common modules, added exception handling.
parent
05a3ec17
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
70 deletions
+105
-70
test06.py
test/fmcadc100m14b4cha/python/test06.py
+105
-70
No files found.
test/fmcadc100m14b4cha/python/test06.py
View file @
b17887c5
...
...
@@ -4,15 +4,28 @@
# Author: Matthieu Cattin <matthieu.cattin@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
# Last modifications: 23/5/2012
# Import system modules
import
sys
import
rr
import
time
import
os
# 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 specific modules
from
fmc_adc_spec
import
*
from
fmc_adc
import
*
import
fmc_adc
from
PAGE.Agilent33250A
import
*
from
PAGE.SineWaveform
import
*
...
...
@@ -22,76 +35,98 @@ test06: Test trigger input
Note: Requires test00.py to run first to load the firmware!
"""
USB_DEVICE
=
"/dev/ttyUSB0"
RS232_BAUD
=
57600
NB_CHANNELS
=
4
PRE_TRIG_SAMPLES
=
500
POST_TRIG_SAMPLES
=
500
NB_SHOTS
=
1
TIMEOUT
=
1
def
main
(
default_directory
=
'.'
):
"""
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);
"""
# Objects declaration
spec
=
rr
.
Gennum
()
# bind to the SPEC board
fmc
=
fmc_adc
.
CFmcAdc100Ms
(
spec
)
gen
=
Agilent33250A
(
device
=
USB_DEVICE
,
bauds
=
RS232_BAUD
)
sine
=
SineWaveform
()
# Set sine params
sine
.
frequency
=
1E3
sine
.
amplitude
=
1
sine
.
dc
=
0
# Set AWG and turn it ON
gen
.
connect
()
gen
.
output
=
True
gen
.
sync
=
True
gen
.
play
(
sine
)
# Disconnect all inputs
for
i
in
range
(
1
,
NB_CHANNELS
+
1
):
fmc
.
set_input_range
(
i
,
"OPEN"
)
# Set trigger
# hw trig, rising edge, external, sw disable, no delay
fmc
.
set_trig_config
(
1
,
0
,
1
,
1
,
0
,
0
,
0
)
# Set acquisition
fmc
.
set_pre_trig_samples
(
PRE_TRIG_SAMPLES
)
fmc
.
set_post_trig_samples
(
POST_TRIG_SAMPLES
)
fmc
.
set_shots
(
NB_SHOTS
)
# Start acquisition
fmc
.
stop_acq
()
print
(
'Acquisition FSM state :
%
s (should be IDLE)'
)
%
fmc
.
get_acq_fsm_state
()
fmc
.
start_acq
()
time
.
sleep
(
TIMEOUT
)
# Switch AWG OFF
gen
.
output
=
False
gen
.
sync
=
False
gen
.
close
()
# Check if the trigger has been received
if
(
'WAIT_TRIG'
==
fmc
.
get_acq_fsm_state
()):
print
(
'Acquisition FSM state :
%
s'
)
%
fmc
.
get_acq_fsm_state
()
raise
PtsError
(
'External trigger input is not working'
)
else
:
print
(
'The external trigger input is working fine.'
)
# Constants declaration
TEST_NB
=
6
EXPECTED_BITSTREAM_TYPE
=
0x1
USB_DEVICE
=
"/dev/ttyUSB0"
RS232_BAUD
=
57600
NB_CHANNELS
=
4
PRE_TRIG_SAMPLES
=
500
POST_TRIG_SAMPLES
=
500
NB_SHOTS
=
1
TIMEOUT
=
0.1
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
:
gen
=
Agilent33250A
(
device
=
USB_DEVICE
,
bauds
=
RS232_BAUD
)
sine
=
SineWaveform
()
# Set sine params
sine
.
frequency
=
1E3
sine
.
amplitude
=
1
sine
.
dc
=
0
# Set AWG and turn it ON
gen
.
connect
()
gen
.
output
=
True
gen
.
sync
=
True
gen
.
play
(
sine
)
# Disconnect all inputs
for
i
in
range
(
1
,
NB_CHANNELS
+
1
):
fmc
.
set_input_range
(
i
,
"OPEN"
)
# Set trigger
# hw trig, rising edge, external, sw disable, no delay
fmc
.
set_trig_config
(
1
,
0
,
1
,
1
,
1
,
0
,
0
)
# Set acquisition
fmc
.
set_pre_trig_samples
(
PRE_TRIG_SAMPLES
)
fmc
.
set_post_trig_samples
(
POST_TRIG_SAMPLES
)
fmc
.
set_shots
(
NB_SHOTS
)
# Start acquisition
fmc
.
stop_acq
()
print
"Acquisition FSM state :
%
s (should be IDLE)"
%
fmc
.
get_acq_fsm_state
()
fmc
.
start_acq
()
print
"Wait for trigger."
time
.
sleep
(
TIMEOUT
)
# Switch AWG OFF
gen
.
output
=
False
gen
.
sync
=
False
gen
.
close
()
# Check if the trigger has been received
if
(
'WAIT_TRIG'
==
fmc
.
get_acq_fsm_state
()):
print
"Acquisition FSM state :
%
s"
%
fmc
.
get_acq_fsm_state
()
raise
PtsError
(
'External trigger input is not working.'
)
else
:
print
"The external trigger input is working fine."
except
FmcAdc100mOperationError
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__'
:
...
...
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