Commit 113ec3bc authored by Fredrik Bagge Carlson's avatar Fredrik Bagge Carlson
Browse files

Update readme

parent 0dc7086c
# LabProcesses
This package contains an (programming- as well as connection-) interface to serve
as a base for the implementation of lab-process software. The first exampel of
an implementaiton of this interface is for the ball-and-beam process, which is
used in Lab1 FRTN35: frequency response analysis of the beam. The lab is implemented
in [BallAndBeam.jl](, a
package that makes use of `LabProcesses.jl` to handle the communication with
the lab process and/or a simulated version thereof. This way, the code written
for frequency response analysis of the beam can be run on another process
implementing the same interface (or a simulated version) by changeing a single
line of code :)
Under development /Bagge
## Installation
1. Start julia
2. Install LabProcesses.jl using command Pkg.clone("") Lots of packages will now be installed, this will take some time.
## How to implement a new process
1. Locate the file [interface.jl](
2. Copy all function definitions.
3. Create a new file under `/interface_implementations` where you paste all the
copied definitions and implement them. See [`/interface_implementations/ballandbeam.jl`]( for an example.
4. Above all function implementations you must define the process type, e.g,
struct BallAndBeam <: PhysicalProcess
BallAndBeam() = BallAndBeam(0.01) # Constructor with default value of sample time
Make sure you inherit from `PhysicalProcess` or `SimulatedProcess` as appropriate.
5. Documentation of all interface functions is available in the file [interface_documentation.jl](
## Control a process
The interface `AbstractProcess` defines the functions `control(P, u)` and `measure(P)`.
These functions can be used to implement your own control loops. A common loop
with a feedback controller and a feedforward filter on the reference is implemented
in the function [`run_control_2DOF`](@ref).
The macro `@periodically` might come in handy if you want to implement your own loop.
Consider the following example, in which the loop body will be run periodically
with a sample time of `h` seconds.
for (i,t) = enumerate(0:h:duration)
@periodically h begin
y[i] = measure(P)
r[i] = reference(t)
u[i] = control(i)
control(P, u[i])
Often one finds the need to implement a stateful controller, i.e., a function
that has a memory or state. To this end, the function [`sysfilter`](@ref) is
provided. Usage is demonstrated below
stateC = init_sysfilter(C)
function control(i)
e = r[i]-y[i]
ui = sysfilter!(stateC, C, e)
`C` must here be represented by a [`StateSpace`](@ref) type from [`ControlSystems.jl`](
`TransferFunction` types can easily be converted to a `StateSpace` by `Gss = ss(Gtf)`.
......@@ -16,6 +16,7 @@ abstract type AbstractProcess end
abstract type PhysicalProcess <: AbstractProcess end
abstract type SimulatedProcess <: AbstractProcess end
## Function definitions =====================================================================
num_outputs(p::AbstractProcess) = error("Function not implemented for $(typeof(p))")
num_inputs(p::AbstractProcess) = error("Function not implemented for $(typeof(p))")
outputrange(p::AbstractProcess) = error("Function not implemented for $(typeof(p))")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment