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
8694859a
Commit
8694859a
authored
2 years ago
by
Gijs Schoonderbeek
Browse files
Options
Downloads
Patches
Plain Diff
Modificatino during test esp. voltage sensor
parent
7bd98cee
No related branches found
No related tags found
1 merge request
!3
Apsct production
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
I2C_serial_pi.py
+4
-4
4 additions, 4 deletions
I2C_serial_pi.py
apsct_lib.py
+19
-13
19 additions, 13 deletions
apsct_lib.py
with
23 additions
and
17 deletions
I2C_serial_pi.py
+
4
−
4
View file @
8694859a
...
...
@@ -55,7 +55,7 @@ class I2C:
return
ret_ack
,
ret_value
def
read_last_reg
(
self
,
bytes_to_read
):
def
read_last_reg
(
self
,
bytes_to_read
,
print_on
=
DEBUG
):
bus
=
smbus
.
SMBus
(
self
.
bus_nr
)
rd_value
=
[]
ret_value
=
''
...
...
@@ -68,12 +68,12 @@ class I2C:
except
IOError
:
ret_ack
=
0
rd_value
.
append
(
0
)
if
DEBUG
:
print
(
"
Reading error
"
)
if
print_on
:
print
(
f
"
Reading
IO
error
{
rd_value
}
"
)
except
err
:
ret_ack
=
0
rd_value
.
append
(
0
)
if
DEBUG
:
if
print_on
:
print
(
"
Reading error
"
)
for
cnt
in
range
(
bytes_to_read
):
ret_value
+=
(
hex
(
rd_value
[
cnt
])[
2
:])
...
...
This diff is collapsed.
Click to expand it.
apsct_lib.py
+
19
−
13
View file @
8694859a
...
...
@@ -406,6 +406,8 @@ class ApsctSensors:
if
not
(
15
<
self
.
temperature
<
50
):
result
=
False
print
(
f
"
Error temperature read
{
self
.
temperature
:
4.2
f
}
°C
"
)
else
:
print
(
f
"
OK temperature read
{
self
.
temperature
:
4.2
f
}
°C
"
)
return
result
def
read_voltage
(
self
,
input_channel
=
0
):
...
...
@@ -422,9 +424,8 @@ class ApsctSensors:
if
DEBUG
:
stri
=
"
Word to select sens input is 0x{0:x}
"
.
format
(
channel_select_word
)
print
(
stri
)
sleep
(
0.2
)
self
.
dev_i2c_sensor
.
write_bytes
(
channel_select_word
,
0xB8
)
sleep
(
0.
2
)
sleep
(
0.
3
)
# Wait for device to take snapshot
ret_ack
,
ret_value
=
self
.
dev_i2c_sensor
.
read_last_reg
(
3
)
if
DEBUG
:
stri
=
"
Return value input 0 : 0x{0}
"
.
format
(
ret_value
)
...
...
@@ -434,10 +435,11 @@ class ApsctSensors:
else
:
steps
=
(
int
(
ret_value
,
16
)
&
0x1FFFFF
)
>>
6
voltage
=
one_step
*
steps
voltage
=
((
4.7
+
2.2
)
/
2.2
)
*
2
*
voltage
voltage
=
((
4.7
+
2.2
)
/
2.2
)
*
2
*
voltage
# Resistor network + half swing
if
DEBUG
:
string
=
"
Voltage sens line {1} is {0:.4f} V
"
.
format
(
voltage
,
input_channel
)
print
(
string
)
sleep
(
0.2
)
# wait for device to go to sleep
return
voltage
def
read_temp
(
self
):
...
...
@@ -448,9 +450,12 @@ class ApsctSensors:
#
Vref
=
3.0
temp_slope
=
93.5E-6
*
2
**
(
16
+
1
)
/
Vref
sleep
(
1.0
)
self
.
dev_i2c_sensor
.
write_bytes
(
0xA0
,
0xC0
)
sleep
(
1.0
)
ret_ack
=
self
.
dev_i2c_sensor
.
write_bytes
(
0xA0
,
0xC0
)
sleep
(
0.5
)
self
.
temperature
=
9999
loops
=
0
while
(
self
.
temperature
>
100
)
&
(
loops
<
2
):
loops
=
loops
+
1
ret_ack
,
ret_value
=
self
.
dev_i2c_sensor
.
read_last_reg
(
3
)
if
ret_ack
:
raw_value
=
(
int
(
ret_value
,
16
)
&
0x1FFFFF
)
>>
6
...
...
@@ -458,6 +463,7 @@ class ApsctSensors:
self
.
temperature
=
temperature_K
-
273
else
:
self
.
temperature
=
9999
sleep
(
0.2
)
return
self
.
temperature
class
PpsClass
:
...
...
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