Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
AIDA-2020 TLU - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
AIDA-2020 TLU - Software
Commits
f435e8b9
Commit
f435e8b9
authored
Feb 07, 2018
by
Paolo Baesso
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
POwermodule. DAC seems to work fine now. Working on the LED code
parent
ce236814
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
31 deletions
+80
-31
TLU_v1e.py
TLU_v1e/scripts/TLU_v1e.py
+10
-30
AD5665R.py
packages/AD5665R.py
+2
-1
TLU_powermodule.py
packages/TLU_powermodule.py
+68
-0
No files found.
TLU_v1e/scripts/TLU_v1e.py
View file @
f435e8b9
...
...
@@ -13,6 +13,7 @@ from si5345 import si5345 # Library for clock chip
from
AD5665R
import
AD5665R
# Library for DAC
from
PCA9539PW
import
PCA9539PW
# Library for serial line expander
from
I2CDISP
import
CFA632
#Library for display
from
TLU_powermodule
import
PWRLED
class
TLU
:
"""docstring for TLU"""
...
...
@@ -102,41 +103,20 @@ class TLU:
self
.
IC7
.
setIOReg
(
1
,
0x00
)
# 0= output, 1= input
self
.
IC7
.
setOutputs
(
1
,
0xB0
)
# If output, set to XX
#Display
#
Instantiate
Display
self
.
DISP
=
CFA632
(
self
.
TLU_I2C
,
0x2A
)
#
#Power/Led Module
#
Instantiate
Power/Led Module
dac_addr_module
=
int
(
parsed_cfg
.
get
(
section_name
,
"I2C_DACModule_Addr"
),
16
)
self
.
zeDAC_pwr
=
AD5665R
(
self
.
TLU_I2C
,
dac_addr_module
)
self
.
zeDAC_pwr
.
setIntRef
(
self
.
intRefOn
,
self
.
verbose
)
print
"BOH"
self
.
writeThreshold
(
self
.
zeDAC_pwr
,
-
1
,
0
,
self
.
verbose
)
self
.
writeThreshold
(
self
.
zeDAC_pwr
,
-
1
,
1
,
self
.
verbose
)
self
.
writeThreshold
(
self
.
zeDAC_pwr
,
-
1
,
2
,
self
.
verbose
)
self
.
writeThreshold
(
self
.
zeDAC_pwr
,
-
1
,
3
,
self
.
verbose
)
exp1_addr
=
int
(
parsed_cfg
.
get
(
section_name
,
"I2C_EXP1Module_Addr"
),
16
)
self
.
ledExp1
=
PCA9539PW
(
self
.
TLU_I2C
,
exp1_addr
)
self
.
ledExp1
.
setInvertReg
(
0
,
0x00
)
# 0= normal, 1= inverted
self
.
ledExp1
.
setIOReg
(
0
,
0x00
)
# 0= output, 1= input
self
.
ledExp1
.
setOutputs
(
0
,
0x1F
)
# If output, set to XX
self
.
ledExp1
.
setInvertReg
(
1
,
0x00
)
# 0= normal, 1= inverted
self
.
ledExp1
.
setIOReg
(
1
,
0x00
)
# 0= output, 1= input
self
.
ledExp1
.
setOutputs
(
1
,
0x1D
)
# If output, set to XX
exp2_addr
=
int
(
parsed_cfg
.
get
(
section_name
,
"I2C_EXP2Module_Addr"
),
16
)
self
.
ledExp2
=
PCA9539PW
(
self
.
TLU_I2C
,
exp1_addr
)
self
.
ledExp2
.
setInvertReg
(
0
,
0x00
)
# 0= normal, 1= inverted
self
.
ledExp2
.
setIOReg
(
0
,
0x00
)
# 0= output, 1= input
self
.
ledExp2
.
setOutputs
(
0
,
0x85
)
# If output, set to XX
self
.
ledExp2
.
setInvertReg
(
1
,
0x00
)
# 0= normal, 1= inverted
self
.
ledExp2
.
setIOReg
(
1
,
0x00
)
# 0= output, 1= input
self
.
ledExp2
.
setOutputs
(
1
,
0x3E
)
# If output, set to XX
print
"BLAH"
print
self
.
ledExp2
.
getOutputs
(
1
)
self
.
pwdled
=
PWRLED
(
self
.
TLU_I2C
,
dac_addr_module
,
exp1_addr
,
exp2_addr
)
self
.
pwdled
.
setVch
(
0
,
1
,
True
)
self
.
pwdled
.
setVch
(
1
,
0.9
,
True
)
self
.
pwdled
.
setVch
(
2
,
0.8
,
True
)
self
.
pwdled
.
setVch
(
3
,
0.1
,
True
)
self
.
pwdled
.
setIndicatorRGB
(
2
,
[
1
,
0
,
1
])
##################################################################################################################################
##################################################################################################################################
...
...
packages/AD5665R.py
View file @
f435e8b9
...
...
@@ -20,7 +20,8 @@ class AD5665R:
cmdDAC
=
[
0x38
,
0x00
,
0x00
]
self
.
i2c
.
write
(
self
.
slaveaddr
,
cmdDAC
,
mystop
)
if
verbose
:
print
"DAC int ref:"
,
intRef
print
" AD5665R"
print
"
\t
DAC int ref:"
,
intRef
def
writeDAC
(
self
,
dacCode
,
channel
,
verbose
=
False
):
...
...
packages/TLU_powermodule.py
0 → 100644
View file @
f435e8b9
import
uhal
from
I2CuHal
import
I2CCore
#import StringIO
from
AD5665R
import
AD5665R
# Library for DAC
from
PCA9539PW
import
PCA9539PW
# Library for serial line expander
class
PWRLED
:
#Class to configure the EEPROM
def
__init__
(
self
,
i2ccore
,
DACaddr
=
0x1C
,
Exp1Add
=
0x76
,
Exp2Add
=
0x77
):
print
" TLU POWERMODULE Initializing..."
self
.
TLU_I2C
=
i2ccore
self
.
pwraddr
=
DACaddr
self
.
exp1addr
=
Exp1Add
self
.
exp2addr
=
Exp2Add
self
.
intRefOn
=
0
self
.
verbose
=
True
#Map indicator color based on their position on the expanders: 0-15 are on expander 2, 16 to 31 on expander 1. One indicator is missing the blue component, hence
#the "-1" value.
self
.
indicatorXYZ
=
[(
1
,
0
,
-
1
),
(
3
,
2
,
4
),
(
6
,
5
,
7
),
(
9
,
8
,
10
),
(
12
,
11
,
13
),
(
15
,
14
,
16
),
(
18
,
17
,
19
),
(
21
,
20
,
22
),
(
24
,
23
,
25
),
(
27
,
26
,
28
),
(
30
,
29
,
31
)]
self
.
zeDAC_pwr
=
AD5665R
(
self
.
TLU_I2C
,
self
.
pwraddr
)
self
.
zeDAC_pwr
.
setIntRef
(
self
.
intRefOn
,
self
.
verbose
)
self
.
zeDAC_pwr
.
writeDAC
(
int
(
0
),
7
,
self
.
verbose
)
self
.
ledExp1
=
PCA9539PW
(
self
.
TLU_I2C
,
self
.
exp1addr
)
self
.
ledExp1
.
setInvertReg
(
0
,
0x00
)
# 0= normal, 1= inverted
self
.
ledExp1
.
setIOReg
(
0
,
0x00
)
# 0= output, 1= input
self
.
ledExp1
.
setOutputs
(
0
,
0x1F
)
# If output, set to XX
self
.
ledExp1
.
setInvertReg
(
1
,
0x00
)
# 0= normal, 1= inverted
self
.
ledExp1
.
setIOReg
(
1
,
0x00
)
# 0= output, 1= input
self
.
ledExp1
.
setOutputs
(
1
,
0x1D
)
# If output, set to XX
self
.
ledExp2
=
PCA9539PW
(
self
.
TLU_I2C
,
self
.
exp2addr
)
self
.
ledExp2
.
setInvertReg
(
0
,
0x00
)
# 0= normal, 1= inverted
self
.
ledExp2
.
setIOReg
(
0
,
0x00
)
# 0= output, 1= input
self
.
ledExp2
.
setOutputs
(
0
,
0x85
)
# If output, set to XX
self
.
ledExp2
.
setInvertReg
(
1
,
0x00
)
# 0= normal, 1= inverted
self
.
ledExp2
.
setIOReg
(
1
,
0x00
)
# 0= output, 1= input
self
.
ledExp2
.
setOutputs
(
1
,
0x3E
)
# If output, set to XX
print
" TLU POWERMODULE Ready"
def
test
(
self
):
print
"Testing the powermodule"
return
def
setVch
(
self
,
channel
,
voltage
,
verbose
=
False
):
# Note: the channel here is the DAC channel.
# The mapping with the power module is not one-to-one
if
((
channel
<
0
)
|
(
3
<
channel
)):
print
"PWRModule: channel should be comprised between 0 and 3"
else
:
if
(
voltage
<
0
):
print
"PWRModule: voltage must be comprised between 0 and 1 V. Coherced to 0 V."
voltage
=
0
if
(
voltage
>
1
):
print
"PWRModule: voltage must be comprised between 0 and 1 V. Coherced to 1 V."
voltage
=
1
dacValue
=
voltage
*
65535
self
.
zeDAC_pwr
.
writeDAC
(
int
(
dacValue
),
channel
,
verbose
)
return
def
setIndicatorRGB
(
self
,
indicator
,
RGB
=
[
0
,
0
,
0
],
verbose
=
False
):
print
self
.
indicatorXYZ
[
indicator
-
1
]
print
self
.
indicatorXYZ
[
indicator
-
1
][
2
]
return
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment