From b1bbe807bb917950ff868369b113e9d379f2edd0 Mon Sep 17 00:00:00 2001
From: Fredrik Bagge Carlsson <cont-frb@ulund.org>
Date: Mon, 21 Aug 2017 14:19:59 +0200
Subject: [PATCH] lab now working

---
 src/controllers.jl                           | 6 +++---
 src/interface_implementations/ballandbeam.jl | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/controllers.jl b/src/controllers.jl
index eef0983..1bdb043 100644
--- a/src/controllers.jl
+++ b/src/controllers.jl
@@ -20,10 +20,10 @@ function run_control_2DOF(P::AbstractProcess,sysFB, sysFF=nothing; duration = 10
 		stateFF = init_sysfilter(sysFF)
 	end
 
-	function control(i)
+	function calc_control(i)
 		rf = sysFF == nothing ? r[i] : sysfilter!(stateFF, sysFF, r[i])
 		e  = rf-y[i]
-		ui = sysfilter!(stateFB, sysFB, e)
+		ui = sysfilter!(stateFB, sysFB, e)[1]
 	end
 
 	initialize(P)
@@ -31,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]       = calc_control(i) # y,r must be updated before u
 			control(P, u[i])
 		end
 	end
diff --git a/src/interface_implementations/ballandbeam.jl b/src/interface_implementations/ballandbeam.jl
index 76d3d75..bdb7786 100644
--- a/src/interface_implementations/ballandbeam.jl
+++ b/src/interface_implementations/ballandbeam.jl
@@ -32,7 +32,7 @@ measure(p::BallAndBeamSimulator)     = error("Not yet implemented")
 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
+num2io(x) = round(Int32,x*100 + 2048)   # 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, comedipath),Int32,(Int32,), 0))
-- 
GitLab