Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drivers
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
Container registry
Model registry
Operate
Environments
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Labber-I2A
Drivers
Commits
67598274
Commit
67598274
authored
Aug 31, 2020
by
Timo Bisswanger
Browse files
Options
Downloads
Patches
Plain Diff
Provide current py version running
parent
6ae33438
Branches
Branches containing commit
No related tags found
1 merge request
!12
Ag spin general
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Bruker_B-MC1/Bruker_B-MC1.py
+96
-0
96 additions, 0 deletions
Bruker_B-MC1/Bruker_B-MC1.py
with
96 additions
and
0 deletions
Bruker_B-MC1/Bruker_B-MC1.py
0 → 100644
+
96
−
0
View file @
67598274
#!/usr/bin/env python
#editor Timo B.
#self.wait(0.1) ## added to reduce fails due to communication losses
import
InstrumentDriver
from
VISA_Driver
import
VISA_Driver
import
visa
from
InstrumentConfig
import
InstrumentQuantity
__version__
=
"
0.0.1
"
class
Error
(
Exception
):
pass
class
Driver
(
VISA_Driver
):
"""
This class implements the Lakeshore 475 driver
"""
def
performOpen
(
self
,
options
=
{}):
"""
Perform the operation of opening the instrument connection
"""
VISA_Driver
.
performOpen
(
self
,
options
=
options
)
def
performClose
(
self
,
bError
=
False
,
options
=
{}):
"""
Perform the operation of opening the instrument connection
"""
self
.
writeAndLog
(
"
PTC= 0.
"
)
VISA_Driver
.
performClose
(
self
,
bError
,
options
=
options
)
def
performGetValue
(
self
,
quant
,
options
=
{}):
"""
Perform the Get Value instrument operation
"""
try
:
if
(
quant
.
name
in
(
'
Output unit
'
,
'
Absolute deviation
'
,
'
Relative deviation
'
,
'
offset in B-Field calculation
'
)):
return
quant
.
getValue
()
value
=
self
.
askAndLog
(
quant
.
get_cmd
)
l
=
value
.
split
(
'
'
)
if
len
(
l
)
<
2
:
return
0
value
=
float
(
l
[
-
1
])
if
l
[
0
]
==
'
-
'
:
value
=
(
-
1
)
*
value
if
(
quant
.
name
in
(
'
B-Field
'
)):
offset
=
self
.
getValue
(
'
offset in B-Field calculation
'
)
#7mT war bei test und ist jetzt standard
params
=
[
-
2.14236783e-04
,
-
1.32015291e-03
,
1.80024778e+01
,
-
5.85129355e+00
]
magfield
=
params
[
3
]
+
params
[
2
]
*
value
+
params
[
1
]
*
value
**
2
+
params
[
0
]
*
value
**
3
magfield
=
round
(
magfield
,
3
)
magfield
-=
offset
return
magfield
return
value
except
Error
as
e
:
return
quant
.
getValue
()
#0.1A + 1% von set wert
def
performSetValue
(
self
,
quant
,
value
,
sweepRate
=
0.0
,
options
=
{}):
"""
Perform the set value operation
"""
# check type of quantity
try
:
if
(
quant
.
name
in
(
'
B-Field
'
,
'
Current
'
)):
deviation
=
[
self
.
getValue
(
'
Absolute deviation
'
),
self
.
getValue
(
'
Relative deviation
'
)
/
100
]
#0.1A + 1% von set wert ist standart
value
=
round
(
float
(
value
),
3
)
if
(
quant
.
name
in
(
'
B-Field
'
)):
offset
=
self
.
getValue
(
'
offset in B-Field calculation
'
)
#7mT war bei test und ist jetzt standart
value
+=
offset
params
=
[
1.87879038e-09
,
2.49701790e-07
,
5.55849318e-02
,
3.27814017e-01
]
current
=
params
[
3
]
+
params
[
2
]
*
value
+
params
[
1
]
*
value
**
2
+
params
[
0
]
*
value
**
3
current
=
round
(
current
,
3
)
self
.
writeAndLog
(
quant
.
set_cmd
.
replace
(
'
<*>
'
,
str
(
current
)))
self
.
wait
(
0.1
)
## added to reduce fails due to communication losses
self
.
waitForReachingValue
(
quant
,
current
,
deviation
)
# here often an error occurs. Chekc the function!
value
-=
offset
else
:
self
.
writeAndLog
(
quant
.
set_cmd
.
replace
(
'
<*>
'
,
str
(
value
)))
self
.
wait
(
0.1
)
## added to reduce fails due to communication losses
self
.
waitForReachingValue
(
quant
,
value
,
deviation
)
elif
(
quant
.
name
in
(
'
max Current Rate
'
)):
self
.
writeAndLog
(
quant
.
set_cmd
.
replace
(
'
<*>
'
,
str
(
round
(
value
,
1
))))
return
value
except
Error
as
e
:
return
value
def
waitForReachingValue
(
self
,
quant
,
value
,
deviation
):
present
=
self
.
askAndLog
(
quant
.
get_cmd
)
l
=
present
.
split
(
'
'
)
if
len
(
l
)
<
2
:
self
.
writeAndLog
(
quant
.
set_cmd
.
replace
(
'
<*>
'
,
str
(
0
)))
l
[
-
1
]
=
'
0
'
present
=
float
(
l
[
-
1
])
avalue
=
abs
(
value
)
while
not
((
avalue
-
deviation
[
0
]
-
deviation
[
1
]
*
avalue
)
<
present
<
(
avalue
+
deviation
[
0
]
+
deviation
[
1
]
*
avalue
))
and
not
self
.
isStopped
()
:
self
.
wait
(
1
)
#wait till new request of current value, set from 0.3 to 1, since the power supply cannot answer so fast
present
=
self
.
askAndLog
(
quant
.
get_cmd
)
l
=
present
.
split
(
'
'
)
present
=
float
(
l
[
-
1
])
if
self
.
isStopped
():
self
.
writeAndLog
(
quant
.
set_cmd
.
replace
(
'
<*>
'
,
str
(
0
)))
if
__name__
==
'
__main__
'
:
pass
\ No newline at end of file
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