Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RBComb Temperature Control
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
Pascal Engeler
RBComb Temperature Control
Commits
2a49bf81
Commit
2a49bf81
authored
1 year ago
by
Pascal Engeler
Browse files
Options
Downloads
Patches
Plain Diff
Added userfriendlyness with lots of members
parent
ff432432
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
drivers/drivers/pidcontroller.py
+95
-2
95 additions, 2 deletions
drivers/drivers/pidcontroller.py
with
95 additions
and
2 deletions
drivers/drivers/pidcontroller.py
+
95
−
2
View file @
2a49bf81
...
...
@@ -21,13 +21,106 @@ class PidController:
self
.
ser
=
None
print
(
f
"
Failed to open Serial Port
{
self
.
port
}
.
"
)
def
reconnect
(
self
):
try
:
self
.
ser
=
serial
.
Serial
(
self
.
port
,
baudrate
=
9600
,
timeout
=
2
)
self
.
connected
=
True
except
:
self
.
ser
=
None
print
(
f
"
Failed to open Serial Port
{
self
.
port
}
.
"
)
self
.
connected
=
False
def
disconnect
(
self
):
self
.
ser
.
close
()
def
_sendCommand
(
self
,
command
):
self
.
ser
.
write
(
command
.
encode
())
try
:
self
.
ser
.
write
(
command
.
encode
())
except
:
print
(
f
"
Serial port
{
self
.
port
}
is not open.
"
)
return
""
time
.
sleep
(
0.5
)
text
=
""
while
(
self
.
ser
.
in_waiting
):
text
+=
self
.
ser
.
read
().
decode
()
return
text
\ No newline at end of file
return
text
def
getTemperatures
(
self
):
text
=
self
.
_sendCommand
(
'
t
'
)
if
(
text
==
'
!
'
):
return
'
!
'
texts
=
text
.
split
(
'
,
'
)
temps
=
[]
for
t
in
texts
:
if
t
[
-
1
]
==
'
;
'
:
temps
.
append
(
float
(
t
[:
-
1
]))
else
:
temps
.
append
(
float
(
t
))
return
temps
def
getPidCoeff
(
self
):
text
=
self
.
_sendCommand
(
'
p
'
)
if
(
text
==
'
!
'
):
return
'
!
'
texts
=
text
.
split
(
'
,
'
)
coeffs
=
[]
for
t
in
texts
:
if
t
[
-
1
]
==
'
;
'
:
coeffs
.
append
(
float
(
t
[:
-
1
]))
else
:
coeffs
.
append
(
float
(
t
))
return
coeffs
def
getPropIntDer
(
self
):
text
=
self
.
_sendCommand
(
'
v
'
)
if
(
text
==
'
!
'
):
return
'
!
'
texts
=
text
.
split
(
'
,
'
)
prinde
=
[]
for
t
in
texts
:
if
t
[
-
1
]
==
'
;
'
:
prinde
.
append
(
float
(
t
[:
-
1
]))
else
:
prinde
.
append
(
float
(
t
))
return
prinde
def
getOutput
(
self
):
text
=
self
.
_sendCommand
(
'
o
'
)
if
(
text
==
'
!
'
):
return
'
!
'
return
float
(
text
[:
-
1
])
def
getSetpoint
(
self
):
text
=
self
.
_sendCommand
(
'
s
'
)
if
(
text
==
'
!
'
):
return
'
!
'
return
float
(
text
[:
-
1
])
def
setP
(
self
,
pval
):
text
=
self
.
_sendCommand
(
f
'
P
{
pval
}
;
'
)
return
text
def
setI
(
self
,
ival
):
text
=
self
.
_sendCommand
(
f
'
I
{
ival
}
;
'
)
return
text
def
setD
(
self
,
dval
):
text
=
self
.
_sendCommand
(
f
'
D
{
dval
}
;
'
)
return
text
def
setIntegral
(
self
,
integral
):
text
=
self
.
_sendCommand
(
f
'
N
{
integral
}
;
'
)
return
text
def
setTemperature
(
self
,
temperature
):
text
=
self
.
_sendCommand
(
f
'
S
{
temperature
}
;
'
)
return
text
def
setIntResErr
(
self
,
errThresh
):
text
=
self
.
_sendCommand
(
f
'
E
{
errThresh
}
;
'
)
return
text
def
nop
(
self
):
text
=
self
.
_sendCommand
(
f
'
?
'
)
return
text
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