Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
pts
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
misc
pts
Commits
b850a594
Commit
b850a594
authored
Feb 03, 2012
by
Matthieu Cattin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test22 to repdo, temperature measurment.
parent
d2edb4c4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
0 deletions
+99
-0
test22.py
test/fmcadc100m14b4cha/python/test22.py
+99
-0
No files found.
test/fmcadc100m14b4cha/python/test22.py
0 → 100755
View file @
b850a594
#! /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
ptsexcept
import
*
import
csr
import
fmc_adc
import
spec_fmc_adc
"""
test13: Test FMC temperature stability
"""
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
main
(
default_directory
=
'.'
):
# Load firmware
load_firmware
(
default_directory
)
# Objects declaration
spec
=
rr
.
Gennum
()
# bind to the SPEC board
fmc
=
fmc_adc
.
CFmcAdc100Ms
(
spec
)
spec_fmc
=
spec_fmc_adc
.
CSpecFmcAdc100Ms
(
spec
)
# Read SPEC unique ID and print to log
spec_unique_id
=
spec_fmc
.
get_unique_id
()
if
(
spec_unique_id
==
-
1
):
raise
PtsError
(
"Can't read DS18D20 1-wire thermometer on SPEC board."
)
else
:
print
(
'SPEC Unique ID:
%.12
X'
)
%
spec_unique_id
# Read FMC unique ID and print to log
fmc_unique_id
=
fmc
.
get_unique_id
()
if
(
fmc_unique_id
==
-
1
):
raise
PtsError
(
"Can't read DS18D20 1-wire thermometer on SPEC board."
)
else
:
print
(
'FMC Unique ID:
%.12
X'
)
%
fmc_unique_id
# Read SPEC temperature and print to log
spec_temp
=
[]
spec_temp
.
append
(
spec_fmc
.
get_temp
())
print
(
'SPEC temperature:
%3.3
f°C'
)
%
spec_temp
[
-
1
]
# Read FMC temperature and print to log
fmc_temp
=
[]
fmc_temp
.
append
(
fmc
.
get_temp
())
print
(
'FMC temperature:
%3.3
f°C'
)
%
fmc_temp
[
-
1
]
fmc_temp_sum
=
0
fmc_temp_cnt
=
0
MAX_DIFF
=
0.2
start_time
=
int
(
time
.
time
())
while
True
:
#spec_temp.append(spec_fmc.get_temp())
fmc_temp
.
append
(
fmc
.
get_temp
())
fmc_temp_cnt
+=
1
if
fmc_temp_cnt
<
50
:
fmc_temp_sum
+=
fmc_temp
[
-
1
]
fmc_temp_avg
=
(
fmc_temp_sum
/
fmc_temp_cnt
)
else
:
fmc_temp_sum
=
sum
(
fmc_temp
[
-
50
:])
fmc_temp_avg
=
(
fmc_temp_sum
/
50
)
temp_diff
=
abs
(
fmc_temp_avg
-
fmc_temp
[
-
1
])
print
"
%4
d fmc temp:
%3.3
f°C average:
%3.3
f°C temp diff:
%3.3
f°C"
%
(
fmc_temp_cnt
,
fmc_temp
[
-
1
],
fmc_temp_avg
,
temp_diff
)
if
fmc_temp_cnt
>
20
:
if
temp_diff
<
MAX_DIFF
:
pass
#break
time
.
sleep
(
2
)
end_time
=
int
(
time
.
time
())
time_diff
=
end_time
-
start_time
print
"FMC temperature is stable after
%
ds"
%
time_diff
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