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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
python_test_scripts
Commits
cf127ccb
Commit
cf127ccb
authored
1 year ago
by
Gijs Schoonderbeek
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://git.astron.nl/lofar2.0/python_test_scripts
parents
e6c3cb63
6f806ce0
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ccd_lib.py
+32
-24
32 additions, 24 deletions
ccd_lib.py
set_ccd.py
+3
-1
3 additions, 1 deletion
set_ccd.py
with
35 additions
and
25 deletions
ccd_lib.py
+
32
−
24
View file @
cf127ccb
...
...
@@ -41,7 +41,7 @@ class CcdClass:
self
.
frequency
=
"
10 MHz
"
self
.
eeprom
=
EepromClass
()
self
.
pll
=
PllClass
()
self
.
sensors
=
Apsct
Sensors
()
self
.
sensors
=
Ccd
Sensors
()
self
.
ccd_id
=
CcdId
()
def
power
(
self
,
state
):
...
...
@@ -188,13 +188,20 @@ class PllClass:
if
DEBUG
:
print
(
f
"
Divider P :
{
divider_p
}
, Divider A :
{
divider_a
}
, Divider B :
{
divider_b
}
"
)
charge_pump_current
=
3
# 0 is low (0.6 mA), 7 is high (4.8 mA)
self
.
write_byte_pll
(
0x04
,
(
divider_a
&
0x3F
))
self
.
write_byte_pll
(
0x05
,
(
divider_b
&
0x1F00
)
>>
8
)
self
.
write_byte_pll
(
0x06
,
(
divider_b
&
0x00FF
))
# self.write_byte_pll(0x04, (divider_a & 0x3F))
self
.
write_byte_pll
(
0x04
,
0x00
)
# (divider_a & 0x3F))
# self.write_byte_pll(0x05, (divider_b & 0x1F00) >> 8)
self
.
write_byte_pll
(
0x05
,
0x00
)
# (divider_b & 0x1F00) >> 8)
# self.write_byte_pll(0x06, (divider_b & 0x00FF))
self
.
write_byte_pll
(
0x06
,
0x01
)
# (divider_b & 0x00FF))
self
.
write_byte_pll
(
0x07
,
0x00
)
# No LOR
self
.
write_byte_pll
(
0x08
,
0x3B
)
# Charge pump normal + Status bit
self
.
write_byte_pll
(
0x09
,
(
charge_pump_current
&
0x7
)
<<
4
)
self
.
write_byte_pll
(
0x0A
,
0x00
)
# Fixed Divide 1
# self.write_byte_pll(0x08, 0x3B) # Charge pump normal + Status bit
self
.
write_byte_pll
(
0x08
,
0x47
)
# Charge pump normal + Status bit
# self.write_byte_pll(0x08, 0x43) # Charge pump normal + Status bit
# self.write_byte_pll(0x09, (charge_pump_current & 0x7) << 4)
self
.
write_byte_pll
(
0x09
,
0x50
)
# (charge_pump_current & 0x7) << 4)
# self.write_byte_pll(0x0A, 0x00) # Fixed Divide 1
self
.
write_byte_pll
(
0x0A
,
0x40
)
# Fixed Divide 1
self
.
write_byte_pll
(
0x0B
,
0x00
)
self
.
write_byte_pll
(
0x0C
,
0x01
)
self
.
write_byte_pll
(
0x45
,
0x00
)
# CLK2 as feedback clock input
...
...
@@ -226,15 +233,15 @@ class PllClass:
#
i2_c_io_device
=
I2C
(
0x20
,
BUSNR
=
I2CBUSNR
)
i2_c_io_device
.
write_bytes
(
0x06
,
0x2C
)
# '0' is output
i2_c_io_device
.
write_bytes
(
0x07
,
0x0
0
)
# '0' is output
i2_c_io_device
.
write_bytes
(
0x07
,
0x0
F
)
# '0' is output
ack
,
ret_value
=
i2_c_io_device
.
read_bytes
(
0x00
,
1
)
status_pll
=
int
(
ret_value
,
16
)
&
0x04
if
status_pll
:
self
.
lock
=
True
stri
=
f
"
PLL is in lock
"
stri
=
f
"
OK
PLL is in lock
"
else
:
self
.
lock
=
False
stri
=
f
"
PLL is not locked
"
stri
=
f
"
Error
PLL is not locked
"
print
(
stri
)
return
self
.
lock
...
...
@@ -244,15 +251,17 @@ class PllClass:
#
i2_c_io_device_a
=
I2C
(
0x20
,
BUSNR
=
I2CBUSNR
)
i2_c_io_device_a
.
write_bytes
(
0x06
,
0x2C
)
# '0' is output
i2_c_io_device_a
.
write_bytes
(
0x07
,
0x0
0
)
# '0' is output
i2_c_io_device_b
=
I2C
(
0x21
,
BUSNR
=
I2CBUSNR
)
i2_c_io_device_b
.
write_bytes
(
0x06
,
0x2C
)
# '0' is output
i2_c_io_device_b
.
write_bytes
(
0x07
,
0xFF
)
# '0' is output
ack
,
ret_value
=
i2_c_io_device_
b
.
read_bytes
(
0x01
,
1
)
i2_c_io_device_a
.
write_bytes
(
0x07
,
0x0
F
)
# '0' is output
#
i2_c_io_device_b = I2C(0x21, BUSNR=I2CBUSNR)
#
i2_c_io_device_b.write_bytes(0x06, 0x2C) # '0' is output
#
i2_c_io_device_b.write_bytes(0x07, 0xFF) # '0' is output
ack
,
ret_value
=
i2_c_io_device_
a
.
read_bytes
(
0x01
,
1
)
status_reg
=
int
(
ret_value
,
16
)
lol
=
(
status_reg
&
0x04
)
if
lol
:
print
(
f
"
{
self
.
frequency
}
has lost lock
"
)
print
(
f
"
Error
{
self
.
frequency
}
has lost lock
"
)
else
:
print
(
f
"
OK
{
self
.
frequency
}
has not lost lock
"
)
ack
,
ret_value
=
i2_c_io_device_a
.
read_bytes
(
0x01
,
1
)
old_reg
=
int
(
ret_value
,
16
)
i2_c_io_device_a
.
write_bytes
(
0x03
,
(
old_reg
|
0x20
))
# '0' is output
...
...
@@ -337,7 +346,7 @@ class CcdSensors:
self
.
power_supplies
=
list
(
CCD_I2C
.
PWR_LOCATIONS
.
keys
())
self
.
voltages
=
{}
self
.
temperature
=
9999
self
.
dev_i2c_sensor
.
write_bytes
(
0xB0
,
0xB8
)
#
self.dev_i2c_sensor.write_bytes(0xB0, 0xB8)
def
ccd_sensors
(
self
):
#
...
...
@@ -478,7 +487,7 @@ class CcdSensors:
class
Ccd
t
Id
:
class
CcdId
:
#
# Class to check ID pins
#
...
...
@@ -499,6 +508,7 @@ class CcdtId:
for
pin
in
CCD_I2C
.
ID_PINS
:
loc_id
=
loc_id
*
2
bit
=
gpio
.
input
(
pin
)
print
(
f
"
DEBUG.. Bit is
{
bit
}
"
)
loc_id
=
loc_id
+
bit
self
.
id
=
loc_id
return
self
.
id
...
...
@@ -523,15 +533,13 @@ def main():
sleep
(
1
)
Ccd
.
power
(
True
)
sleep
(
1
)
if
False
:
Ccd
.
pll
.
write_byte_pll
(
0x06
,
0xA5
)
Ccd
.
pll
.
write_byte_pll
(
0x5A
,
0x01
)
Ccd
.
pll
.
setup_pll
()
Ccd
.
pll
.
read_lol
()
Ccd
.
pll
.
read_lock
()
Ccd
.
pll
.
read_all_regs_pll
()
Ccd
.
pll
.
read_lol
()
# Ccd.pll.read_all_regs_pll()
Ccd
.
sensors
.
check_values
()
# Ccd.eeprom.wr_rd_eeprom()
Ccd
.
ccd_id
.
check_id
()
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
set_ccd.py
+
3
−
1
View file @
cf127ccb
...
...
@@ -145,6 +145,7 @@ if SET_PLL :
Write_byte_PLL
(
0x05
,
0xF0
)
Write_byte_PLL
(
0x06
,
0x40
)
# cp inv = 0xF4 other 0xE4
Write_byte_PLL
(
0x07
,
0x04
)
# Divider R = 1 dec
Read_byte_PLL
(
0x07
,
2
)
Write_byte_PLL
(
0x08
,
0x01
)
Write_byte_PLL
(
0x07
,
0x00
)
# Write_byte_PLL(0x09, 0x10) # reset
...
...
@@ -168,7 +169,8 @@ if READ_LOCK:
print
(
"
Not locked --> PLL Error
"
)
if
READ_ALL
:
Read_byte_PLL
(
0x00
,
nof_bytes
=
23
)
for
cnt
in
range
(
32
):
Read_byte_PLL
(
cnt
,
nof_bytes
=
1
)
if
UPDATE_PLL
:
...
...
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