Using Linux in a Control and Robotics Lab
The Mathematics and Engineering program at Queen's University in Kingston, Ontario operates a control and robotics laboratory as part of the course offerings in the control systems area. The lab experiments use our custom-built electro-mechanical setups and require the students to write algorithms in C for controlling the hardware.
The lab began using C under DOS as the software environment for the lab experiments, but not all students had an easy time with the environment. Generally, it was too easy for configuration files to be inadvertently changed with frustrating consequences. Subsequently, an integrated experiment environment known as dlxlab has been developed for simulating and running control lab experiments. It consists of a single program, run as dlxsim for simulations or as dlxrun for controlling hardware experiments. The program was developed using the XView toolkit under Linux (see “Programming with XView” by Michael Hall, LJ, March 1998), and operates in the lab on a variety of PC-compatible hardware running Linux 1.2.13.
The students taking the lab vary widely in computing background and skill. The primary intent of the control labs is to investigate the application of control theory to actual motors, carts, inverted pendula and so on, without having software operation dominate the experience. On the other hand, understanding low-level interfacing code is also a desirable outcome, so the hardware interface has to be “visible”.
In order to design a control algorithm for a physical system, one must have a mathematical model of the system to be controlled in the form of either differential or difference equations, and knowledge of the physical parameters in the model. The user interface to dlxlab was designed so that, as far as possible, this is the only information that must be supplied by the user.
This goal is attained for the case of the program running in simulation mode. For the situation where actual hardware is being controlled, information describing the hardware interface must also be provided, although it can be largely hidden from the user through header files.
The user input to the program takes place through interactive construction of a system file which describes the system under investigation.
To simulate a system, one invokes dlxsim with a system description file as argument.
dlxsim sim.sys &
One of the lab experiments consists of a pair of track-mounted carts, coupled by springs and driven by a servomotor. A simple system file for simulating such a pair of spring-coupled carts is shown in Listing 1. The format of the system file is a sequence of begin ... end delimited blocks. The blocks are of two types:
Definition blocks establishing identifiers for variables (including parameters)
Code blocks containing C code sequences which are executed by the program to initialize variables, as well as numerically integrate the governing differential equations to simulate the system
The main program panel (see Figure 1) contains a “Build” button, which when pressed causes processing of the system file. That is, the user system file is converted into a series of C code files by a parsing process. The files are compiled to a shared object file by gcc, and the contents of the resulting shared object module are dynamically linked into dlxsim as it runs. The linked code contains not just the system differential equations, but also modules for interactively manipulating parameters and plotting results on the basis of the variable names provided in the system file.
Assuming that the system file contains no syntactic errors, the program log window contains only progress messages, and a pop-up panel for controlling simulations appears (Figure 2). As long as only parameter changes are made, a series of simulation runs can be made. Plotting and printing is handled by gnuplot running as a child process.
If the system file contains errors, the error location is reported in the log window, and the pop-up does not appear. The errors are caught either at the parsing level or within the C code segments. In the latter case, the error messages from gcc refer to lines in the user system file, since the generated C files include #line statements referring to the user system file. Since the dlxsim system file edit window is an XView textsw, it inherits the line searching menus associated with XView applications.
Simulations can be run and plotted, as long as the system file contents (such as variable names, equations of motion and so on) are not changed. If such changes are made, the “ReBuild” button must be invoked to cause freeing of resources, recompilation of the dynamic module and relinking of the generated codes.
|Happy Birthday Linux||Aug 25, 2016|
|ContainerCon Vendors Offer Flexible Solutions for Managing All Your New Micro-VMs||Aug 24, 2016|
|Updates from LinuxCon and ContainerCon, Toronto, August 2016||Aug 23, 2016|
|NVMe over Fabrics Support Coming to the Linux 4.8 Kernel||Aug 22, 2016|
|What I Wish I’d Known When I Was an Embedded Linux Newbie||Aug 18, 2016|
|Pandas||Aug 17, 2016|
- Happy Birthday Linux
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- ContainerCon Vendors Offer Flexible Solutions for Managing All Your New Micro-VMs
- What I Wish I’d Known When I Was an Embedded Linux Newbie
- Updates from LinuxCon and ContainerCon, Toronto, August 2016
- New Version of GParted
- NVMe over Fabrics Support Coming to the Linux 4.8 Kernel
- All about printf
- Tor 0.2.8.6 Is Released
- Blender for Visual Effects
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide