Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Martin Heyden
LabProcesses.jl
Commits
23c78b4d
Commit
23c78b4d
authored
Aug 21, 2017
by
Fredrik Bagge Carlson
Browse files
Bugfixes from lab
parent
6313360a
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/LabProcesses.jl
View file @
23c78b4d
__precompile__
()
#
__precompile__()
module
LabProcesses
...
...
src/controllers.jl
View file @
23c78b4d
...
...
@@ -15,10 +15,8 @@ function run_control_2DOF(P::AbstractProcess,sysFB, sysFF=nothing; duration = 10
u
=
zeros
(
0
:
h
:
duration
)
r
=
zeros
(
0
:
h
:
duration
)
sysFB
=
minreal
(
sysFB
)
stateFB
=
init_sysfilter
(
sysFB
)
if
sysFF
!=
nothing
sysFF
=
minreal
(
sysFF
)
stateFF
=
init_sysfilter
(
sysFF
)
end
...
...
@@ -33,7 +31,7 @@ function run_control_2DOF(P::AbstractProcess,sysFB, sysFF=nothing; duration = 10
@periodically
h
begin
y
[
i
]
=
measure
(
P
)
r
[
i
]
=
reference
(
t
)
u
[
i
]
=
control
(
i
)
# y,r must be updated before u
u
[
i
]
.
=
control
(
i
)
# y,r must be updated before u
control
(
P
,
u
[
i
])
end
end
...
...
src/interface_implementations/ballandbeam.jl
View file @
23c78b4d
...
...
@@ -29,12 +29,12 @@ measure(p::BallAndBeam) = io2num(ccall((:comedi_read,comedipath), Int32,
control
(
p
::
BallAndBeamSimulator
,
u
)
=
error
(
"Not yet implemented"
)
measure
(
p
::
BallAndBeamSimulator
)
=
error
(
"Not yet implemented"
)
const
comedipath
=
"../c/
comedi_bridge.so"
const
comedipath
=
Pkg
.
dir
(
"LabProcesses"
,
"c"
,
"
comedi_bridge.so"
)
const
conversion
=
65535
/
20
io2num
(
x
)
=
x
/
conversion
-
10
# Converts from io to float
num2io
(
x
)
=
round
(
Int32
,
x
*
100
+
2050
)
# Converts from regular number to io
initialize
(
p
::
BallAndBeam
)
=
ccall
((
:
comedi_start
,
comedipath
),
Int32
,(
Int32
,),
0
)
finalize
(
p
::
BallAndBeam
)
=
(
control
(
P
,
0
);
ccall
((
:
comedi_stop
,
"../c/comedi_bridge.so"
),
Int32
,(
Int32
,),
0
))
finalize
(
p
::
BallAndBeam
)
=
(
control
(
p
,
0
);
ccall
((
:
comedi_stop
,
comedipath
),
Int32
,(
Int32
,),
0
))
initialize
(
p
::
BallAndBeamSimulator
)
=
nothing
finalize
(
p
::
BallAndBeamSimulator
)
=
nothing
src/utilities.jl
View file @
23c78b4d
...
...
@@ -9,7 +9,7 @@ macro periodically(h, body)
local
start_time
=
time
()
$
(
esc
(
body
))
local
execution_time
=
time
()
-
start_time
sleep
(
max
(
0
,
$
h
-
execution_time
))
sleep
(
max
(
0
,
$
(
esc
(
h
))
-
execution_time
))
end
end
...
...
Write
Preview
Supports
Markdown
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