## Software for the teaching of (and tinkering with) Control Theory and Control Systems

I recently picked up a few control theory books from the University library to support a project I am involved with right now and was interested in the seemingly total dominance of MATLAB in this subject area. Since I’m not an expert in control systems, I’m not sure if this is because MATLAB is genuinely the best tool for the job or if it’s simply because it’s been around for a very long time and so has become entrenched. Comments from anyone who works in relevant fields would be most welcome.

On its own, MATLAB is insufficient to teach introductory control systems courses — you also need the control systems toolbox as a bare minimum but most books and courses also seem to require Simulink and the symbolic math toolbox. All of these are included in the student edition of MATLAB which is very reasonably priced.

If you are not a registered student, however, and don’t work for someone who can provide you with MATLAB it’s going to be very expensive! As far as I can tell, your only option would be to purchase commercial licenses which are very expensive (as in thousands of dollars/pounds for MATLAB and a few toolboxes).

**What else is out there?**

I have a strong interest in mathematical software and so I know that there are several products that have support for control theory. Here are some that I know of and have access to myself

- Mathematica – Its symbolic math support far exceeds that of MATLAB and it is on an equal footing numerically but its control systems support is much more recent and I don’t know of a textbook that utilizes it. One benefit of Mathematica is that it doesn’t separate functionality out into toolboxes – everything is just built in. Another benefit to tinkerers is the home edition which gives you the full product at a much lower price than commercial licenses.
- Maple – This also has very strong symbolic and numeric math support. It also comes with some Control Systems support built in. Like Mathematica, it has a home edition for non-commercial tinkering and learning.
- Labview – A graphical programming language that I’m only just starting to get used to. It has lots of users and advocates in my employers electrical and mechanical engineering departments. There is no support for symbolic computing as far as I know.
- Python – Python is a superb general purpose scripting language that’s also completely free. Numerics are taken care of by Numpy, symbolics by Sympy and there is a control theory module, the development of which is coordinated by Richard Murray of Caltech (The same Richard Murray that co-wrote the book Feedback Systems: An Introduction for Scientists and Engineers).
- Octave – Octave is a free implementation of the MATLAB .m language. It also has a free control package.
- Scilab – Scilab is a free numerical environment that also has a free control package.

I haven’t mentioned Simulink alternatives in this post since I’ve discussed them before.

**Questions**

Some questions that arise are

- Are there any other alternatives to those listed above?
- Do these alternatives have sufficient functionality to support undergraduate courses in control systems and control theory?
- What would be the best language to use if you were teaching control systems as a Massively Open Online Course (MOOC)?
- Does it matter to employers which computational language you learned your control systems in as an undergraduate?

I find that the final point is very divisive among people I discuss it with. On the one hand you have those who say ‘It’s the concepts that matter, the language you choose to implement them in is much less important’ and on the other hand you have those who say ‘It’s gotta be MATLAB, my father used MATLAB and his grandfather before him. Industry uses MATLAB, I only know MATLAB, we must teach MATLAB.’

i think an intro course should not use anything that has a control package. these control packages make the control problems almost trivial. the problems should be solved sans tool box so that student understands what goes into the solution.

I’ve used MATLAB for controls in school and in industry (as well as Simulink). It originated as a tool for controls and signal processing. It’s developers know those domains really well and the tools are really good for those domains. That and the fact that it beat out other options in those domains long ago makes it the defacto standard.

But Python is rising rapidly in scientific and analytic computing, especially in academia and education. Over time I think we will see it used more and more. It’s power as a programming language makes it a much better alternative for any kind of application or software development. And even in core controls or signal processing research and design, while MATLAB remains entrenched, Python’s versatility and inevitable improvement make it an attractive alternative.

I work in controls in aerospace. I find that most of the recent graduates in controls have Matlab experience. However, we still do a lot of our analysis work with FORTRAN. We implement the controls in C and C++.

From an employer’s perspective, I have only hired controls engineers with C/C++ experience. We find that knowing how to program in C/C++ is necessary for a complete understanding of how an algorithm is actually implemented on the flight hardware.

But, every analyst seems to have their own tool preferences. The pure analysts and younger engineers tend to use Matlab and simulink. The people who work closer to the hardware and flight systems favor C++ and FORTRAN with some python scripting to automate post-processing.

The Mathematica control toolbox is very good in those areas it provides support for; its Nyquist plots, for example, are much better than Matlab’s since it displays loops at infinite radius correctly (while Matlab simply omits them entirely).

But having a control toolbox to handle the theory is only one half of the story. While Matlab isn’t my favourite programming environment, the reason we couldn’t think of switching from it in our school is that it also provides very good support for hardware IO via dSpace, XPC, or Windows real-time targets.

This allows a complete analysis in which students can simulate a system, animate it in a VR model, design and tune a controller, and then finally switch to actual hardware and perform real-time control. (In much shorter time that it would take them to derive the control theory and then learn to program a microcontroller in C.)

I’d be interested to hear of solutions that cover algorithms (the “toolbox”), simulation (simulink), and hardware IO to the same degree.

When I took a Control Systems course during my undergrad course, our professor had come up with a tool, written in Python, that we used for doing basic stuff (testing simple controllers, verifying the effects of tweaking the parameters on the root locus, impulse and step responses, etc). It seems it was not updated in a while, but it was a nice tool.

This is where the tool’s code is hosted: http://code.google.com/p/labcontrole/

Question is whether you prefer a dedicated language to teach/model control systems only, or whether you consider embedding such control system into a bigger system and map it onto an implementation in the analog, digital HW and/or software domain. If this is the case, I would recommend looking into SystemC, in particular the AMS extensions (SystemC-AMS). SystemC is a class library build on top of C++ and introduces discrete-event simulation semantics to model HW. The AMS extensions offer additional models of computation such as linear signal flow to model control systems and continuous-time systems. The strength is in the combination to model a AMS+HW+SW system.

SystemC and the AMS extensions are well document as standard (language reference manual), and there are also open source implementations available to get started immediately.

http://www.accellera.org/downloads/standards/systemc/

http://www.accellera.org/downloads/standards/systemc/ams/

@will: And in order to bridge the gap to real-time hardware in the loop, Fraunhofer IIS/EAS offers a tool and flow to run SystemC/SystemC-AMS models on dSPACE

http://www.dspace.com/en/inc/home/news/iis_tx_2013.cfm