Asee peer logo

Open-Source Hardware in Controls Education

Download Paper |


2014 ASEE Annual Conference & Exposition


Indianapolis, Indiana

Publication Date

June 15, 2014

Start Date

June 15, 2014

End Date

June 18, 2014



Conference Session

Computer Hardware

Tagged Division

Computers in Education

Page Count


Page Numbers

24.955.1 - 24.955.11



Permanent URL

Download Count


Request a correction

Paper Authors


Mark A. Hopkins Rochester Institute of Technology (KGCOE)

visit author page

Mark Hopkins has been teaching electrical engineering at RIT in the controls area for over 25 years, and has extensive related experience in the aerospace industry.

visit author page


Alexander Michael Kibbe Rochester Institute of Technology

visit author page

Electrical Engineering graduate of the Rochester Institute of Technology, Bachelors degree.

visit author page

Download Paper |


Open-source hardware in controls education Abstract — In teaching undergraduate automatic controls, the laboratory experience is animportant and irreplaceable component. Historically, good platforms for a controls laboratoryhave been expensive, because the equipment has typically been very specialized for educationalpurposes. Moreover, the equipment often is not physically robust in the face of studentmanhandling, creating major difficulties and costs in maintaining such a lab. The advent of theArduino Board, and Matlab/Simulink/LabVIEW support for it, is revolutionizing this situationbecause it is now possible to have good controls-hardware capability at relatively low cost. The Arduino is an open-source electronics prototyping platform based on flexible, easy-to-usehardware and software. The “motor shield” is an add-on (daughterboard) to the base hardwarethat further enables control of dc and servo motors. This paper explains a method and hardwareto connect an Arduino to a separately-powered dc-motor unit with full support of feedback-controller design using Matlab/Simulink, powering and communicating with the Arduino boardthrough a standard USB connection. Keywords — computers in education, controls education, controls laboratory, laboratoryhardware, Arduino board, dc motor, motor control, motor control hardwareI. Introduction Educational hardware for electronics laboratories is generally very expensive in part becausethe customer base, mostly schools and universities, is not large. Due to the relatively low numberof total units produced, such hardware is almost never as refined or bug-free as a full-upcommercial product, and independent third-party support is not usually available. Using theArduino board as a laboratory platform avoids all these problems. The Arduino is an open-source platform for hobbyists and tinkerers, available at low-cost frommultiple suppliers. In fact, the availability and low cost are such that many students could acquiretheir own boards, if necessary. The Arduino is designed to be user-friendly, and requires onlybasic electronics and programming knowledge to use. Engineering students in their second orthird year should be capable of quickly learning how to use the Arduino, and of interfacing it withother hardware components with relative ease, particularly when it is used in conjunction withthird-party support now available from The Mathworks (Matlab/ Simulink) and NationalInstruments (LabVIEW). The Arduino has already been successfully used in classroom and laboratory settings to teachvarious topics [8], including photovoltaic cells and C-programming, demonstrating the versatilityand robustness of this platform. This article describes how the Arduino board is being used at to implement dc-motor control in laboratories related to control signals, feedback loops, andtransfer functions.II. Hardware The Arduino Mega 2560 was selected as the Arduino board of choice, as it is among the morepowerful of the Arduino models, and it is one of the boards that have been fully supported in  Matlab, Simulink, and LabVIEW for more than a year. This board has 54 Digital I/O pins, 15 ofwhich can double as PWM pins, 16 analog inputs, and serial-communication capabilities via USBcable. Arduino board input/output ports are only capable of operating in the positive voltage range.All signals produced by the board or any of its standard shields (daughterboards) are positive andany input voltage below 0V is clipped and interpreted as 0V. Additionally, the analog inputs arenot capable of reading voltages above a reference voltage (nominally +5V, but this can be setlower). Voltages above the reference are similarly clipped. These limitations are addressed bythe hardware-interface circuit discussed below. The Arduino Motor-Shield is an add-on that plugs in to the Arduino. It contains variousoutputs for servos as well as two PWM driven analog outputs. This shield is capable of derivingits power solely from the Mega motherboard, and thus does not require a separate supply (exceptfor high-power applications). The Arduino Mega/Motor-Shield combination can be powered entirely through the USB cable.In that case, the voltage output of the PWM signals have a maximum of 4 V. When powered by aseparate, independent power supply, the Arduino voltage-range increases to approximately one-half volt below the supply voltage. A wide variety of controls experiments can be designed around an independently-powered dc-motor unit. There are many such units available commercially, with the common feature of built-in electronics to power the dc-motor. Thus, very little power is required from the external control-hardware, in this case the Arduino/Motor Shield. In discussing the dc-motor module, we assume it is a platform that includes a power amplifierfor the control input, and an output voltage that is proportional to the motor velocity (atachometer). In this paper, both of these signals are assumed to be in the range of -5V to +5V.These two signals are sufficient to design velocity-control experiments. If a dc-motor unit alsohas an output signal that is proportional to motor-shaft position, then position-control experimentscan also be designed for the unit. The motor module that is used at is the MS15 DC Motor Control Module,marketed by LJ Create. In this paper, we refer to this module as the LJE motor board. Due to input/output mismatch between the Arduino and a typical motor module, a customsignal-conditioner shown in Fig. 1 was designed and implemented (the full schematic is given inAppendix A, Figure A.1). The Arduino is indeed capable of driving an attached motor in eitherdirection, but it can only accomplish this by switching a pulsewidth modulated (PWM) controlsignal between two different output pins when the control signal changes sign. The customsignal-conditioner uses just one of these PWM signals (the positive one) to output a voltagebetween -5V and +5V. The signal-conditioner converts the PWM signal produced by the motor shield from squarewave to a -5V to +5V DC signal. The conditioner uses a lowpass filter and a tunable voltagedivider as inputs to a differential amplifier. Thus, a PWM signal at 50% duty cycle is the ‘zeropoint,’ and the conditioner outputs a voltage of zero. Duty cycles above 50% produce positivevoltages, and those below 50% produce negative voltages.   Fig. 1. Low-cost custom signal-condition to interface Arduino a motor u 1 c ner and unit. The signal-condit s tioner also contains a voltage-avera c v aging circui This ave it. eraging circuit isneeded because the tachometer (motor vel b r locity) volta is betw age ween -5V an +5V, bu the nd utArduino A/D conve erter is only capable of converting voltages b y f g between 0V and +5V. Thecondition shifts an scales the tachometer signal so i is between 0V and +5V. In effe it ner nd e r it n ect,averages the tachome signal with a consta +5V, res eter w ant sulting in a v voltage that is in the req quiredrange. Fig. 2. Block diag 2 gram of system compone and inte ents erconnection ns The PWM drive signal prod P duced by th Arduino is filtered a applied to a differe he and entialamplifier The filter shown in Fig. 3, is first-order lowpass with a time cons r. r, fi stant of 22.5 ms, 5tailored to the Arduin PWM sig t no gnal. The PW signal p WM produced by the Arduino has a frequ y o uencyof 490 Hz, and thus has a period of about 2.0 ms. Bec H d 2 cause the tim constant of the lowpa is me assmuch lon nger than the period of the PWM, it effectively smooths th square-wa PWM si i y he ave ignal.The filter signal is buffered to reduce effects due to loa red r ading from th rest of the circuit. he e   Fig. 3. Lowpass filter with bu 3 f uffer Fig. 4. Difference amp / volta subtracto 4 e age or The difference am d mplifier in Fi 4 subtrac the voltag applied t R2 from t filtered P ig. cts ge to the PWMsignal applied to R3, and amplifie their diffe es erence by its gain; for the Arduino, t gain is ar e the round3.8. The result is that the Ardui PWM signal, which typically ha a range o +1V to +4 is e ino as of 4V,smoothed and transla to the ra d ated ange -5V to +5V, so it ca be applied to the moto module. an d or Fig. 5. Voltage di 5 ivider with buffer b The otther input (R to the dif R2) fference ampplifier is fed by the buffe ered voltage- -divider of F 5. Fig.The fact that this div vider has a tu unable potenntiometer allo the sign ows nal-condition to service any nerPWM sig gnal whose voltage is between 0V and 5V. A such, the conditione should als be b V As e er socompatib with non- ble -Arduino PW signal so WM ources. It ha served we with the A as ell Arduino in aactuallaborator experimen even thou there is some inhere variation in PWM sig ry nts, ugh ent n gnals from u to unitunit. Fig 6 shows the input/ou gure utput signals for three dif fferent duty cycles.   a. 50 Duty cyc 0% cle b. 75 Duty Cyc 5% cle c. 25 Duty cyc 5% cle Fig. 6. PWM of various duty cycles, and resulting sig 6 v gnal-conditio oner output. In the plots of Fig 6, the inp is represe e g. put ented in ora ange and the output in b e blue. These plotsdemonstr rate the depe endence of signal-condi itioner outpu on the PW duty cy ut WM ycle, and the fact ethat the output range includes negative voltages. As P e n PWM duty cycle increa ases, so doe the esoutput vo oltage, and when PWM duty cycle is below 50% , the output is negative. w d s   III. Simu ulink control To achhieve closed d-loop contro a controller design is created in Simulink an download to ol, s nd dedthe Arduuino to be executed. The example controller, shown in A e T e Appendix A Fig A.2, u uses afeedback loop and a second or k rder PID tra ansfer-functi ion to contr the PWM output o the rol M ofArduino. Input and output signa require conversion be als etween floatting-point an integer va nd alues.The ADC data are unsigned inte C u egers from 0 to 1023 (100-bit ADC), which mus be convert to , st tedfloating-p point values between -5 and +5V Similarly, the control output m be conv 5V V. , ller must vertedfrom a flo oating-point value betwe -5V and +5V to an u een d unsigned inte eger between 0 and 255. n . The coontroller des sign in Simuulink can be done either in the continnuous-time domain, or i the indiscrete-t time domain When the design is in continuou n. e i us-time, as i is in Fig. A the req it A.2, quiredconversio to discret on te-time (for implementat i tion in the A Arduino) is n obvious t students d not to duringthe downnload process That mak the contin s. kes nuous-to-disccrete converrsion an optio onal lesson i the incurriculu of the cou for whic the labora um urse ch atory is being done. g Fig. 7. Hardware closed-loop test results 7 The hardware clos sed-loop test results of Fig. 7 show th motor ve t F hat elocity (red) is able to ex xactlymatch the reference step-input va (blue), as it should w PID con e s alue a with ntrol. The diifference bettweenthe theor retical and measured arm m mature-voltag is due to slightly non ge, n-unity gain bboth in the s signalcondition and in the particular LJE motor board that wa used in thi experimen ner e L b as is nt. IV. Rela ated Products Severa products exist that pro al e ovide simila functions, however no complete suited fo our ar one ely orneeds, due either to functional limitations or to hig price. H d o l s, gh Here are so ome example of escommerc products aimed at co cial ontrols educaation. The Sparkfun Inventors Kit is a very goo product th uses an Arduino boa to interf Sp s od hat ard face acomputer to variou electronic componen r us c nts. The Arduino UN can be controlled via NO e dMatlab/SSimulink in the same way that the Ar y rduino Mega is supporte However the kit doe not a ed. r, esinclude a tachometer, so closed-loop velocity y-control is n easily im not mplemented. Additionally the y,motor is driven simply by the on-board PWM without lo M ing. In effect, the motor itself owpass filteriis used as the low pas filter for th PWM sig s ss he gnal.   The ScienceWiz Inventions Kit is a fairly simple set of do-it-yourself experiments, on a rangeof topics from motor control to radios. The kit similarly lacks tachometer feedback. While itdoes allow the dc-motor control to be configured as a generator, there is only one motor sotachometer feedback for velocity control is not possible. No connectivity to a computer for datagathering purposes is supported. The Industrial Mechatronic Drives Base Unit, from Quanser, uses multiple motors, andvarious methods of interconnecting them, to emulate various real-world control scenarios. It isdesigned to test how motor controllers perform under the effects of disturbances, and todemonstrate the effects of torsion on drive shafts. This unit is a very effective way ofdemonstrating various real-world imperfections or problems one might encounter, but its cost iscomparatively high. Feedback Inc. markets the Powerframe System which is capable of, among other things, actingas a motor speed controller. This is a very full-featured product, in terms of controls and physicsexperimentation. However, the size and cost are probably only justifiable if this system is used tosupport a much wider range of courses than controls alone.References[1] D. Wilcher, “Physical Computing and DC Motor Control” in Learn Electronics with Arduino Apress, 2012, Ch 4. pp. 69-87[2] K Zachariadou et al" A low-cost computer-controlled Arduino-based educational laboratory system for teaching the fundamentals of photovoltaic cells " Eur. J. Phys. 2012 33 1599[3] B. M. Hoffer, “A low-cost computer-controlled Arduino-based educational laboratory system for teaching the fundamentals of photovoltaic cells” East Tennessee State University, 2012. 1520533[4] Powerframes Components [online] Availiable:[5] Industrial Mechatronic Drives Base Unit [online] Availiable:[6] Sparkfun Inventor's Kit, a professional kit for Arduino [Online] Availiable: retail/dp/B005FMNJ3S/ref=pd_sim_sbs_e_2[7] ScienceWiz / Inventions Kit [Online] Availiable: Kit/dp/1886978034/ref=sr_1_8?s=electronics&ie=UTF8&qid=1359657797&sr=1- 8&keywords=home+electronics+kit[8] J. Sarik and I. Kymissis, “Lab Kits Using the Arduino Prototyping Platform”, 40th ASEE/IEEE Frontiers in Education Conference, October 2010, Washington DC, pp.T3C1- T3C5.  Appendix A x Fig.A.1. Schemat of the Ard tic duino-to-dc motor interf m face board (s signal-condit tioner). Fig.A Examp of a PID dc-motor co A.2. ple ontroller for A Arduino, as a Simulink model.The PID dc-motor controller in Fig.A.2 wa designed for the LJE motor boa D c n as E ard, which h a hasdominant mechanical time-consta of about 0.3 seconds. The PID controller tran t l ant . nsfer functio is on . , with autom matic conver rsion to disc crete-time at a 100-Hz s t sample rate when download to the Arduino boar This con ded A rd. ntroller was used in the hardware cllosed-loop te estingreported in Fig. 7 of the main text. t  

Hopkins, M. A., & Kibbe, A. M. (2014, June), Open-Source Hardware in Controls Education Paper presented at 2014 ASEE Annual Conference & Exposition, Indianapolis, Indiana. 10.18260/1-2--22888

ASEE holds the copyright on this document. It may be read by the public free of charge. Authors may archive their work on personal websites or in institutional repositories with the following citation: © 2014 American Society for Engineering Education. Other scholars may excerpt or quote from these materials with the same citation. When excerpting or quoting from Conference Proceedings, authors should, in addition to noting the ASEE copyright, list all the original authors and their institutions and name the host city of the conference. - Last updated April 1, 2015