Using Linux in a Control and Robotics Lab

How a lab at Queen's University is using Linux to develop programs and control hardware experiments.
Controlling Actual Hardware

The system file for an actual experiment contains code sections which mediate between floating-point program variables and the binary hardware levels, in addition to the requirements of a simulation file. A file for measuring the response of a servomotor to a constant voltage input is shown in Listing 2. This file illustrates the use of so-called utility code and definition sections in the system file. There is really no restriction on the type of code placed here. The program user guide contains an example of such code written to carry out a recursive least squares identification algorithm using measured data resident in files. The example in Listing 2 is much more modest and uses library include files to abstract the interface board data access.

The include files serve to hide the actual hardware interface behind port access macros like set_dac() for setting digital-to-analog converter levels and get_encoder() for reading the count of the optical quadrature position encoder from the interface boards. The code blocks using these macros are converted to dynamically linked subroutines and repeatedly called by the program main real-time control loop.

This example is really “open loop control” and primarily illustrates the hardware interface provided by the program. Feedback controllers typically employ filtering of the measured data, and the system file for such a controller includes a system code section which implements the dynamics of the filters.

I Thought Real-time Linux Wasn't Running?

True, certainly we would be in trouble trying to run a print server and a copy of the Apache WWW daemon at the same time that we were balancing an inverted double pendulum. However, in the lab environment, the window manager (preferably Open Look olvwm) and the control environment dlxrun are the only user level applications running. The program dlxlab is an XView application, written in the explicit dispatch mode. This means the timing of the control loop is under control of the programmed loop and not the XView notifier.

As long as the lab machines are provided with enough memory to avoid swapping during the experiments, the effect of timing jitter has a smaller effect than, for example, pretending that the behavior of servomotors is entirely linear. It was originally thought that selectively killing and restarting certain daemon processes would be necessary, but our experience has shown that this is not the case. In any event, one of the aims of control design is to produce controllers which are robust against unmodelled disturbances, and timing jitter provides an example of such a disturbance.

Equipment Description

We run lab experiments on machines ranging from a 12MB 486SLC-66 to a Pentium P5-166. There is no problem running the experiments on our set of 486DX2-66 boxes, with sample rates up to several thousand samples per second. The lab machines are on a local network with 10Base-2 coaxial cable, with a salvaged 386DX-16 staggering along as the resident print server.

Further Information

The Linux machine in my office is running the Apache web server and has a WWW page for our control and robotics lab. The address is http://jhd486.mast.queensu.ca/. The lab page has photos of the lab equipment and links to my home page where documentation, sources and binaries for the dlxlab programs are available.

Conclusion

The dlxlab environment described began life as an awk script that turned a system file (ancestor of the ones above) into an XView control system simulation program, running under SunOS-4.1. After a Linux conversion experience, I came upon a version of the Kernel Hacker's Guide by Michael Johnson and discovered that user level I/O port access was possible under Linux. This allowed the program to accomplish hardware control as well as simulation tasks.

The low cost and wide availability of interface boards for PC-compatible machines make them ideal for a lab such as the one we have set up. The complete openness of the Linux system made it possible to undertake program development with the confidence that it could be made to work. It is also helpful to have the same operating environment in the office, at home and in the robotics and control lab.

Virtual beers all around.

Jon Davis is an Associate Professor in the Department of Mathematics and Statistics, Queen's University, Kingston, Ontario. His interests are in applied mathematics, especially control and communication systems. His interest in computing goes back to high school, where he cannibalized some pinball machines to make a science project computing device. He can be reached via e-mail at jon@mast.queensu.ca.

______________________

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState