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
079cb6ee
Commit
079cb6ee
authored
Jan 11, 2012
by
Matthieu Cattin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modifications for two's complement ADC data. Display in volts.
parent
da09d702
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletion
+18
-1
fmc_adc_demo.py
test/fmcadc100m14b4cha/python/fmc_adc_demo.py
+18
-1
No files found.
test/fmcadc100m14b4cha/python/fmc_adc_demo.py
View file @
079cb6ee
...
...
@@ -26,6 +26,9 @@ from PAGE.SineWaveform import *
# Constants declaration
NB_POINTS
=
1000
ADC_NBITS
=
16
# ADC chip is 14 bits, but shifted to 16 bits in the firmware
ADC_FS
=
10.0
USB_DEVICE
=
"/dev/ttyUSB0"
RS232_BAUD
=
57600
...
...
@@ -42,6 +45,17 @@ def bit2string(bit):
else
:
return
'NO'
# Converts two's complement hex to signed
def
hex2signed
(
value
):
if
(
value
&
0x8000
):
return
-
((
~
value
&
0xFFFF
)
+
1
)
else
:
return
value
# Converts digital value to volts
def
digital2volt
(
value
,
full_scale
,
nb_bit
):
return
float
(
value
)
*
float
(
full_scale
)
/
2
**
nb_bit
def
acq_plot
():
if
(
1
==
m
.
nb_shot
.
value
()):
trig_pos
=
fmc
.
get_trig_pos
()
...
...
@@ -55,6 +69,9 @@ def acq_plot():
print
(
'Multi-shot acq'
)
channels_data
=
spec_fmc
.
get_data
(
0
,
(
NB_POINTS
*
8
))
channels_data
=
[
hex2signed
(
item
)
for
item
in
channels_data
]
channels_data
=
[
digital2volt
(
item
,
ADC_FS
,
ADC_NBITS
)
for
item
in
channels_data
]
#channels_data = spec_fmc.get_data(0, (NB_POINTS*8))
print
(
'Nb points:
%
d'
)
%
NB_POINTS
print
(
'channels data length:
%
d'
)
%
len
(
channels_data
)
...
...
@@ -65,7 +82,7 @@ def acq_plot():
m
.
mpl_acq
.
canvas
.
ax
.
plot
(
sample
,
channels_data
[
2
::
4
],
'r'
,
label
=
'Channel 3'
)
m
.
mpl_acq
.
canvas
.
ax
.
plot
(
sample
,
channels_data
[
3
::
4
],
'c'
,
label
=
'Channel 4'
)
m
.
mpl_acq
.
canvas
.
ax
.
set_xlim
(
0
,
NB_POINTS
)
m
.
mpl_acq
.
canvas
.
ax
.
set_ylim
(
0
,
65535
)
m
.
mpl_acq
.
canvas
.
ax
.
set_ylim
(
-
(
ADC_FS
/
2
)
-
(
ADC_FS
/
10
),
(
ADC_FS
/
2
)
+
(
ADC_FS
/
10
)
)
m
.
mpl_acq
.
canvas
.
ax
.
legend
()
m
.
mpl_acq
.
canvas
.
draw
()
...
...
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