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
a4800b2c
Commit
a4800b2c
authored
Nov 13, 2018
by
Martin Drechsler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'changing_scan' of
https://code.df.uba.ar/martindrech/control_app
parents
5a692e01
af8e2b0c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
38 deletions
+91
-38
ADoutputs.py
ADoutputs.py
+18
-6
myWidgets.py
myWidgets.py
+20
-32
scanFunctions.py
scanFunctions.py
+53
-0
No files found.
ADoutputs.py
View file @
a4800b2c
...
@@ -14,17 +14,29 @@ If the daq is not found, whenever trying to send signals, the command will be pr
...
@@ -14,17 +14,29 @@ If the daq is not found, whenever trying to send signals, the command will be pr
import
warnings
import
warnings
from
mcculw
import
ul
try
:
from
mcculw.enums
import
InterfaceType
,
ULRange
,
InfoType
,
BoardInfo
,
DigitalIODirection
from
mcculw
import
ul
from
mcculw.ul
import
ULError
from
mcculw.enums
import
InterfaceType
,
ULRange
,
InfoType
,
BoardInfo
,
DigitalIODirection
from
mcculw.ul
import
ULError
from
props.digital
import
DigitalProps
from
props.ao
import
AnalogOutputProps
from
props.digital
import
DigitalProps
except
ValueError
:
from
props.ao
import
AnalogOutputProps
warnings
.
warn
(
'Problem importing ul from mcculw, Thus might happen in Linux'
)
import
uldaq
as
ul
from
uldaq
import
InterfaceType
from
uldaq
import
Range
as
ULRange
ul
.
ignore_instacal
()
#instacal will be ignored
try
:
ul
.
ignore_instacal
()
#instacal will be ignored
except
NameError
:
print
(
'Instacall not ignored because mcculw not imported'
)
except
AttributeError
:
print
(
'Instacall not ignored because you imported uldaq and there is no instacal in that case'
)
# First of all, I check which daqs are available and print it.
# First of all, I check which daqs are available and print it.
devices
=
ul
.
get_daq_device_inventory
(
interface_type
=
InterfaceType
.
USB
)
devices
=
ul
.
get_daq_device_inventory
(
interface_type
=
InterfaceType
.
USB
)
if
len
(
devices
)
==
1
:
if
len
(
devices
)
==
1
:
...
...
myWidgets.py
View file @
a4800b2c
...
@@ -14,6 +14,8 @@ import telnetlib
...
@@ -14,6 +14,8 @@ import telnetlib
import
os
import
os
from
messages
import
show_warning
from
messages
import
show_warning
import
scanFunctions
#An example of a class
#An example of a class
class
anal_control_signal
(
QWidget
):
class
anal_control_signal
(
QWidget
):
_registry
=
[]
_registry
=
[]
...
@@ -59,7 +61,6 @@ class anal_control_signal(QWidget):
...
@@ -59,7 +61,6 @@ class anal_control_signal(QWidget):
self
.
scan_sb_stop
=
pg
.
SpinBox
(
value
=
0
,
bounds
=
[
self
.
min
,
self
.
max
],
step
=
self
.
step
,
siPrefix
=
self
.
siPrefix
,
suffix
=
self
.
suffix
)
self
.
scan_sb_stop
=
pg
.
SpinBox
(
value
=
0
,
bounds
=
[
self
.
min
,
self
.
max
],
step
=
self
.
step
,
siPrefix
=
self
.
siPrefix
,
suffix
=
self
.
suffix
)
self
.
scan_sb_period
=
pg
.
SpinBox
(
value
=
1
,
bounds
=
[
0
,
100
],
step
=
0.1
,
siPrefix
=
True
,
suffix
=
's'
)
self
.
scan_sb_period
=
pg
.
SpinBox
(
value
=
1
,
bounds
=
[
0
,
100
],
step
=
0.1
,
siPrefix
=
True
,
suffix
=
's'
)
self
.
scan_direction
=
0
self
.
scan_button
.
clicked
.
connect
(
self
.
doScanAction
)
self
.
scan_button
.
clicked
.
connect
(
self
.
doScanAction
)
...
@@ -94,62 +95,51 @@ class anal_control_signal(QWidget):
...
@@ -94,62 +95,51 @@ class anal_control_signal(QWidget):
def
scanEvent
(
self
):
def
scanEvent
(
self
):
if
float
(
self
.
scan_step
)
<
float
(
self
.
scan_sb_start
.
val
)
or
float
(
self
.
scan_step
)
>
float
(
self
.
scan_sb_stop
.
val
):
self
.
scan_direction
=
(
-
1
)
*
self
.
scan_direction
self
.
scan_step
=
self
.
scan_step
+
self
.
scan_direction
self
.
scan_step
=
next
(
self
.
scan_array_gen
)
self
.
AO
.
set_out
(
self
.
scan_step
)
self
.
AO
.
set_out
(
self
.
scan_step
)
#print(self.scan_step)
def
PbarEvent
(
self
):
def
PbarEvent
(
self
):
try
:
try
:
self
.
scanpBar
.
setValue
(
100
*
float
(
self
.
scan_step
-
float
(
self
.
scan_sb_start
.
val
))
/
float
(
self
.
scan_sb_stop
.
val
-
self
.
scan_sb_start
.
val
)
)
self
.
scanpBar
.
setValue
(
100
*
float
(
self
.
scan_step
-
float
(
self
.
scan_sb_start
.
val
))
/
float
(
self
.
scan_sb_stop
.
val
-
self
.
scan_sb_start
.
val
)
)
self
.
scanLabelValue
.
setText
(
"
%.2
f"
%
self
.
scan_step
+
' V'
)
self
.
scanLabelValue
.
setText
(
"
%.2
f"
%
self
.
scan_step
+
' V'
)
except
ZeroDivisionError
:
except
ZeroDivisionError
:
self
.
doScanAction
()
self
.
doScanAction
()
#print('Oh dear, you might be trying to scan from 0 to 0. Plase never do that again. ')
show_warning
(
'Oh dear, you might be trying to scan from 0 to 0. Plase never do that again.'
)
show_warning
(
'Oh dear, you might be trying to scan from 0 to 0. Plase never do that again.'
)
def
doScanAction
(
self
):
def
doScanAction
(
self
):
#self.scan_direction = -float( (self.scan_sb_stop.val-self.scan_sb_start.val)/self.scan_sb_period.val ) * 5e-3 * 2
#self.scan_step = float(self.scan_sb_start.val)
if
self
.
ScanTimer
.
isActive
():
if
self
.
ScanTimer
.
isActive
():
self
.
ScanTimer
.
stop
()
self
.
ScanTimer
.
stop
()
self
.
scan_button
.
setText
(
'Start scan'
)
self
.
scan_button
.
setText
(
'Start scan'
)
self
.
scan_button
.
setStyleSheet
(
'background-color: None'
)
self
.
scan_button
.
setStyleSheet
(
'background-color: None'
)
self
.
PbarTimer
.
stop
()
self
.
PbarTimer
.
stop
()
self
.
sb
.
setEnabled
(
True
)
self
.
sb
.
setValue
(
self
.
scan_step
)
self
.
sb
.
setValue
(
self
.
scan_step
)
self
.
sb
.
setEnabled
(
True
)
self
.
scan_sb_start
.
setEnabled
(
True
)
self
.
scan_sb_stop
.
setEnabled
(
True
)
else
:
else
:
b
=
float
(
self
.
scan_sb_stop
.
val
)
a
=
float
(
self
.
scan_sb_start
.
val
)
dt
=
5.0e-3
dt
=
5.0e-3
T
=
float
(
self
.
scan_sb_period
.
val
)
n
=
int
(
T
/
(
2
*
dt
)
)
self
.
scan_direction
=
-
abs
(
b
-
a
)
/
n
# this is the size in voltage of each step
self
.
scan_step
=
float
(
self
.
sb
.
val
)
# from here it beggins
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_gen
=
scanFunctions
.
yield_scan_array
(
self
.
scan_array
)
if
self
.
scan_step
>
b
or
self
.
scan_step
<
a
:
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'
show_warning
(
'Scan can not start outside scan range and scan start should be lower than scan stop'
,
details_text
=
details
)
show_warning
(
'Scan can not start outside scan range and scan start should be lower than scan stop'
,
details_text
=
details
)
elif
n
<
5
:
elif
len
(
self
.
scan_array
)
<
5
:
show_warning
(
'
%
i steps are too few, you need at least 5 steps'
%
(
n
)
)
show_warning
(
'
%
i steps are too few, you need at least 5 steps'
%
(
len
(
self
.
scan_array
))
)
pass
else
:
else
:
self
.
sb
.
setEnabled
(
False
)
self
.
sb
.
setEnabled
(
False
)
self
.
scan_sb_start
.
setEnabled
(
False
)
self
.
scan_sb_stop
.
setEnabled
(
False
)
self
.
scan_button
.
setStyleSheet
(
"background-color: green"
)
self
.
scan_button
.
setStyleSheet
(
"background-color: green"
)
self
.
PbarTimer
.
start
(
dt
*
1e3
)
self
.
PbarTimer
.
start
(
dt
*
1e3
)
self
.
ScanTimer
.
start
(
dt
*
1e3
)
self
.
ScanTimer
.
start
(
dt
*
1e3
)
...
@@ -213,15 +203,13 @@ class burleighWM(QWidget):
...
@@ -213,15 +203,13 @@ class burleighWM(QWidget):
wavemeter_ok
=
False
wavemeter_ok
=
False
try
:
try
:
tn
=
telnetlib
.
Telnet
(
host
=
"wannanosaurus"
,
port
=
1234
,
timeout
=
1
)
tn
=
telnetlib
.
Telnet
(
host
=
"wannanosaurus"
,
port
=
1234
,
timeout
=
1
)
wavemeter_ok
=
True
except
:
except
:
show_warning
(
'Wannanosaurus not connected'
)
show_warning
(
'Wannanosaurus not connected'
)
if
tn
.
sock_avail
():
wavemeter_ok
=
True
else
:
show_warning
(
'Wannanosaurus seems connected but WM might be off.'
)
if
wavemeter_ok
:
if
wavemeter_ok
:
tn
.
write
(
b
'++eos 1
\n
'
)
tn
.
write
(
b
'++eos 1
\n
'
)
...
...
scanFunctions.py
0 → 100644
View file @
a4800b2c
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 26 11:24:28 2018
@author: martindrech
Auxiliary functions for performing scans in a cleaner way
"""
import
numpy
as
np
def
create_scan_array
(
scan_start
,
scan_stop
,
scan_period
,
first_value
,
dt
):
"""
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.
"""
scan_start
=
float
(
scan_start
)
scan_stop
=
float
(
scan_stop
)
scan_period
=
float
(
scan_period
)
number_of_points
=
1
+
(
scan_period
+
dt
)
//
(
2
*
dt
)
scan_array
=
np
.
linspace
(
scan_start
,
scan_stop
,
int
(
number_of_points
))
scan_array
=
np
.
concatenate
((
scan_array
,
np
.
flip
(
scan_array
,
0
)[
1
:]))
starting_index
=
np
.
abs
(
scan_array
-
first_value
)
.
argmin
()
+
1
scan_array
=
np
.
roll
(
scan_array
,
starting_index
)
return
scan_array
def
_yield_array
(
arr
):
larr
=
len
(
arr
)
cursor
=
0
while
cursor
<
larr
:
yield
arr
[
cursor
]
cursor
=
cursor
+
1
def
yield_scan_array
(
arr
):
while
True
:
yield
from
_yield_array
(
arr
)
#%%
#scan_start = 0
#scan_stop = 1
#scan_period = 1
#first_value = .6
#dt = 0.1
#
#a = create_scan_array(scan_start, scan_stop, scan_period, first_value, dt)
#print(a)
\ No newline at end of file
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