Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
AIDA-2020 TLU
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
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
Commits
607392e3
Commit
607392e3
authored
Feb 11, 2014
by
David Cussans
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Checking in changes on branch before merging with trunk
parent
b9c58117
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
13 deletions
+36
-13
FmcTluI2c.py
firmware/scripts/FmcTluI2c.py
+21
-7
test_aida_tlu.sh
firmware/scripts/test_aida_tlu.sh
+1
-1
test_aida_tlu_thresholds.py
firmware/scripts/test_aida_tlu_thresholds.py
+14
-5
No files found.
firmware/scripts/FmcTluI2c.py
View file @
607392e3
...
...
@@ -88,7 +88,7 @@ class FmcTluI2c:
#################
### set DAC value
#################
def
set_dac
(
self
,
channel
,
value
):
def
set_dac
(
self
,
channel
,
value
,
vrefOn
=
0
,
i2cSlaveAddrDac
=
0x1F
):
if
channel
<
0
or
channel
>
7
:
print
"set_dac ERROR: channel"
,
channel
,
"not in range 0-7 (bit mask)"
return
-
1
...
...
@@ -96,10 +96,17 @@ class FmcTluI2c:
print
"set_dac ERROR: value"
,
value
,
"not in range 0-0xFFFF"
return
-
1
# AD5665R chip with A0,A1 tied to ground
i2cSlaveAddrDac
=
0x1F
# seven bit address, binary 00011111
#i2cSlaveAddrDac = 0x1F # seven bit address, binary 00011111
print
"I2C address of DAC = "
,
hex
(
i2cSlaveAddrDac
)
dac
=
RawI2cAccess
(
self
.
i2cBusProps
,
i2cSlaveAddrDac
)
# enter vref-on mode:
dac
.
write
([
0x38
,
0x00
,
0x01
])
# if we want to enable internal voltage reference:
if
vrefOn
:
# enter vref-on mode:
print
"Turning internal reference ON"
dac
.
write
([
0x38
,
0x00
,
0x01
])
else
:
print
"Turning internal reference OFF"
dac
.
write
([
0x38
,
0x00
,
0x00
])
# now set the actual value
sequence
=
[(
0x18
+
(
channel
&
0x7
)
)
,
(
value
/
256
)
&
0xff
,
value
&
0xff
]
print
sequence
...
...
@@ -110,13 +117,20 @@ class FmcTluI2c:
##################################################
### convert required threshold voltage to DAC code
##################################################
# WARNING THIS CODE IS BUGGY.
def
convert_voltage_to_dac
(
self
,
desiredVoltage
):
Vref
=
2.50
def
convert_voltage_to_dac
(
self
,
desiredVoltage
,
Vref
=
1.300
):
Vdaq
=
(
desiredVoltage
+
Vref
)
/
2
dacCode
=
0xFFFF
*
Vdaq
/
Vref
return
int
(
dacCode
)
##################################################
### calculate the DAC code required and set DAC
##################################################
def
set_threshold_voltage
(
self
,
channel
,
voltage
):
dacCode
=
self
.
convert_voltage_to_dac
(
voltage
)
print
" requested voltage, calculated DAC code = "
,
voltage
,
dacCode
self
.
set_dac
(
channel
,
dacCode
)
firmware/scripts/test_aida_tlu.sh
View file @
607392e3
#!/bin/bash
#
export
PYTHONPATH
=
~/PyChips_1_
4_3
/src
export
PYTHONPATH
=
~/PyChips_1_
5_0_pre2A
/src
python test_aida_tlu.py
firmware/scripts/test_aida_tlu_thresholds.py
View file @
607392e3
...
...
@@ -14,13 +14,22 @@ boardi2c = FmcTluI2c(board)
boardFirmware
=
board
.
read
(
"FirmwareId"
)
print
"Firmware version = "
,
hex
(
boardFirmware
)
#scanResults = boardi2c.i2c_scan()
#print scanResults
print
"Scanning I2C bus:"
scanResults
=
boardi2c
.
i2c_scan
()
print
scanResults
boardId
=
boardi2c
.
get_serial_number
()
print
"FMC-TLU serial number = "
,
boardId
# Set thresholds at about -0.1V ( with 1MOhm f/back resistors )
print
"Setting Vthreshold to about -0.1V"
boardi2c
.
set_dac
(
7
,
0x4100
)
#dacValue = 0x4100
dacValue
=
0xFFFF
print
"Setting Vthreshold for all DACs. Code = "
,
dacValue
boardi2c
.
set_dac
(
7
,
dacValue
)
dacValue
=
0x6000
print
"Setting Vthreshold for DAC 0. Code = "
,
dacValue
boardi2c
.
set_dac
(
0
,
dacValue
)
# set DACs to -5mV
#boardi2c.set_threshold_voltage(7, -0.005)
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