Introducing “Feedback Control with Scilab and Arduino” Book

Time flies. Four years have passed since I first create this website to share information on the use of Scilab in control engineering and related fields. I, as a university instructor, have used some of the developments as class materials. The site itself is still not very convenient for such purpose, because it is difficult for a student to find an article related to a topic or assignment, even though I have arranged some essential parts to study modules.

So I decide it is a good time to collect core articles on and compose them as an e-book. During that process, I review the work and have a feeling that the book still lacks something. In addition to digesting feedback control basics and how to use Scilab/Xcos as study aids, the reader should be able to implement his/her design on a target board. That would close the learning loop.

This describes the how and why of my new book “Feedback Control with Scilab and Arduino.”

The Hardware

I have designed my embedded hardware boards and am happy with the performance. On my first thought I want to use them in the book. The drawback of this approach, unfortunately, is general audience would have difficulty acquiring the boards. Even I post the schematics and firmware, it would still require some work to build them.

It seems like the best solution is to use an embedded product that’s already available worldwide. Though there might be some other candidates, I select the Arduino line of product, the most favorite choice of engineering students here. (Well, it’s a bit confusing for me at the moment who is actually the rightful owner, or, so I cite them both.)

I can buy an Arduino UNO R3 board quite easily in this country. It is affordable, easy to use, and yields good results for all the experiments in this book. BTW, the board used in the book is from

Frankly, at the start of my writing this book some months ago, I am a beginner in the Arduino world. Thanks to my long experience on embedded systems, I could catch up pretty fast and now are comfortable with the board enough to include it in this book. So all the Arduino examples in the book are entirely new.

The development starts from a simple plant consisting of electrical circuit, which the reader could easily construct on a blank prototype Arduino shield as in Figure 1.

Figure 1 RC circuits built on blank proto shields

This plant is used in most of the controllers implemented on Arduino, from PID to custom designed ones. Motion control applications are demonstrated on a DC motor with self-made encoder shield in Figure 2.

Figure 2 motion control experimental setup

From Control Design to Implementation

The book covers PID basics and tuning, and also various control design schemes. What I consider the essence of this book and hope the reader could master, is the process of implementing a linear controller, regardless of how it is designed. I have used and refined the discrete-to-continuous conversion routine in applications of different nature from my previous work in the U.S. until now.

Simulation is also an important step that should never be neglected. The Xcos simulation engine in Scilab is now mature enough for you to create a model that best represents the real system. In many cases, you know what to encounter beforehand. For example, the PWM output of Arduino UNO is 8-bit, so the controller output with offset is limited to +/- 127. This saturation must be put into the model as shown in Figure 3.

Figure 3 feedback control model with controller output saturation

Figure 4 shows the comparison of pure linear versus the nonlinear response when saturation is presented. Similar degradation is expected in the real step response.

Figure 4 simulated response that shows an effect from 8-bit PWM limit

Book Features

This list addresses some key topics in “Feedback Control with Scilab and Arduino.”

  • Scilab and Xcos usage in control engineering: From basic scripts, functions, and simulation to advanced control synthesis, this issue casts the main theme for the book.
  • Arduino sketch structure tailored to feedback control: some basic knowledge and experience with Arduino is assumed. We do not discuss blinking an LED. The timer2 library has to be installed to yield a precise sampling period. You can download chapter 2 to get acquainted with this topic. As the book progresses, the features from previous sketches are retained. Eventually, the reader has a workable firmware structure that can be adapted to his/her own application.
  • Data transfer via serial communication: To command and capture responses from Arduino, simple ASCII text communication is implemented. We learn how to write a command interpreter function, and how to receive message reliably in Scilab. As simple as it sounds, the process does require some tips and tricks to work properly.
  • PID controllers: as the most widely-used ever in industry, two chapters are dedicated to PID feedback, from the basic theory, anti-windup methods, manual/auto tuning, to implementation. Simulation and experimental results are provided.
  • Linear controller implementation: from a continuous-time transfer function, the discretization and conversion to an algorithm steps are elaborated.
  • Least-square system identification: to design or synthesize a custom controller, a math model of the plant is required. We show how to estimate it experimentally.
  • Advanced control design/synthesis: Chapter 8 of the book addresses 3 methods to yield a custom controller: classical loopshaping, state-feedback, and H_\infty
  • Arduino I2C interface: the encoder interface shield in Appendix A is like a bonus, since PIC24 programming is not a main topic of the book. The shield is used in DC motor motion control examples. To me, it’s fun to create and the thing works like a charm. Regarding Arduino, the reader learns how to use the Wire library to communicate with a device via I2C.

From the author’s perspective, this book “Feedback Control with Scilab and Arduino” is really joyful to write. The current version of Scilab is superb. The flow from design to implementation, though not totally seamless, is systematic and not hard to follow. There is no special 3rd party tool or software used in this book other than Scilab, the Serial Toolbox, and Arduino IDE with timer2 library. I believe the benefits are more solid and valuable by learning from scratch.

The experimental results conform to underlying theory. Even though the limited resources of Arduino UNO prevent us from implementing more advanced control schemes, for all the discussion in this book, this board supplements the topics well.

Get the Free Chapters and Software

Perhaps you could decide this book is for you or not by skimming Chapter 1 and 2, which are provided on the book page below. This also helps a beginner to get started on Scilab and Arduino. The appendices and software are also free-downloadable.

The whole e-book in PDF is USD 7.00. Alternatively, if you prefer to read the e-book online without getting the PDF, it is just USD 5.00. Consider this modest price as your kind contribution that helps supporting this site.

Visit “Feedback Control with Scilab and Arduino” official page.



Comments are closed.