Real-Time Control of Magnetic Bearings Using RTLinux
Control theory, central to all modern technologies from the automobile to the jetliner, is an extensive field in which graduate students have toiled for many decades. I cannot cover this extensive body of theory here, but I can explain the essentials of the digital control for the magnetic bearing. First, the quantity to be controlled is instrumented and measured. In this case, the quantity is the gap between the rotating bearing and the magnetic poles of the bearing. This gap is converted to a voltage with signal conditioners and input to an analog/digital input (AI) board. In my setup, four separate gap sensor signals control the rotating shaft. All four gap signal voltages are sampled simultaneously.
The gap is controlled by the current traveling through the magnets, which are driven by eight power amplifiers. The power amplifiers are controlled by the voltage from a separate digital/analog output (AO) board. The AO board receives a digital input and converts it to a voltage that is held constant until the next signal. This sample-and-hold operation is fundamental to all digital control systems. In the control loop, the AO board receives the processed signals from the AI board after numerical processing. In an ideal digital controller, both AI and AO operations occur simultaneously at precise constant intervals. Although impossible to achieve this ideal, you must ensure that the code within the control algorithm runs efficiently. In my control program this occurs at 10kHz.
The numerical operations within the control program include the history of the input, x, and the output, y, of the controller for several previous steps. These are stored in memory and shifted one increment each time the control loop executes. The history is incorporated in a difference equation:
y(n)=A*y(n-1)+B*y(n-2)+...+C*x(n) + D*x(n-1) +...
where y(n) is the output of the controller for the current time step, y(n-1) is the output of the controller in the previous time step, y(n-2) is the output two steps in the past, y(n-3) is three steps in the past and so forth to the depth demanded by the sophistication of the control algorithm. Similarly, x(n) is the input voltage for the current time step, and x(n-1) is the input for the previous step. A, B, C, D and the rest are constant coefficients determined by the particular control law implementation. Controllers are either single-input-single-output (SISO) or multiple-input-multiple-output (MIMO). In my magnetic bearing test setup, y is the voltage driving the power amplifier, and x is the signal from the gap sensor. I use the three previous values in my magnetic bearing difference equation.
The digital controller is implemented on an Intel Pentium III PC operating at 1GHz with a six-slot PCI bus. The system was procured as a customized desktop personal computer with Red Hat Linux version 7.2 installed. In the laboratory the PC is not networked. I installed version 3.1 of RTLinux from a tar archive downloaded from FSMLabs.
The three possible approaches for selecting the digital acquisition and control (DAC) boards are to write the required board driver software, to obtain a driver from an open-source project such as Comedi and to use vendor-supplied driver software. The first and second options require a high level of sophistication and expertise with using Linux and data acquisition programming. The second option reflects the open-source nature of the Linux system, but the selection of vendors is limited and the latest products often are unavailable. The third option, although it requires the least expertise, places the user at the mercy of the board vendor. The vendors supplying and supporting the necessary drivers are limited and quite often use the same sources as the second option. In the end, I chose the third option and purchased two PCI bus multichannel DAC boards from United Electronics, Inc. These came with the required RTLinux drivers.
Before implementing the digital control law, I performed tests to characterize the digital system behavior. These tests are various program codes that evaluate conversion and timing interactions of the digital boards. For my primary functional test, I designed and coded a C language module that reads the analog data on the analog input board, converts it to floating point variables, converts it back to a digital variable and then outputs the signal by way of the analog output board.
Listing 1 shows the skeleton of the C program for the primary functional test. At the heart of the real-time control program is the RTLinux function, pthread_wait_np, which suspends execution of the currently running real-time thread until the start of the next period. This thread is marked for execution using pthread_make_periodic_np. The thread gives up control until the next time period. The default arithmetic in RTLinux is integer. My control application requires floating point, which is turned on by pthread_setfp_np. A comparison of the input and output is recorded on a Tektronix two-channel digital storage oscilloscope. Figure 3 shows a typical record of system performance on this test. The main loop in the software is set at 10kHz in this plot; the analog input is a 1,000Hz sawtooth. The output shows the step waveform characteristic of sample-and-hold operation.
Practical Task Scheduling Deployment
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.View Now!
|The Firebird Project's Firebird Relational Database||Jul 29, 2016|
|Stunnel Security for Oracle||Jul 28, 2016|
|SUSE LLC's SUSE Manager||Jul 21, 2016|
|My +1 Sword of Productivity||Jul 20, 2016|
|Non-Linux FOSS: Caffeine!||Jul 19, 2016|
|Murat Yener and Onur Dundar's Expert Android Studio (Wrox)||Jul 18, 2016|
- Stunnel Security for Oracle
- The Firebird Project's Firebird Relational Database
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- SUSE LLC's SUSE Manager
- Managing Linux Using Puppet
- My +1 Sword of Productivity
- Non-Linux FOSS: Caffeine!
- Doing for User Space What We Did for Kernel Space
- Google's SwiftShader Released
- SuperTuxKart 0.9.2 Released
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