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
f1343b17
Commit
f1343b17
authored
Dec 08, 2011
by
Matthieu Cattin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test18, calibration box test.
parent
218df425
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
212 additions
and
0 deletions
+212
-0
calibr_box.py
test/fmcadc100m14b4cha/python/calibr_box.py
+44
-0
cp210x.py
test/fmcadc100m14b4cha/python/cp210x.py
+33
-0
test18.py
test/fmcadc100m14b4cha/python/test18.py
+135
-0
No files found.
test/fmcadc100m14b4cha/python/calibr_box.py
0 → 100644
View file @
f1343b17
#! /usr/bin/env python
# coding: utf8
# Copyright CERN, 2011
# Author: Matthieu Cattin <matthieu.cattin@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
import
sys
import
rr
import
time
import
os
import
cp210x
from
PAGE.Agilent33250A
import
*
from
PAGE.SineWaveform
import
*
"""
calibr_box: Access to calibration box via USB-UART bridge CP2103
"""
class
CCalibr_box
:
def
__init__
(
self
,
dev_num
):
self
.
cp210x
=
cp210x
.
CCP210x
(
dev_num
)
# Select AWG as default output
self
.
cp210x
.
gpio_set
(
0x0
)
def
select_output
(
self
,
out
):
if
(
'10V'
==
out
):
self
.
cp210x
.
gpio_set
(
0xF
)
elif
(
'1V'
==
out
):
self
.
cp210x
.
gpio_set
(
0xD
)
elif
(
'100mV'
==
out
):
self
.
cp210x
.
gpio_set
(
0xC
)
elif
(
'AWG'
==
out
):
self
.
cp210x
.
gpio_set
(
0x0
)
else
:
raise
Exception
(
'Invalid output selection!'
)
def
get_config
(
self
):
return
self
.
cp210x
.
gpio_get
()
test/fmcadc100m14b4cha/python/cp210x.py
0 → 100644
View file @
f1343b17
#! /usr/bin/env python
# coding: utf8
import
fcntl
,
struct
,
termios
,
os
import
time
import
array
class
CCP210x
:
def
__init__
(
self
,
usb_number
):
self
.
fd
=
open
(
'/dev/ttyUSB'
+
str
(
usb_number
),
'wb'
)
def
gpio_set
(
self
,
mask
):
fcntl
.
ioctl
(
self
.
fd
.
fileno
(),
0x8001
,
mask
)
def
gpio_get
(
self
):
f
=
array
.
array
(
'I'
,
[
0
])
ret
=
fcntl
.
ioctl
(
self
.
fd
.
fileno
(),
0x8000
,
f
,
1
)
return
f
[
0
]
# Create an object (the 0 is used to generate the name, eg. /dev/ttyUSB0
#gpio = cp210x_gpio(0)
# Infinite test loop
#while 1:
# # Pass the mask of the 4 bits as a hex number
# gpio.gpio_set(0xf)
# # Returns the states of the 4 bits as hex number
# print gpio.gpio_get()
# time.sleep(1)
# gpio.gpio_set(0x0)
# print gpio.gpio_get()
# time.sleep(1)
test/fmcadc100m14b4cha/python/test18.py
0 → 100755
View file @
f1343b17
#! /usr/bin/env python
# coding: utf8
# Copyright CERN, 2011
# Author: Matthieu Cattin <matthieu.cattin@cern.ch>
# Licence: GPL v2 or later.
# Website: http://www.ohwr.org
import
sys
import
rr
import
time
import
os
from
numpy
import
*
from
pylab
import
*
from
ptsexcept
import
*
import
spec_fmc_adc
import
fmc_adc
import
calibr_box
from
PAGE.Agilent33250A
import
*
from
PAGE.SineWaveform
import
*
"""
test18: Test calibration box
Note: Requires test00.py to run first to load the firmware!
"""
USB_DEVICE
=
"/dev/ttyUSB0"
RS232_BAUD
=
57600
NB_CHANNELS
=
4
AWG_SET_SLEEP
=
1
SSR_SET_SLEEP
=
0.05
ACQ_TIMEOUT
=
10
MAX_FIRMWARE_RELOAD
=
10
PRE_TRIG_SAMPLES
=
10
POST_TRIG_SAMPLES
=
1000
NB_SHOTS
=
1
ACQ_LENGTH
=
1
# in samples
DMA_LENGTH
=
4096
# in bytes
def
load_firmware
(
default_directory
):
print
(
'Load firmware to FPGA'
)
path_fpga_loader
=
'../../../gnurabbit/user/fpga_loader'
;
path_firmware
=
'../firmwares/spec_fmcadc100m14b4cha_test.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
disconnect_channels
(
fmc
):
for
i
in
range
(
1
,
NB_CHANNELS
+
1
):
fmc
.
set_input_range
(
i
,
'OPEN'
)
time
.
sleep
(
SSR_SET_SLEEP
)
def
fmc_adc_init
(
spec
,
fmc
):
print
(
'Initialise FMC board.'
)
fmc
.
__init__
(
spec
)
# Reset offset DACs
fmc
.
dc_offset_reset
()
# Make sure all switches are OFF
disconnect_channels
(
fmc
)
# Set trigger
fmc
.
set_soft_trig
()
# Set acquisition
fmc
.
set_pre_trig_samples
(
PRE_TRIG_SAMPLES
)
fmc
.
set_post_trig_samples
(
POST_TRIG_SAMPLES
)
fmc
.
set_shots
(
NB_SHOTS
)
# Print configuration
#fmc.print_adc_core_config()
def
set_awg_freq
(
gen
,
sine
,
freq
):
sine
.
frequency
=
freq
gen
.
play
(
sine
)
print
(
'Sine frequency:
%3.3
fMHz'
)
%
(
sine
.
frequency
/
1E6
)
time
.
sleep
(
AWG_SET_SLEEP
)
def
main
(
default_directory
=
'.'
):
# Load firmware to FPGA
load_firmware
(
default_directory
)
# Objects declaration
spec
=
rr
.
Gennum
()
# bind to the SPEC board
spec_fmc
=
spec_fmc_adc
.
CSpecFmcAdc100Ms
(
spec
)
fmc
=
fmc_adc
.
CFmcAdc100Ms
(
spec
)
gen
=
Agilent33250A
(
device
=
USB_DEVICE
,
bauds
=
RS232_BAUD
)
sine
=
SineWaveform
()
box
=
calibr_box
.
CCalibr_box
(
1
)
# Enable "DMA finished" IRQ
spec_fmc
.
set_irq_en_mask
(
0x1
)
# Initialise fmc adc
fmc_adc_init
(
spec
,
fmc
)
# Disconnect all inputs
disconnect_channels
(
fmc
)
# Test calibration box ranges
print
(
'
\n
=== 10V range ==='
)
box
.
select_output
(
'10V'
)
print
(
'Box gpio:
%
X'
)
%
box
.
get_config
()
raw_input
(
'Press ENTER to continue...'
)
print
(
'
\n
=== 1V range ==='
)
box
.
select_output
(
'1V'
)
print
(
'Box gpio:
%
X'
)
%
box
.
get_config
()
raw_input
(
'Press ENTER to continue...'
)
print
(
'
\n
=== 100mV range ==='
)
box
.
select_output
(
'100mV'
)
print
(
'Box gpio:
%
X'
)
%
box
.
get_config
()
raw_input
(
'Press ENTER to continue...'
)
print
(
'
\n
=== AWG ==='
)
box
.
select_output
(
'AWG'
)
print
(
'Box gpio:
%
X'
)
%
box
.
get_config
()
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