Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
redpitaya-MCPHA
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
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
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
Günter Quast
redpitaya-MCPHA
Commits
bbc691cd
Commit
bbc691cd
authored
1 year ago
by
Günter Quast
Browse files
Options
Downloads
Patches
Plain Diff
mcpha: added option to set update interval
parent
991348e1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mcpha.py
+41
-24
41 additions, 24 deletions
mcpha.py
with
41 additions
and
24 deletions
mcpha.py
+
41
−
24
View file @
bbc691cd
...
...
@@ -4,8 +4,14 @@
Client script for displaying the output of the MCPHA application
running on a RedPitaya FPGA board
Modified version of mcphy.py by Pavel Demin
Modified
and extended
version of mcphy.py by Pavel Demin
Command line args:
-h, --help show this help message and exit
-c CONNECT_IP, --connect_ip CONNECT_IP connect IP address of RedPitaya
-t TRIGGER_LEVEL, --trigger_level TRIGGER_LEVEL trigger level in ADC counts
-i INTERVAL, --interval INTERVAL interval for readout (in ms)
"""
# differences w.r.t. original version marked with " # !gq"
...
...
@@ -57,11 +63,10 @@ class MCPHA(QMainWindow, Ui_MCPHA):
def
__init__
(
self
):
super
(
MCPHA
,
self
).
__init__
()
# !gq additions
self
.
get_physical_units
()
# !gq end
self
.
setupUi
(
self
)
# !gq get command line arguments
self
.
parse_args
()
self
.
get_physical_units
()
# !gq end
# initialize variables
self
.
idle
=
True
self
.
waiting
=
[
False
for
i
in
range
(
3
)]
...
...
@@ -81,8 +86,6 @@ class MCPHA(QMainWindow, Ui_MCPHA):
self
.
tabWidget
.
addTab
(
self
.
osc
,
"
Oscilloscope
"
)
self
.
tabWidget
.
addTab
(
self
.
gen
,
"
Pulse generator
"
)
# configure controls
# !gq color orange if not yet connected
self
.
addrValue
.
setStyleSheet
(
"
color: darkorange
"
)
self
.
connectButton
.
clicked
.
connect
(
self
.
start
)
self
.
syncCheck
.
toggled
.
connect
(
self
.
set_sync
)
self
.
neg1Check
.
toggled
.
connect
(
partial
(
self
.
set_negator
,
0
))
...
...
@@ -95,10 +98,6 @@ class MCPHA(QMainWindow, Ui_MCPHA):
self
.
rateValue
.
setItemData
(
i
,
Qt
.
AlignRight
,
Qt
.
TextAlignmentRole
)
self
.
rateValue
.
setCurrentIndex
(
1
)
self
.
rateValue
.
currentIndexChanged
.
connect
(
self
.
set_rate
)
# address validator
# !gq
self
.
addrValue
.
setText
(
self
.
ip_address
)
# !gq end
rx
=
QRegExp
(
"
^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|rp-[0-9A-Fa-f]{6}\.local$
"
)
self
.
addrValue
.
setValidator
(
QRegExpValidator
(
rx
,
self
.
addrValue
))
# create TCP socket
...
...
@@ -115,21 +114,35 @@ class MCPHA(QMainWindow, Ui_MCPHA):
self
.
readTimer
=
QTimer
(
self
)
self
.
readTimer
.
timeout
.
connect
(
self
.
read_timeout
)
# !gq set defaults and units
# get command line arguments
# !gq additions
self
.
parse_args
()
# set argument options
self
.
osc
.
levelValue
.
setValue
(
self
.
trigger_level
)
# automatically connect
if
self
.
ip_address
is
not
None
:
self
.
addrValue
.
setText
(
self
.
ip_address
)
self
.
start
()
else
:
self
.
addrValue
.
setStyleSheet
(
"
color: darkorange
"
)
# !gq end
# !gq get command line arguments
def
parse_args
(
self
):
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
parser
.
add_argument
(
'
-
i
'
,
'
--
ip_address
'
,
type
=
str
,
default
=
"
192.168.0.103
"
,
help
=
'
IP address of RedPitaya
'
)
parser
.
add_argument
(
'
-
c
'
,
'
--
connect_ip
'
,
type
=
str
,
help
=
'
connect
IP address of RedPitaya
'
)
parser
.
add_argument
(
'
-t
'
,
'
--trigger_level
'
,
type
=
int
,
default
=
500
,
help
=
'
trigger level in ADC counts
'
)
parser
.
add_argument
(
'
-i
'
,
'
--interval
'
,
type
=
int
,
default
=
500
,
help
=
'
interval for readout (in ms)
'
)
args
=
parser
.
parse_args
()
self
.
trigger_level
=
args
.
trigger_level
self
.
ip_address
=
args
.
ip_address
self
.
ip_address
=
args
.
connect_ip
self
.
readInterval
=
args
.
interval
def
get_physical_units
(
self
):
"""
get physical units corresponding to ADC units and channel numbers
"""
...
...
@@ -141,7 +154,8 @@ class MCPHA(QMainWindow, Ui_MCPHA):
def
start
(
self
):
self
.
socket
.
connectToHost
(
self
.
addrValue
.
text
(),
1001
)
self
.
startTimer
.
start
(
5000
)
# gq! self.startTimer.start(5000)
self
.
startTimer
.
start
(
1000
)
self
.
connectButton
.
setText
(
"
Disconnect
"
)
self
.
connectButton
.
clicked
.
disconnect
()
self
.
connectButton
.
clicked
.
connect
(
self
.
stop
)
...
...
@@ -176,7 +190,8 @@ class MCPHA(QMainWindow, Ui_MCPHA):
def
connected
(
self
):
self
.
startTimer
.
stop
()
self
.
readTimer
.
start
(
500
)
# ! gq self.readTimer.start(500)
self
.
readTimer
.
start
(
self
.
readInterval
)
# !gq color green if connected
self
.
addrValue
.
setStyleSheet
(
"
color: green
"
)
self
.
log
.
print
(
"
IO started
"
)
...
...
@@ -203,19 +218,21 @@ class MCPHA(QMainWindow, Ui_MCPHA):
return
True
def
read_timeout
(
self
):
"""
data transfer from RP, triggered by QTimer readTimer
"""
# send reset commands
if
self
.
reset
&
1
:
self
.
command
(
0
,
0
,
0
)
self
.
command
(
0
,
0
,
0
)
# hst 1
if
self
.
reset
&
2
:
self
.
command
(
0
,
1
,
0
)
self
.
command
(
0
,
1
,
0
)
# hst 2
if
self
.
reset
&
4
:
self
.
command
(
1
,
0
,
0
)
self
.
command
(
1
,
0
,
0
)
# reset timer 1
if
self
.
reset
&
8
:
self
.
command
(
1
,
1
,
0
)
self
.
command
(
1
,
1
,
0
)
# reset timer 2
if
self
.
reset
&
16
:
self
.
command
(
2
,
0
,
0
)
self
.
command
(
2
,
0
,
0
)
# reset osc
if
self
.
reset
&
32
:
self
.
command
(
19
,
0
,
0
)
self
.
command
(
19
,
0
,
0
)
# start osc
self
.
reset
=
0
# read
self
.
command
(
11
,
0
,
0
)
...
...
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