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
ffab720b
Commit
ffab720b
authored
Aug 23, 2021
by
Gijs Schoonderbeek
Browse files
Options
Downloads
Patches
Plain Diff
Added script reading Voltage sensor
parent
c2de62f0
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
APSCT_CLK_I2C.py
+38
-0
38 additions, 0 deletions
APSCT_CLK_I2C.py
with
38 additions
and
0 deletions
APSCT_CLK_I2C.py
+
38
−
0
View file @
ffab720b
...
...
@@ -31,6 +31,7 @@ READ_LOCK = True
READ_ALL
=
False
CHECK_EEPROM
=
True
PWR_RST
=
True
READ_SENSOR
=
True
CLK_FREQ
=
'
200MHz
'
dev_i2c_eeprom
=
I2C
(
0x50
)
...
...
@@ -203,6 +204,41 @@ def wr_rd_eeprom(value=0x34):
print
(
stri
)
return
True
def
apsct_sensors
():
addr
=
0x74
Vref
=
3.0
one_step
=
Vref
/
(
2
**
(
16
+
1
))
I2C_device
=
I2C
(
addr
,
BUSNR
=
I2CBUSNR
)
I2C_device
.
write_bytes
(
0xB8
,
0xB0
)
sleep
(
1
)
ret_ack
,
ret_value
=
I2C_device
.
read_last_reg
(
3
)
if
ret_ack
:
stri
=
"
Return value input 0 : 0x{0}
"
.
format
(
ret_value
)
print
(
stri
)
if
int
(
ret_value
,
16
)
>=
0xC00000
:
print
(
"
over range
"
)
else
:
steps
=
(
int
(
ret_value
,
16
)
&
0x1FFFFF
)
>>
6
voltage
=
one_step
*
steps
string
=
"
Voltage is {0:.4f}
"
.
format
(
voltage
)
print
(
string
)
else
:
print
(
"
ACK nok
"
)
sleep
(
1
)
temp_slope
=
93.5E-6
*
2
**
(
16
+
1
)
/
Vref
I2C_device
.
write_bytes
(
0xA0
,
0xE0
)
sleep
(
1
)
ret_ack
,
ret_value
=
I2C_device
.
read_last_reg
(
3
)
if
ret_ack
:
raw_value
=
(
int
(
ret_value
,
16
)
&
0x1FFFFF
)
>>
6
temperature_K
=
(
raw_value
/
temp_slope
)
temperature
=
temperature_K
-
273
stri
=
"
Return value : 0x{0} Temperature : {1:.2f} gr. C
"
.
format
(
ret_value
,
temperature
)
print
(
stri
)
else
:
print
(
"
ACK nok
"
)
if
CHECK_EEPROM
:
wr_rd_eeprom
()
...
...
@@ -228,3 +264,5 @@ if READ_LOCK:
else
:
print
(
"
Not locked --> PLL Error
"
)
if
READ_SENSOR
:
apsct_sensors
()
\ No newline at end of file
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