Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
python_test_scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
python_test_scripts
Commits
37bef031
Commit
37bef031
authored
3 years ago
by
Gijs Schoonderbeek
Browse files
Options
Downloads
Patches
Plain Diff
Added fan control on CCD
parent
b33fb937
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
CCD_I2C.py
+58
-34
58 additions, 34 deletions
CCD_I2C.py
with
58 additions
and
34 deletions
CCD_I2C.py
+
58
−
34
View file @
37bef031
...
...
@@ -16,6 +16,7 @@ Set CCD
'''
import
sys
import
time
import
math
sys
.
path
.
insert
(
0
,
'
.
'
)
import
os
if
os
.
name
==
"
posix
"
:
...
...
@@ -32,7 +33,7 @@ READ_ALL = False
CHECK_EEPROM
=
True
PWR_RST
=
False
READ_SENSOR
=
False
READ_SET_FAN
=
True
CLK_FREQ
=
'
200MHz
'
dev_i2c_eeprom
=
I2C
(
0x50
)
dev_i2c_eeprom
.
bus_nr
=
I2CBUSNR
...
...
@@ -251,39 +252,57 @@ def read_temp():
else
:
print
(
"
Error reading tempeature
"
)
def
set_fan_off
():
#
# Switch CCD fan off
#
print
(
"
Switch fan off
"
)
MAX6620
=
0x29
fanmonitor_dev
=
I2C
(
MAX6620
)
fanmonitor_dev
.
bus_nr
=
3
fanmonitor_dev
.
write_bytes
(
0x00
,
0x10
)
fanmonitor_dev
.
write_bytes
(
0x02
,
0x08
)
fanmonitor_dev
.
write_bytes
(
0x28
,
0x00
)
fanmonitor_dev
.
write_bytes
(
0x29
,
0x00
)
def
set_fan_speed
(
speed
):
#
# Set control voltage of fan PNP
#
stri
=
"
Set fan to {} %
"
.
format
(
speed
)
print
(
stri
)
MAX6620
=
0x29
reg_a
=
((
0xFF
*
speed
)
/
100
)
&
0xFF
fanmonitor_dev
=
I2C
(
MAX6620
)
fanmonitor_dev
.
bus_nr
=
3
fanmonitor_dev
.
write_bytes
(
0x00
,
0x00
)
fanmonitor_dev
.
write_bytes
(
0x02
,
0x08
)
fanmonitor_dev
.
write_bytes
(
0x01
,
0x0F
)
fanmonitor_dev
.
write_bytes
(
0x06
,
0x60
)
fanmonitor_dev
.
write_bytes
(
0x28
,
reg_a
)
fanmonitor_dev
.
write_bytes
(
0x29
,
0x80
)
def
read_tacho
():
MAX6620
=
0x52
REG_GLOBAL
=
0x00
#
# Read the fan speed
#
MAX6620
=
0x29
REG_TACH_MSP_REGS
=
[
0x10
,
0x12
,
0x14
]
REG_TACH_LSP_REGS
=
[
0x11
,
0x13
,
0x15
]
TACH_PERIODS
=
16
TACH_COUNT_FREQ
=
8192
FAN_TACHS
=
1
RUN_MONITOR
=
0x02
NOF_APS_FANS
=
3
DEBUG
=
1
fanmonitor_dev
=
I2C
(
MAX6620
)
fanmonitor_dev
.
bus_nr
=
I2CBUSNR
fanmonitor_dev
.
bus_nr
=
3
fan_nr
=
0
ret_ack
,
ret_value
=
fanmonitor_dev
.
read_bytes
(
1
)
if
ret_ack
<
1
:
stri
=
"
Device {0} at address 0x{1:X} not found
"
.
format
(
"
MAX6620
"
,
MAX6620
)
print
(
stri
)
status
=
False
else
:
if
DEBUG
:
stri
=
"
Device {0} at address 0x{1:X} is found
"
.
format
(
"
MAX6620
"
,
MAX6620
)
print
(
stri
)
ret_ack
,
reg_before
=
fanmonitor_dev
.
read_bytes
(
REG_GLOBAL
,
1
)
fanmonitor_dev
.
write_bytes
(
REG_GLOBAL
,
RUN_MONITOR
)
ret_ack
,
reg_after
=
fanmonitor_dev
.
read_bytes
(
REG_GLOBAL
,
1
)
if
DEBUG
:
stri
=
"
Reg at address 0x{0} before : {1} and after write action {2}
"
.
format
(
REG_GLOBAL
,
reg_before
,
reg_after
)
print
(
stri
)
fan_config_reg
=
int
((
math
.
log
(
TACH_PERIODS
)
/
math
.
log
(
2
)))
<<
5
for
fan_cnt
in
range
(
NOF_APS_FANS
):
fanmonitor_dev
.
write_bytes
(
0x02
+
fan_cnt
,
0x88
)
fanmonitor_dev
.
write_bytes
(
0x06
+
fan_cnt
,
fan_config_reg
)
ret_ack
,
tach_msb
=
fanmonitor_dev
.
read_bytes
(
REG_TACH_MSP_REGS
[
fan_nr
],
1
)
ret_ack
,
tach_msb
=
fanmonitor_dev
.
read_bytes
(
REG_TACH_MSP_REGS
[
0
],
1
)
tach_msb
=
int
(
tach_msb
,
16
)
&
0xFF
if
tach_msb
>
254
:
if
DEBUG
:
...
...
@@ -291,12 +310,12 @@ def read_tacho():
tach
=
99999
rpm
=
0
else
:
ret_ack
,
tach_lsb
=
fanmonitor_dev
.
read_bytes
(
REG_TACH_LSP_REGS
[
fan_nr
],
1
)
ret_ack
,
tach_lsb
=
fanmonitor_dev
.
read_bytes
(
REG_TACH_LSP_REGS
[
0
],
1
)
tach_lsb
=
int
(
tach_lsb
,
16
)
&
0xE0
tach
=
tach_msb
*
16
+
tach_lsb
/
8
rpm
=
float
((
TACH_COUNT_FREQ
*
TACH_PERIODS
*
60
))
/
(
FAN_TACHS
*
tach
)
if
DEBUG
:
stri
=
"
MSP: {0}, LSB: {1}, TACH : {2}
"
.
format
(
tach_msb
,
tach_lsb
,
tach
)
stri
=
"
MSP: {0}, LSB: {1}, TACH : {2}
, RPM : {3:6.2f}
"
.
format
(
tach_msb
,
tach_lsb
,
tach
,
rpm
)
print
(
stri
)
if
CHECK_EEPROM
:
...
...
@@ -319,7 +338,12 @@ if READ_LOCK:
print
(
"
Not Locked --> No 10 MHz ref
"
)
else
:
print
(
"
Not locked --> PLL Error
"
)
if
READ_SET_FAN
:
read_tacho
()
set_fan_off
()
sleep
(
10
)
set_fan_speed
(
75
)
sleep
(
10
)
read_tacho
()
if
READ_SENSOR
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment