Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
total_control_app
Project
Project
Details
Activity
Releases
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Drechsler
total_control_app
Commits
0c2f0791
Commit
0c2f0791
authored
Dec 17, 2018
by
Martin Drechsler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added feedfoward
parent
c264ae66
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
26 deletions
+68
-26
myGUI.py
myGUI.py
+22
-17
myWidgets.py
myWidgets.py
+30
-7
scanFunctions.py
scanFunctions.py
+16
-2
No files found.
myGUI.py
View file @
0c2f0791
...
@@ -70,28 +70,29 @@ class GuiMainWindow(QMainWindow):
...
@@ -70,28 +70,29 @@ class GuiMainWindow(QMainWindow):
self
.
dactivate
.
hideTitleBar
()
self
.
dactivate
.
hideTitleBar
()
# Here I add the docks
# Here I add the docks
self
.
area
.
addDock
(
self
.
dtrap_electrodes
)
#self.area.addDock( self.dtrap_electrodes)
self
.
area
.
addDock
(
self
.
d397
,
'bottom'
,
self
.
dtrap_electrodes
)
#self.area.addDock(self.d397, 'bottom', self.dtrap_electrodes)
self
.
area
.
addDock
(
self
.
d866
,
'bottom'
,
self
.
d397
)
#self.area.addDock(self.d866, 'bottom', self.d397)
self
.
area
.
addDock
(
self
.
dPI
,
'bottom'
,
self
.
d866
)
self
.
area
.
addDock
(
self
.
dWM
)
self
.
area
.
addDock
(
self
.
dWM
,
'bottom'
,
self
.
dPI
)
self
.
area
.
addDock
(
self
.
dPI
,
'bottom'
,
self
.
dWM
)
self
.
area
.
addDock
(
self
.
d397_scan
,
'right'
,
self
.
d397
)
#self.area.addDock(self.d397_scan, 'right', self.d397)
self
.
area
.
addDock
(
self
.
d423_scan
,
'right'
,
self
.
dPI
)
self
.
area
.
addDock
(
self
.
d423_scan
,
'right'
,
self
.
dPI
)
self
.
area
.
addDock
(
self
.
d866_scan
,
'right'
,
self
.
d866
)
#
self.area.addDock(self.d866_scan, 'right', self.d866)
self
.
area
.
addDock
(
self
.
dactivate
,
'right'
,
self
.
dtrap_electrodes
)
#
self.area.addDock(self.dactivate, 'right', self.dtrap_electrodes)
self
.
area
.
moveDock
(
self
.
dWM
,
'above'
,
self
.
dtrap_electrodes
)
#
self.area.moveDock(self.dWM, 'above', self.dtrap_electrodes)
# Here I add the layouts to the corresponding dock
# Here I add the layouts to the corresponding dock
self
.
d397
.
addWidget
(
self
.
layout397
)
#
self.d397.addWidget(self.layout397)
self
.
d866
.
addWidget
(
self
.
layout866
)
#
self.d866.addWidget(self.layout866)
self
.
dPI
.
addWidget
(
self
.
layoutPI
)
self
.
dPI
.
addWidget
(
self
.
layoutPI
)
self
.
dWM
.
addWidget
(
self
.
layoutWM
)
self
.
dWM
.
addWidget
(
self
.
layoutWM
)
self
.
d397_scan
.
addWidget
(
self
.
layout397_scan
)
#
self.d397_scan.addWidget(self.layout397_scan)
self
.
d866_scan
.
addWidget
(
self
.
layout866_scan
)
#
self.d866_scan.addWidget(self.layout866_scan)
self
.
d423_scan
.
addWidget
(
self
.
layout423_scan
)
self
.
d423_scan
.
addWidget
(
self
.
layout423_scan
)
self
.
dtrap_electrodes
.
addWidget
(
self
.
layout_trap_electrodes
)
#
self.dtrap_electrodes.addWidget(self.layout_trap_electrodes)
self
.
dactivate
.
addWidget
(
self
.
layout_activate
)
#
self.dactivate.addWidget(self.layout_activate)
############ creating the controls ########################
############ creating the controls ########################
...
@@ -100,7 +101,7 @@ class GuiMainWindow(QMainWindow):
...
@@ -100,7 +101,7 @@ class GuiMainWindow(QMainWindow):
self
.
piezoB397
=
anal_control_signal
(
'piezoB397'
,
7
,
out_step
=
0.01
)
self
.
piezoB397
=
anal_control_signal
(
'piezoB397'
,
7
,
out_step
=
0.01
)
self
.
piezoA866
=
anal_control_signal
(
'piezoA866'
,
14
,
out_minimum
=
0
,
out_maximum
=
4
,
out_step
=
0.01
)
self
.
piezoA866
=
anal_control_signal
(
'piezoA866'
,
14
,
out_minimum
=
0
,
out_maximum
=
4
,
out_step
=
0.01
)
self
.
piezoB866
=
anal_control_signal
(
'piezoB866'
,
6
,
out_step
=
0.01
)
self
.
piezoB866
=
anal_control_signal
(
'piezoB866'
,
6
,
out_step
=
0.01
)
self
.
piezoA423
=
anal_control_signal
(
'piezoA423'
,
1
,
out_step
=
0.01
)
self
.
piezoA423
=
anal_control_signal
(
'piezoA423'
,
1
,
out_step
=
0.01
,
feedfoward_channel
=
8
)
self
.
trapDCA
=
anal_control_signal
(
'DC A'
,
2
)
self
.
trapDCA
=
anal_control_signal
(
'DC A'
,
2
)
self
.
trapDCB
=
anal_control_signal
(
'DC B'
,
3
)
self
.
trapDCB
=
anal_control_signal
(
'DC B'
,
3
)
...
@@ -117,7 +118,7 @@ class GuiMainWindow(QMainWindow):
...
@@ -117,7 +118,7 @@ class GuiMainWindow(QMainWindow):
#############Toolbar and initial loading of config ############################
#############Toolbar and initial loading of config ############################
toolbar
=
myToolbarMenu
(
self
.
win
,
anal_control_signal
.
_registry
)
toolbar
=
myToolbarMenu
(
self
.
win
,
anal_control_signal
.
_registry
)
print
(
'Defined analog outputs:
\n
'
,
toolbar
.
aosDicc
.
keys
())
###############################################################################
###############################################################################
#here I connect the spinboxes to the daq analog outputs:
#here I connect the spinboxes to the daq analog outputs:
for
ao
in
anal_control_signal
.
_registry
:
for
ao
in
anal_control_signal
.
_registry
:
...
@@ -178,6 +179,10 @@ class GuiMainWindow(QMainWindow):
...
@@ -178,6 +179,10 @@ class GuiMainWindow(QMainWindow):
self
.
layout423_scan
.
addWidget
(
self
.
piezoA423
.
scanLabelValue
,
5
,
0
)
self
.
layout423_scan
.
addWidget
(
self
.
piezoA423
.
scanLabelValue
,
5
,
0
)
self
.
layout423_scan
.
addWidget
(
self
.
piezoA423
.
scanpBar
,
5
,
1
)
self
.
layout423_scan
.
addWidget
(
self
.
piezoA423
.
scanpBar
,
5
,
1
)
self
.
layout423_scan
.
addWidget
(
self
.
piezoA423
.
scan_feedfoward_button
,
6
,
0
)
self
.
layout423_scan
.
addWidget
(
self
.
piezoA423
.
scan_feedfoward_sb
,
6
,
1
)
#########################
#########################
######### trap electrodes ###########
######### trap electrodes ###########
...
...
myWidgets.py
View file @
0c2f0791
...
@@ -9,7 +9,7 @@ import pyqtgraph as pg
...
@@ -9,7 +9,7 @@ import pyqtgraph as pg
from
ADoutputs
import
daq_AO
,
daq_DO
from
ADoutputs
import
daq_AO
,
daq_DO
from
pyqtgraph.Qt
import
QtGui
,
QtCore
from
pyqtgraph.Qt
import
QtGui
,
QtCore
from
PyQt5.QtCore
import
QTimer
from
PyQt5.QtCore
import
QTimer
from
PyQt5.QtWidgets
import
(
QPushButton
,
QWidget
,
QVBoxLayout
,
QLCDNumber
,
QProgressBar
,
QLabel
)
from
PyQt5.QtWidgets
import
(
QPushButton
,
QWidget
,
QVBoxLayout
,
QLCDNumber
,
QProgressBar
,
QLabel
,
QCheckBox
)
import
telnetlib
import
telnetlib
import
os
import
os
from
messages
import
show_warning
from
messages
import
show_warning
...
@@ -20,13 +20,14 @@ import scanFunctions
...
@@ -20,13 +20,14 @@ import scanFunctions
class
anal_control_signal
(
QWidget
):
class
anal_control_signal
(
QWidget
):
_registry
=
[]
_registry
=
[]
def
__init__
(
self
,
name
,
channel
,
out_minimum
=
-
10
,
out_maximum
=
10
,
out_step
=
0.1
):
def
__init__
(
self
,
name
,
channel
,
out_minimum
=
-
10
,
out_maximum
=
10
,
out_step
=
0.1
,
feedfoward_channel
=
None
):
super
()
.
__init__
()
super
()
.
__init__
()
self
.
_registry
.
append
(
self
)
self
.
_registry
.
append
(
self
)
self
.
name
=
name
self
.
name
=
name
self
.
ch
=
channel
self
.
ch
=
channel
self
.
feedfoward_channel
=
feedfoward_channel
self
.
initial_value
=
0
self
.
initial_value
=
0
...
@@ -39,13 +40,13 @@ class anal_control_signal(QWidget):
...
@@ -39,13 +40,13 @@ class anal_control_signal(QWidget):
self
.
sb
=
pg
.
SpinBox
(
value
=
self
.
initial_value
,
bounds
=
[
self
.
min
,
self
.
max
],
step
=
self
.
step
,
siPrefix
=
self
.
siPrefix
,
suffix
=
self
.
suffix
)
self
.
sb
=
pg
.
SpinBox
(
value
=
self
.
initial_value
,
bounds
=
[
self
.
min
,
self
.
max
],
step
=
self
.
step
,
siPrefix
=
self
.
siPrefix
,
suffix
=
self
.
suffix
)
try
:
try
:
self
.
AO
=
daq_AO
(
self
.
ch
)
self
.
AO
=
daq_AO
(
self
.
ch
)
if
feedfoward_channel
:
self
.
AO_feedfoward
=
daq_AO
(
self
.
feedfoward_channel
)
except
:
except
:
show_warning
(
'Analog output
%
i not found. Daq might not be connected'
%
self
.
ch
)
show_warning
(
'Analog output
%
i not found. Daq might not be connected'
%
self
.
ch
)
self
.
scan_button
=
QPushButton
(
'Start scan'
)
self
.
scan_button
=
QPushButton
(
'Start scan'
)
self
.
ScanTimer
=
QTimer
()
self
.
ScanTimer
=
QTimer
()
...
@@ -72,6 +73,11 @@ class anal_control_signal(QWidget):
...
@@ -72,6 +73,11 @@ class anal_control_signal(QWidget):
self
.
scan_sb_start
.
setMinimumHeight
(
22
)
self
.
scan_sb_start
.
setMinimumHeight
(
22
)
self
.
scan_sb_stop
.
setMinimumHeight
(
22
)
self
.
scan_sb_stop
.
setMinimumHeight
(
22
)
self
.
scan_feedfoward_button
=
QCheckBox
(
'Feedfoward'
)
self
.
scan_feedfoward_sb
=
pg
.
SpinBox
(
value
=
0
,
bounds
=
[
0
,
1
],
step
=
0.02
)
self
.
scan_feedfoward_sb
.
setMinimumHeight
(
22
)
self
.
scan_feedfoward_step
=
0
self
.
scan_feedfoward_analogOut
=
None
def
sb_analog_change
(
self
):
def
sb_analog_change
(
self
):
self
.
AO
.
set_out
(
self
.
sb
.
val
)
self
.
AO
.
set_out
(
self
.
sb
.
val
)
...
@@ -99,6 +105,10 @@ class anal_control_signal(QWidget):
...
@@ -99,6 +105,10 @@ class anal_control_signal(QWidget):
self
.
scan_step
=
next
(
self
.
scan_array_gen
)
self
.
scan_step
=
next
(
self
.
scan_array_gen
)
self
.
AO
.
set_out
(
self
.
scan_step
)
self
.
AO
.
set_out
(
self
.
scan_step
)
if
self
.
scan_feedfoward_button
.
isChecked
():
self
.
scan_feedfoward_step
=
next
(
self
.
scan_array_feedfoward_gen
)
self
.
AO_feedfoward
.
set_out
(
self
.
scan_feedfoward_step
)
def
PbarEvent
(
self
):
def
PbarEvent
(
self
):
try
:
try
:
...
@@ -127,9 +137,21 @@ class anal_control_signal(QWidget):
...
@@ -127,9 +137,21 @@ class anal_control_signal(QWidget):
dt
=
5.0e-3
dt
=
5.0e-3
first_value
=
float
(
self
.
sb
.
val
)
first_value
=
float
(
self
.
sb
.
val
)
self
.
scan_array
=
scanFunctions
.
create_scan_array
(
self
.
scan_sb_start
.
val
,
self
.
scan_sb_stop
.
val
,
self
.
scan_sb_period
.
val
,
first_value
,
dt
)
self
.
scan_array
=
scanFunctions
.
create_scan_array
(
self
.
scan_sb_start
.
val
,
self
.
scan_sb_stop
.
val
,
self
.
scan_sb_period
.
val
,
first_value
,
dt
)
self
.
scan_array_gen
=
scanFunctions
.
yield_scan_array
(
self
.
scan_array
)
self
.
scan_array_gen
=
scanFunctions
.
yield_scan_array
(
self
.
scan_array
)
self
.
scan_array_feedfoward
=
scanFunctions
.
create_scan_array
(
self
.
scan_sb_start
.
val
,
self
.
scan_sb_stop
.
val
,
self
.
scan_sb_period
.
val
,
first_value
,
dt
,
normalized
=
True
,
normalization_constant
=
float
(
self
.
scan_feedfoward_sb
.
val
)
)
self
.
scan_array_feedfoward_gen
=
scanFunctions
.
yield_scan_array
(
self
.
scan_array_feedfoward
)
import
pylab
as
plt
plt
.
figure
()
plt
.
plot
(
self
.
scan_array
,
label
=
'scan'
)
plt
.
plot
(
self
.
scan_array_feedfoward
,
label
=
'feedfoward'
)
plt
.
legend
()
plt
.
show
()
if
first_value
>
float
(
self
.
scan_sb_stop
.
val
)
or
first_value
<
float
(
self
.
scan_sb_start
.
val
):
if
first_value
>
float
(
self
.
scan_sb_stop
.
val
)
or
first_value
<
float
(
self
.
scan_sb_start
.
val
):
details
=
'Remember remember the fifth of November.'
+
'
\n
'
+
'Also remember that scan starts from the value of the corresponding spin box'
details
=
'Remember remember the fifth of November.'
+
'
\n
'
+
'Also remember that scan starts from the value of the corresponding spin box'
...
@@ -147,7 +169,8 @@ class anal_control_signal(QWidget):
...
@@ -147,7 +169,8 @@ class anal_control_signal(QWidget):
def
set_scan_feedfoward_analog_out
(
self
,
analogOut
):
self
.
scan_feedfoward_analogOut
=
analogOut
...
...
scanFunctions.py
View file @
0c2f0791
...
@@ -11,21 +11,35 @@ Auxiliary functions for performing scans in a cleaner way
...
@@ -11,21 +11,35 @@ Auxiliary functions for performing scans in a cleaner way
import
numpy
as
np
import
numpy
as
np
def
create_scan_array
(
scan_start
,
scan_stop
,
scan_period
,
first_value
,
dt
):
def
create_scan_array
(
scan_start
,
scan_stop
,
scan_period
,
first_value
,
dt
,
normalized
=
False
,
normalization_constant
=
0
):
"""
"""
Returns the array that represents one period of the scan, including up and down paths of the triangle.
Returns the array that represents one period of the scan, including up and down paths of the triangle.
The first_value param is were the scan actually starts. The scan_start and scan_top give the range.
The first_value param is were the scan actually starts. The scan_start and scan_top give the range.
If normalized is true, then it returns the array from 1 to -1 (including up and down paths) multiplied by
the value normalization_constant
"""
"""
scan_start
=
float
(
scan_start
)
scan_start
=
float
(
scan_start
)
scan_stop
=
float
(
scan_stop
)
scan_stop
=
float
(
scan_stop
)
scan_period
=
float
(
scan_period
)
scan_period
=
float
(
scan_period
)
number_of_points
=
1
+
(
scan_period
+
dt
)
//
(
2
*
dt
)
number_of_points
=
1
+
(
scan_period
+
dt
)
//
(
2
*
dt
)
scan_array_norm
=
np
.
linspace
(
1
*
normalization_constant
,
-
1
*
normalization_constant
,
int
(
number_of_points
)
)
scan_array_norm
=
np
.
concatenate
((
scan_array_norm
,
np
.
flip
(
scan_array_norm
,
0
)[
1
:]))
scan_array
=
np
.
linspace
(
scan_start
,
scan_stop
,
int
(
number_of_points
))
scan_array
=
np
.
linspace
(
scan_start
,
scan_stop
,
int
(
number_of_points
))
scan_array
=
np
.
concatenate
((
scan_array
,
np
.
flip
(
scan_array
,
0
)[
1
:]))
scan_array
=
np
.
concatenate
((
scan_array
,
np
.
flip
(
scan_array
,
0
)[
1
:]))
starting_index
=
np
.
abs
(
scan_array
-
first_value
)
.
argmin
()
+
1
starting_index
=
np
.
abs
(
scan_array
-
first_value
)
.
argmin
()
+
1
scan_array
=
np
.
roll
(
scan_array
,
starting_index
)
scan_array
=
np
.
roll
(
scan_array
,
starting_index
)
scan_array_norm
=
np
.
roll
(
scan_array_norm
,
starting_index
)
if
normalized
:
return
scan_array_norm
else
:
return
scan_array
return
scan_array
def
_yield_array
(
arr
):
def
_yield_array
(
arr
):
...
...
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