Jack, H., Blauch, A., “A Modeling and Controls Course Using Microcontrollers”, submitted to ASEE National Meeting, Salt Lake City, June 2004.
As with most engineering programs, we offer a dynamic systems modeling and control course (EGR 345) to our students in Mechanical and Manufacturing Engineering . This course has evolved since it was originally offered, with the goal of producing graduates who are capable of successfully implementing control systems. Towards this goal, the laboratory component of the course is very important. Originally the laboratories were based on experiments with discrete mechanical components and data acquisition to allow analysis of the results. While this was very effective in improving laboratory skills, it did not help prepare the students to implement actual control systems.
Previously the laboratory made extensive use of Labview for data acquisition and control. This did allow students to quickly build systems, but students rarely saw beyond the graphical interface. The laboratory component of EGR 345 was revised to build upon two previous courses, one in basic programming with C (EGR 261) or Java (CS 162), and a subsequent course in digital systems using 68HC11 microcontrollers (EGR 226). In the laboratory students use 68HC11 single board computers with 32K of memory for data collection and control . Programs are written in the C programming language and compiled with the free GCC compiler. The typical laboratory focuses on motor control using a transistor for speed control, or an H-bridge for bidirectional motion. The motor speed or position is read using a potentiometer, tachometer or encoder. The students learn to construct feedback loops by converting block diagrams to C programs, circuits and mechanical systems. Similar efforts have been reported before in mechatronics courses for non-electrical engineering students , but dynamic systems modeling courses tend to focus on more traditional approaches .
The sequence of the laboratories basically begins with a review of C programming, analog inputs, Pulse Width Modulated (PWM) outputs and interrupt driven subroutines. Through the following laboratories students create and analyze a variety of velocity and position control systems. The laboratory exercise progressively introduces topics such as data collection, deadband compensation, feedback control and measuring parameters of permanent magnet DC motors. Other topics in the laboratories include Scilab (a Matlab clone) , Variable Frequency AC Drives, Labview and Simulink.
The normal laboratory structure requires that students prepare programs and do appropriate calculations before the laboratory. During the lab sessions the students build and test a system, and then use it to collect data that they may compare to the theoretical predictions.
The laboratory exercises have been designed to emphasize control systems as soon as possible, as shown in the list below. The first week is used to review the use of 68HC11 controllers and C programming, as learned in EGR 226. In the second week the students build a feedback controller for motor speed control. By the end of Lab 6 students are able to design and build a sophisticated motion control systems, including deadband compensation, an interrupt driven feedback loop, setpoint planning and scheduling with a simple user interface. The remainder of the laboratory work expands the basic controller knowledge into areas that are more practical and/or theoretical.
Lab 7: Modelling Brushed DC Motors: Permanent magnet DC motors were modeled as differential equations and their parameters measured. This lab also required students to use the 68HC11 board to collect analog data.
Lab 9: Variable Frequency Drives (Allen Bradley Ultra 161s): This lab introduced the students to industrial motor controllers for AC induction motors. During this lab students were able to set PID parameters and see a trapezoidal motion profile.
Labview was used as the primary laboratory programming tool in previous years. This simplified the process of reading inputs and setting outputs. However, students often struggled with concepts such as sampling times and data ranges. They often encountered difficulties when constructing programs that required operational mode changes, or varied data types. However, with Labview now placed after the use of microcontrollers, and only used for two laboratories, students were more comfortable with Labview and able to do more than in previous years.
The 68HC11 based laboratories made use of an Axiom development board with 32K of RAM. This made it possible to write control programs in C using integer mathematics. When used properly the boards were reliable, but they occasionally failed when connected improperly. In many cases this only required replacing an inexpensive component. To help overcome this problem capacitors and resistors have been used to limit transient currents. In general the components for the laboratories were very inexpensive. For example the general component costs are,
In the second laboratory students design and build a velocity controller. Although not formally introduced yet, a block diagram is used to present the control system, as shown in Figure 1. Care is taken to present the relationship between the block diagram and actual system components. Aside from the summation block, students find these diagrams to be very intuitive. This block diagram shows a proportional feedback loop implemented in an interrupt subroutine. The A/D input is handled by hardware in the microcontroller, and the PWM output is generated by a provided library. The PWM output drives a power transistor, which in turn drives a motor. Another motor is connected as a tachometer to provide a velocity feedback. Students implement their control software using this diagram, and some provided subroutine examples. As suggested in the variable definitions below all of the math operations are done with integer values. The analog input range is 0 to 5V. The PWM output is at logic levels (0 and 5V) but it switches a transistor to drive heavier loads. (Note: Vs will be proportional to Vc, but they may have different absolute magnitudes.)
The electrical schematic for the controller was designed to be very simple as shown in Figure 2. The simplicity of the circuit allows students to connect it within a few minutes. Capacitors are used to ‘short’ voltage spikes caused by induction and switching. (Note: it may also be useful to limit currents by putting 10K resistors in series with each of the 68HC11 inputs.) The tachometer can be a simple DC motor. Indeed, the same model motor may be used for the motor and tachometer.
The average student was able to successfully complete this lab within the 3 hour time block. At the end of the laboratory period they had a fully functional controller that would allow them to control the motor speed. They could vary the setpoint and the proportional gain and observe the effect. Most students were able to notice the motor deadband, and that larger gains made the system more responsive. The limitations of integer mathematics did create some difficulties when students over/underflowed the range. This will be rectified in the following course offerings with additional tutorials and prelaboratory materials.
In Laboratory 6 the students developed a motion control system, as shown in Figure 3. Their controllers must allow a desired distance and time to be entered. These are used to generate setpoints along a smooth motion path. A feedback control loop is then used to ‘chase’ these points. A sample program is given in Appendix A and function names are referred between ‘[....]’.
The feedback control loop for the system is shown in Figure 4 [void RTI_ISR()]. The controller includes a proportional and integral component, as well as deadband compensation [int DeadBand()]. The deadband subroutine will increase the output PWM values to overcome the stiction of the motor, so that all non-zero voltages result in motion. A subroutine [void EncoderUpdate()] is used to decode the quadrature output of the encoder to measure position. In this case the PWM output is still unidirectional, but the use of direction outputs allowed the H-bridge to switch the motor voltage polarity [void SetOutput(int value)].
The laboratory experiences were complimentary to the lecture material, allowing students to grasp difficult control concepts easily. In the laboratory, students were able to build more control systems with a higher level of complexity in a shorter time than they could using Labview.
HUGH JACK earned his bachelors degree in electrical engineering, and masters and Ph.D. degrees in mechanical engineering at the University of Western Ontario. He is currently an associate professor at Grand Valley State University and chairs the graduate and manufacturing programs. His research interests include using open source software for industrial control.
ANDY BLAUCH received his B.S. degree in Electrical Engineering from Messiah College, M.S. degree in Electrical and Computer Engineering from Carnegie Mellon University, and Ph.D. degree in Electrical Engineering from the Pennsylvania State University. He is currently an Assistant Professor at Grand Valley State University. Current interests include development of an 68HC11-based general purpose controller and student practice/assessment software.