Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
PyPCC
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
PyPCC
Commits
bd01d8b9
Commit
bd01d8b9
authored
8 months ago
by
Paulus Kruger
Browse files
Options
Downloads
Patches
Plain Diff
dante test R8
parent
7e8483ad
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
dante_test/dante.py
+25
-26
25 additions, 26 deletions
dante_test/dante.py
dante_test/dante_array.ipynb
+5500
-94
5500 additions, 94 deletions
dante_test/dante_array.ipynb
dante_test/dante_test.ipynb
+20
-20
20 additions, 20 deletions
dante_test/dante_test.ipynb
with
5545 additions
and
140 deletions
dante_test/dante.py
+
25
−
26
View file @
bd01d8b9
...
...
@@ -8,15 +8,15 @@ HBA_X=0
HBA_Y
=
1
HBA_PWR
=
2
#HBA_PWR=0xB
HBA_ID
=
0x14
HBA_VERSION
=
0x10
HBA_ADDR
=
0x20
HBA_V
=
0x30
HBA_VSENSE
=
0x34
HBA_ID
=
0x4
HBA_VERSION
=
0x0C
HBA_PCB_VERSION
=
0x20
HBA_PCB_NUMBER
=
0x30
HBA_ADDR
=
0x10
HBA_V
=
0x50
HBA_VSENSE
=
0x54
HBA_SAVE_EEPROM
=
0x40
HBA_LOAD_EEPROM
=
0x41
#HBA selected to speak to
#HBA_select=15
Debug
=
False
def
GetPackets
(
ser
,
Debug
=
False
):
...
...
@@ -41,6 +41,10 @@ def GetPackets(ser,Debug=False):
if
NoData
:
print
(
"
Communication error!
"
)
return
RXdata
;
def
string2hex
(
D1
):
s
=
'
0x
'
for
d
in
D1
[::
-
1
]:
s
+=
hex
(
d
)[
2
:]
return
s
class
dante
():
def
__init__
(
self
,
SetReg
,
GetReg
):
#self.ser = serial.Serial(serial_port,115200,timeout=0.3) # open serial port
...
...
@@ -77,11 +81,14 @@ class dante():
def
power_off
(
self
,
addr
=
None
):
self
.
SetRegisters
(
HBA_PWR
,[
0x0
],
addr
=
addr
);
def
get_id
(
self
,
addr
=
None
):
D1
=
self
.
RequestRegisters
(
HBA_VERSION
,
4
,
addr
=
addr
);
s
=
'
0x
'
for
d
in
D1
[::
-
1
]:
s
+=
hex
(
d
)[
2
:]
return
s
def
get_UID
(
self
,
addr
=
None
):
return
string2hex
(
self
.
RequestRegisters
(
HBA_ID
,
8
,
addr
=
addr
));
def
get_PCB_version
(
self
,
addr
=
None
):
return
bytearray
(
self
.
RequestRegisters
(
HBA_PCB_VERSION
,
16
,
addr
=
addr
)).
decode
(
'
utf8
'
);
def
get_PCB_number
(
self
,
addr
=
None
):
return
bytearray
(
self
.
RequestRegisters
(
HBA_PCB_NUMBER
,
16
,
addr
=
addr
)).
decode
(
'
utf8
'
);
def
getvoltage
(
self
,
x
,
addr
=
None
):
D1
=
self
.
RequestRegisters
(
0x30
+
x
,
0
,
addr
=
addr
);
...
...
@@ -114,17 +121,9 @@ class dante():
self
.
dab_on
[
addr
]
=
val
;
self
.
update_shift
(
addr
=
addr
)
def
update_shift
(
self
,
addr
):
val
=
self
.
delay
.
get
(
addr
,
15
)
TTDs
=
[
False
]
*
5
;
for
x
in
range
(
5
):
TTDs
[
x
]
=
val
//
(
2
**
(
x
))
%
2
==
1
val2
=
0
;
previous
=
self
.
term_on
.
get
(
addr
,
False
);
# for x in range(5,-1,-1):
for
x
in
range
(
5
):
val2
=
val2
*
2
+
1
*
(
not
(
TTDs
[
x
]
==
previous
))
previous
=
TTDs
[
x
]
val2
=
val2
*
2
+
1
*
previous
# print(val,TTDs,val2,bin(val2))
self
.
SetRegisters
(
HBA_X
,[
val2
+
self
.
dab_on
.
get
(
addr
,
False
)
*
0x80
,
val2
+
self
.
LED
.
get
(
addr
,
False
)
*
0xC0
],
addr
=
addr
)
\ No newline at end of file
def
update_shift
(
self
,
addr
=
None
):
val
=
self
.
delay
.
get
(
addr
,
15
)
*
4
if
not
(
self
.
term_on
.
get
(
addr
,
False
)):
val
+=
0x80
self
.
SetRegisters
(
HBA_X
,[
val
+
self
.
dab_on
.
get
(
addr
,
False
)
*
1
,
val
+
self
.
LED
.
get
(
addr
,
False
)
*
1
],
addr
=
addr
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
dante_test/dante_array.ipynb
+
5500
−
94
View file @
bd01d8b9
This diff is collapsed.
Click to expand it.
dante_test/dante_test.ipynb
+
20
−
20
View file @
bd01d8b9
...
...
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count":
864
,
"execution_count":
11
,
"id": "be158779-1b1b-4772-8b8a-ac5be689cd2a",
"metadata": {},
"outputs": [
...
...
@@ -25,7 +25,7 @@
},
{
"cell_type": "code",
"execution_count":
865
,
"execution_count":
12
,
"id": "1e3ebc6a-8b6d-442c-b043-23b83d0392ef",
"metadata": {},
"outputs": [
...
...
@@ -50,7 +50,7 @@
},
{
"cell_type": "code",
"execution_count":
760
,
"execution_count":
13
,
"id": "75b0f251-3828-480c-bb1d-9f12664e7b68",
"metadata": {},
"outputs": [],
...
...
@@ -63,7 +63,7 @@
},
{
"cell_type": "code",
"execution_count":
76
1,
"execution_count": 1
4
,
"id": "4d3b27b5-dbd5-46f1-8bf1-1c3c2428ce6e",
"metadata": {},
"outputs": [
...
...
@@ -105,7 +105,7 @@
},
{
"cell_type": "code",
"execution_count":
858
,
"execution_count":
15
,
"id": "f899a423-a022-4d6a-91d4-d07b03968b85",
"metadata": {},
"outputs": [
...
...
@@ -113,12 +113,12 @@
"name": "stdout",
"output_type": "stream",
"text": [
"RCU uC Mode
0
\n",
"RCU uC Mode
2
\n",
"RCU uC Vref 0xc\n",
"RCU uC Readback
0
\n",
"RCU uC Readback
1
\n",
"RCU uC start high 4\n",
"RCU uC RX start timeout 0x
f
0\n",
"RCU uC RX end timeout 0x
a
\n"
"RCU uC RX start timeout 0x
5
0\n",
"RCU uC RX end timeout 0x
4
\n"
]
}
],
...
...
@@ -137,7 +137,7 @@
},
{
"cell_type": "code",
"execution_count":
859
,
"execution_count":
16
,
"id": "5c374c72-22d7-4076-afb1-a698cbffbe14",
"metadata": {},
"outputs": [
...
...
@@ -168,7 +168,7 @@
},
{
"cell_type": "code",
"execution_count":
866
,
"execution_count":
17
,
"id": "487febee-9858-41db-a7b2-251c766b13e0",
"metadata": {},
"outputs": [],
...
...
@@ -201,7 +201,7 @@
},
{
"cell_type": "code",
"execution_count":
86
1,
"execution_count": 1
8
,
"id": "00b396bc-57ba-4b6b-ba27-56e8bb8baf8e",
"metadata": {},
"outputs": [
...
...
@@ -209,19 +209,19 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[
9
, 4, 2, 2, 255]\n"
"[
8
, 4, 2, 2, 255]\n"
]
}
],
"source": [
"#power on\n",
"HBA_select=
9
\n",
"HBA_select=
8
\n",
"SetRegisters(HBA_PWR,[0xFF]) #switch power on\n"
]
},
{
"cell_type": "code",
"execution_count":
863
,
"execution_count":
11
,
"id": "b1eb54c1-960d-42fe-acee-7559d4c08637",
"metadata": {},
"outputs": [
...
...
@@ -229,7 +229,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"['0x
9
', '0x
3
', '0x
9
', '0x
14
', '0x
f4
', '0x3']\n"
"['0x
81
', '0x
5
', '0x
44
', '0x
32
', '0x
30
', '0x3
2
']\n"
]
}
],
...
...
@@ -241,7 +241,7 @@
},
{
"cell_type": "code",
"execution_count":
508
,
"execution_count":
12
,
"id": "3107ba56-6a4a-4451-922f-372dc3bfa31c",
"metadata": {},
"outputs": [
...
...
@@ -249,7 +249,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"['0x81', '0x5', '0x
0
', '0x0', '0x
0
', '0x0']\n"
"['0x81', '0x5', '0x
9
', '0x
1
0', '0x
23
', '0x
2
0']\n"
]
}
],
...
...
@@ -654,7 +654,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3
(ipykernel)
",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
...
...
@@ -668,7 +668,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.
11.5
"
"version": "3.
9.2
"
}
},
"nbformat": 4,
...
...
%% Cell type:code id:be158779-1b1b-4772-8b8a-ac5be689cd2a tags:
```
python
from
pypcc.i2cdirect
import
i2cdirect
from
time
import
sleep
import
hbat1
as
hb
#d1=i2cdirect('RECVTR_HB_DANTE.yaml')
d1
=
i2cdirect
(
'
RECVTR_HB_TEST.yaml
'
)
```
%% Output
WARNING:root:Variable None not found
WARNING:root:I2C_RCU I2C mask not found!
%% Cell type:code id:1e3ebc6a-8b6d-442c-b043-23b83d0392ef tags:
```
python
if
True
:
for
varname
in
[
'
RCU_PCB_ID
'
,
'
RCU_PCB_version
'
,
'
RCU_PCB_number
'
,
'
RCU_firmware_version
'
,]:
data
,
var1
=
d1
.
GetVal
(
varname
);
print
(
varname
+
"
=
"
,
data
[
0
])
```
%% Output
RCU_PCB_ID= 9231404
RCU_PCB_version= RCU2H V 3.2
RCU_PCB_number= RCU2H-202914-00026
RCU_firmware_version= 1660812099
%% Cell type:code id:75b0f251-3828-480c-bb1d-9f12664e7b68 tags:
```
python
#d1.runmethod("RCU_on")
#band=4;
#for ch in ['CH1','CH2','CH3']:
# d1.SetVal(ch+"_band_select",band)
```
%% Cell type:code id:4d3b27b5-dbd5-46f1-8bf1-1c3c2428ce6e tags:
```
python
for
ch
in
[
'
CH1
'
,
'
CH2
'
,
'
CH3
'
]:
print
(
"
Channel
"
,
ch
)
for
varname
in
[
'
band_select
'
,
'
attenuator_dB
'
,
# 'PWR_ANT_on','PWR_ANT_VOUT','PWR_ANT_VIN','PWR_ANT_IOUT',
# 'ADC_locked','ADC_sync','ADC_JESD','ADC_CML_level','ADC_shutdown',
# 'DTH_freq','DTH_PWR','DTH_on',
]:
data
,
var1
=
d1
.
GetVal
(
ch
+
'
_
'
+
varname
);
print
(
"
"
,
varname
+
"
=
"
,
data
[
0
])
```
%% Output
Channel CH1
band_select= 0
attenuator_dB= 0
Channel CH2
band_select= 0
attenuator_dB= 0
Channel CH3
band_select= 0
attenuator_dB= 0
%% Cell type:code id:beeb881d-b4d6-4430-b4c8-9aa3850d4187 tags:
```
python
``
`
%%
Cell
type
:
code
id
:
f899a423
-
a022
-
4
d6a
-
91
d4
-
d07b03968b85
tags
:
```
python
uCaddr=0x40
HBAi2c=0x41
i2c=d1.conf.conf
[
'drivers'
][
0
]
['obj'] #assume I2C is first device
v=[0]
i2c.i2csetget(uCaddr,v,reg=2 ,read=1);print("RCU uC Mode",v[0]);
i2c.i2csetget(uCaddr,v,reg=13,read=1);print("RCU uC Vref",hex(v[0]));
i2c.i2csetget(uCaddr,v,reg=5 ,read=1);print("RCU uC Readback",v[0]);
i2c.i2csetget(uCaddr,v,reg=14,read=1);print("RCU uC start high",v[0]);
i2c.i2csetget(uCaddr,v,reg=11,read=1);print("RCU uC RX start timeout",hex(v[0]));
i2c.i2csetget(uCaddr,v,reg=9,read=1);print("RCU uC RX end timeout",hex(v[0]));
```
%% Output
RCU uC Mode
0
RCU uC Mode
2
RCU uC Vref 0xc
RCU uC Readback
0
RCU uC Readback
1
RCU uC start high 4
RCU uC RX start timeout 0x
f
0
RCU uC RX end timeout 0x
a
RCU uC RX start timeout 0x
5
0
RCU uC RX end timeout 0x
4
%% Cell type:code id:5c374c72-22d7-4076-afb1-a698cbffbe14 tags:
```
python
if True:
# print("Set Vref=0x0c");
i2c.i2csetget(uCaddr,[0x0c],reg=13,read=0)
print("Set mode=0");
i2c.i2csetget(uCaddr,[0],reg=2,read=0)
print("Set Auto readback=0");
i2c.i2csetget(uCaddr,[0],reg=5,read=0)
print("Set timeouts");
i2c.i2csetget(uCaddr,[0xf0],reg=11,read=0) #was 0x50
i2c.i2csetget(uCaddr,[0xa],reg=9,read=0) #0x4
# print("TX start high=0");
# i2c.i2csetget(uCaddr,[4],reg=14,read=0)
```
%% Output
Set mode=0
Set Auto readback=0
Set timeouts
%% Cell type:code id:487febee-9858-41db-a7b2-251c766b13e0 tags:
```
python
HBA_PWR=2
def SetRegisters(reg,data):
func=len(data)
*
2;
TX1=hb.MakeRequest(HBA_select,data,func,reg)[:-2];
print(TX1)
i2c.i2csetget(HBAi2c,TX1,reg=None,read=0)
def getreg(reg,length,wait=0.5):
func=length
*
2+1;
TX1=hb.MakeRequest(HBA_select,[],func,reg)[:-2];
i2c.i2csetget(HBAi2c,TX1,reg=None,read=0)
if length==0: return []
sleep(wait)
data=[0]
*
(length+6)
i2c.i2csetget(HBAi2c,data,reg=None,read=1)
return data[2:-2]
#def RequestRegisters(reg,length):
# func=length*2+1;
# TX1=hb.MakeRequest(HBA_select,[],func,reg);
# if Debug: print("Packet to TX",TX1)
# TX2=hb.ManchesterEncode(TX1)
# self.ser.write(bytearray(TX2))
# return GetPackets(self.ser);
```
%% Cell type:code id:00b396bc-57ba-4b6b-ba27-56e8bb8baf8e tags:
```
python
#power on
HBA_select=
9
HBA_select=
8
SetRegisters(HBA_PWR,[0xFF]) #switch power on
```
%% Output
[
9
, 4, 2, 2, 255]
[
8
, 4, 2, 2, 255]
%% Cell type:code id:b1eb54c1-960d-42fe-acee-7559d4c08637 tags:
```
python
HBA_ID=0x14
D=getreg(HBA_ID,4)
print([hex(d) for d in D])
```
%% Output
['0x
9
', '0x
3
', '0x
9
', '0x
14
', '0x
f4
', '0x3']
['0x
81
', '0x
5
', '0x
44
', '0x
32
', '0x
30
', '0x3
2
']
%% Cell type:code id:3107ba56-6a4a-4451-922f-372dc3bfa31c tags:
```
python
HBA_ID=0x10
D=getreg(HBA_ID,4)
print([hex(d) for d in D])
```
%% Output
['0x81', '0x5', '0x
0
', '0x0', '0x
0
', '0x0']
['0x81', '0x5', '0x
9
', '0x
1
0', '0x
23
', '0x
2
0']
%% Cell type:code id:d7c5172c-0363-48ff-9f3d-77bb0455a83a tags:
```
python
D=getreg(0x30,2,wait=1)
print([hex(d) for d in D])
```
%% Output
['0x1', '0x3', '0x5', '0x30']
%% Cell type:code id:95040fa6-e124-4f78-82b6-28d69ce788e2 tags:
```
python
length=4
reg=HBA_ID
func=length
*
2+1;
TX1=hb.MakeRequest(HBA_select,[],func,reg)[:-2];
print(TX1)
print([hex(x) for x in TX1])
i2c.i2csetget(HBAi2c,TX1,reg=None,read=0)
#D1=self.RequestRegisters(HBA_VERSION,4,addr=addr);
```
%% Output
[15, 3, 9, 20]
['0xf', '0x3', '0x9', '0x14']
True
%% Cell type:code id:bec9128d-ca8c-4c56-a0b0-f2703092d3ce tags:
```
python
data=[0]
*
(length+6)
i2c.i2csetget(HBAi2c,data,reg=None,read=1)
print(data)
print([hex(x) for x in data])
```
%% Output
[0, 0, 30, 6, 18, 41, 234, 151, 151, 151]
['0x0', '0x0', '0x1e', '0x6', '0x12', '0x29', '0xea', '0x97', '0x97', '0x97']
%% Cell type:code id:57ebdc42-5ea7-40ea-b463-e600e998aa91 tags:
```
python
SetRegisters(0,[0xff,0xff])
```
%% Output
[15, 5, 4, 0, 255, 255]
%% Cell type:code id:6b61f41a-714f-4319-8711-2035c860ea43 tags:
```
python
```
%% Cell type:code id:d501a27d-9d90-4b37-978b-7d01ee3eb021 tags:
```
python
#data=hb.MakeBroadcast([0x81,0x82]*16)[:-2]
data=hb.MakeBroadcast([x+0xf0 for x in range(4)],reg=0,func=2,serv1=2,serv2=5)[:-2]
print(data)
i2c.i2csetget(HBAi2c,data,reg=None,read=0)
```
%% Output
[0, 9, 2, 0, 2, 5, 240, 241, 242, 243]
True
%% Cell type:code id:f9850abc-5328-4edc-aaac-2dc68497ca2b tags:
```
python
data=getreg(0,1)
print(data)
print([hex(x) for x in data])
```
%% Output
[30, 6, 6]
['0x1e', '0x6', '0x6']
%% Cell type:code id:3168a5c6-6e95-4f0c-9a9d-a7fa82b32e83 tags:
```
python
SetRegisters(0,[0x12,0xff])
sleep(0.5)
data=getreg(0,2)
print([hex(x) for x in data])
```
%% Output
[15, 5, 4, 0, 18, 255]
['0xf', '0x3', '0x5', '0x0']
%% Cell type:code id:493292ab-5efb-4477-a4fb-74bbe151e043 tags:
```
python
import numpy as np
10
*
np.log10(100e6)
```
%% Output
80.0
%% Cell type:code id:1814c7ab-0f40-44fe-89a2-1d4d2455e3f6 tags:
```
python
(10
*np.log10(100e6)+20*
np.log10(2
**
12))
```
%% Output
152.2471989593555
%% Cell type:code id:1c71995a-6606-4183-b90b-cd04afbbcb91 tags:
```
python
-128-6
*
4
```
%% Output
-152
%% Cell type:code id:a88355e3-7cfe-40fc-b91b-f274648aecb6 tags:
```
python
(10
*np.log10(200e6)+20*
np.log10(2
**
14))-152.247
```
%% Output
15.05169874255455
%% Cell type:code id:e61895b6-854f-4e82-b4fa-7e880c4127e0 tags:
```
python
10
**
(15/10)
```
%% Output
31.622776601683793
%% Cell type:code id:4452dbd5-0aaf-4a0c-88f2-c30799aa5c21 tags:
```
python
np.sqrt(512)
**
2
*
195313
```
%% Output
100000256.00000001
%% Cell type:markdown id:e60be73c-4b85-4b97-b59b-0c579beed4f7 tags:
# Change id
%% Cell type:code id:9e6c8a65-df36-4b61-9bf5-d72ee70cb6b9 tags:
```
python
SetRegisters(0x20,[0x9])
#HBA_select=2
```
%% Output
[6, 4, 2, 32, 9]
%% Cell type:code id:89609c76-b975-4841-a7b4-011846443591 tags:
```
python
#SetRegisters(0x1a,[0xff])
```
%% Cell type:code id:6d82359c-6d20-4625-8193-bd629bea81d3 tags:
```
python
D=getreg(0x40,0) #save EEPROM
```
%% Cell type:code id:68694ef7-c088-4383-8663-5a404d54e281 tags:
```
python
HBA_select=11
D=getreg(0x1b,6)
print([hex(d) for d in D])
```
%% Output
['0xb', '0x3', '0xd', '0x1b', '0xb7', '0x7f', '0x7f', '0x7f']
%% Cell type:code id:69257341-f14a-476b-a124-fdf6a08d77bd tags:
```
python
D=getreg(0x41,0) #load EEPROM
```
%% Cell type:code id:bdd70748-f571-47d1-b212-68bf450e39ba tags:
```
python
```
...
...
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