LinkShield - gergelytakacs/AutomationShield GitHub Wiki
Introduction
Application programming interface
Examples
System identification
Feedback control
Detailed hardware description
Circuit design
Parts
PCB
About
Authors
The LinkShield belongs to the family of control engineering education devices for Arduino that form a part of the AutomationShield project. The basic design of LinkShield consists of a vertically placed servo motor connected to a horizontal flexible cantilever beam to simulate the vibration response of dynamic systems in motion—such as high-speed slender flexible robotic manipulator arms. The goal is to attenuate the vibrations of the beam measured by an accelerometer unit attached to its free end, thus creating a simple single-input single-output (SISO) feedback loop. The user may also set the reference angle of the servo manually—using a potentiometer.
The basic application programming interface (API) serving the device is written in C/C++ and is integrated into the open-source AutomationShield Arduino library. This library contains hardware drivers and sample exercises for control systems engineering education. All functionality associated with the LinkShield is included in the LinkShield.h
header, which contains the LinkClass
class that is constructed by default as the LinkShield
object. The functions specific to this shield mostly perform input/output peripheral communication.
The summary of basic functions and the illustration below should get you started quickly:
- Output (sensor):
LinkShield.sensorRead();
- Input (actuator):
LinkShield.actuatorWrite();
Before you begin an experiment you must initialize the hardware by calling
LinkShield.begin();
which initializes the default Arduino servo motor library and attaches the motor to the D9 pin. To maintain both 3.3V system compatibility and analog resolution, the reference is set to external. Finally, the ADXL345 accelerometer is initialized with a 8G range and 3200Hz data rate, producing a 1600Hz bandwidth. The sensor can be optionally calibrated by running the calibrate()
method to remove sensor bias in the direction of interest.
The acceleration sensor can be read at any time instant by calling
float y = LinkShield.sensorRead();
which returns a floating-point number providing acceleration data in m.s−2.
The servo motor can be commanded to the internally kept position of degrees by the
LinkShield.actuatorWrite(float u);
method. The board contains a programmable potentiometer as well, its state is returned in the range of 0–100% by the referenceRead()
method.
We remark that APIs for Simulink and possibly MATLAB are subject to ongoing work.
Before proceeding to controller design, one shall first try to identify a simple dynamic model of the tip position (m) in dependence of the servo angle (deg). Let us assume that the load carried by the end-effector consists of three stacked magnets weighing 2.84 g (∼0.95 g each). Assuming the manipulated load and the beam can be represented by a single dominant resonant mode, we obtain
where (rad.s−1) is natural angular frequency, (-) is the damping ratio and is the force acting on the system. We may represent this force by assuming , where (m.deg−1) is the actuator constant. After performing a Laplace transform, we arrive at the well-known transfer function
One shall not forget that we may only measure an acceleration signal , however, may still use the same model structure for grey-box identification, then compensate for the discrepancy later. The servo angle was changed 90 deg while sampling the acceleration signal at a s period. The identification experiment loaded to the MCU is available in a worked C/C++ example.
Identification of the above transfer function can be performed as in the worked MATLAB example. First, a data section with free vibration has been selected, then a continuous two-pole and no zero transfer function has been obtained with a ∼92% fit to the estimation data. According to this, the angular natural frequency of the system with the given load is rad.s−1 (16 Hz) and the damping ratio is . Remember that the numerator assumes an acceleration signal, thus, by modeling simple harmonic motion we may safely consider the position signal to be out-of-phase with acceleration and scaled down by . The actuator constant is then m.deg−1. The comparison of the identified transfer function to test data is shown in the figure below, assuming we model the acceleration signal.
For a start you may want to experiment with a feedback control of the beam tip, or in other words, the stabilization of the end effector of the simulated robotic arm.
The manipulation angle is maintained by a feedback loop inside the servo motor to (deg). This reference can be then modified by an appropriated control input , so that the resulting overall angle is . In the following example we will consider positive position feedback control (PPF) of the dominant structural mode, where (m) is the position signal and (deg) is the resulting servo angle. The PPF controller is given in the time domain by
where [deg.m−1] is the tunable controller gain, (rad.s−1) is the angular frequency of the controller that usually equals to the angular natural frequency of the controlled mode and (-) is the tunable controller damping ratio affecting the “sharpness” of the controller response.
As we are controlling a single dominant mode with a prevalent harmonic response, we may assume that the acceleration signal recorded by the system is out-of-phase to the position with an amplitude that is smaller. The PFF controller is then transformed to
which is effectively a negative acceleration feedback (NAF) controller. Let us not forget, that besides the orientation of the feedback, the scaling of the acceleration signal is eventually combined with the tunable gain , thus is ultimately lost in the digital realization. The transfer function of the controller is
which after selecting rad.s−1, (-) , the gain deg.m−1 and the sampling period of s results in the following discrete-time transfer function:
The computation of the NAF/PPF controller, based on the identified single-mode vibration model, is listed in a worked MATLAB example, while the digital realization of the discrete-time transfer function is listed in a worked C/C++ example that is a part of the API.
A representative experiment is shown in the figure below, where an open-loop response is compared to the closed-loop response obtained with the NAF/PPF controller presented above. As one may observe from the experimental data, the controller damps the tip vibrations very effectively whilst ultimately converging to the desired servo angle.
The LinkShield is an open hardware product, you are free to make your own device. If you come up with improvements, please let us know so we can improve our design as well. The discussion below should help you to improvise a similar setup for experimentation on a breadboard or perforation board. You may even order a professionally made PCB by a PCB fabrication service.
The circuit schematics were designed in the Freeware version of the DIPTrace CAD software. You may download the circuit schematics for the LinkShield from here.
The digital micro servo motor (d), only represented by its connectors J2, is driven by the D9 PWM capable pin of Arduino. Its power supply is drawn directly from the board, as the current consumption remains well below the allowable maximum. A diode D1 (e) protects the microcontroller from reverse currents caused by possible back electromotive force, while transient effects on the servo supply are filtered by a capacitor C1 (f). To minimize the size of the accelerometer unit, the I2C pull-up resistors R1,R2 (g) are included on the base board. A miniature connector J1 (h) mounted to the shield supplies power to the acceleration sensor U2 (v), which is connected to the I2C bus of the MCU by the SCL and SDA pins. The last component located on the base is a potentiometer POT1 (i) connected to the A0 analog pin, including a shaft (j), that allows the user to program this input for any purpose, such as providing reference to the feedback control loop.
To make a LinkShield either on a PCB or on a breadboard you will need the following parts or their similar equivalents:
Part | Name | Type/Value/Note | PCS |
---|---|---|---|
(d),M1 | Servo | digital, high-speed metal gear micro-servo, e.g. Savox SH-0257MG |
1 |
(v),U2 | Accelerometer | Analog Devices ADXL345 | 1 |
(h),J1,J2 | Connector | 0.5mm pitch, 4-lead FFC/FPC, e.g. Molex 52745-0497 | 2 |
(i),POT1 | Potentiometer | 250 mW, e.g. ACP CA14NV12,5-10KA2020 | 1 |
(g),R1,R2 | Resistor | 0805, 10kΩ, e.g. ROYAL OHM 0805S8J0103T5E | 2 |
(f),C1 | Capacitor | 0805, tantalum, 4.7µF, e.g. AVX TAJP475K016RNJ | 1 |
(u),C2 | Capacitor | 1206, tantalum, 10µF, e.g. KEMET T491A106M016AT | 1 |
(t),C3 | Capacitor | 0805, ceramic, 100nF, e.g. KEMET C0805C104M5RACTU | 1 |
(e),D1 | Diode | DO214AC, e.g. Vishay BYG20J, 1.5A, 600V) | 1 |
(r) | Cable | 0.5mm pitch, 4-lead FFC | 1 |
(a) | PCB (shield) | 2 layer, FR4, 1.6mm thick, green mask | 1 |
(s) | PCB (breakout) | 1 layer, FR4, 0.6mm thick (or less), green mask | 1 |
(o) | Screw | M2×8, steel | 1 |
(p) | Nut | M2, steel | 1 |
(k) | Spacer | hexagonal, polyamide, M2, 10mm | 2 |
(l) | Screw | M2×5, Phillips, polyamide | 2 |
(m) | Nut | M2, polyamide | 2 |
(j) | Shaft | Potentiometer shaft, e.g. ACP CA9MA9005 | 1 |
(c) | Header | 6×1, female, 2.54mm pitch | 1 |
(c) | Header | 8×1, female, 2.54mm pitch | 2 |
(c) | Header | 10×1, female, 2.54mm pitch | 1 |
(n) | Hub | 1.1g green PETG filament, 21m to print, 0.07kWh electricity | 1 |
— | Magnets | Ø9×2mm, N50, ∼13N, e.g. Omo Magnets N50D00960020 | 3 |
(q) | Beam | 85×10×0.3mm, Ø2mm hole, 5mm from edge, AISI 301 | 1 |
Note that the total cost of the above components and thus of the entireLinkShield is no more than 22€ excluding labor and postage.
The assembled LinkShield is shown in the figure below. The mechanical base of the LinkShield is a standard two-layer 1.6mm thick printed circuit board (a) that carries all electronic and mechanical components and acts as a foundation for the device. This is connected to an Arduino R3-layout compatible microcontroller prototyping board (b) by a set of stackingheader pins (c). The servo is inserted into a prefabricated slot on the PCB and raised by 10mm using a pair of spacers (k), fixed with polyamide screws (l) from the top and nuts (m) from the bottom. The slotted cylindrical hub (n), which connects the servo shaft with the beam, was designed in Autodesk Fusion 360 and printed by a Prusa I2 MK3/S 3D printer using PETG filament in 21 minutes. The hub is held in place by a machine screw connecting the servo shaft that comes with most metal-geared servos as standard, while the slot holding the beam is tightened and fixed by a M2×8 machine screw (o) and corresponding nut (p). The flexible cantilever beam (q) measuring 85×10×0.3mm and with a Ø2mm mounting hole placed 5mm from the edge is laser-cut from stainless steel.
The tip of the beam is equipped by the accelerometer unit (v), which is connected to the base board by a 4-lead flexible flat cable (r). The accelerometer unit is based on a single layer 0.6mm thick PCB (s) glued firmly to the beam tip. Power to the accelerometer chip is filtered by a pair of 10µF (t) and 100nF (u) capacitors. The breakout PCB contains the Analog Devices ADXL345 3-axis configurable gain digital accelerometer unit (v).
The equivalents of the circuit components described above for the schematics are marked on the assembled device with the same letters.
The printed circuit board has been designed in the Freeware version of the DIPTrace CAD software. The PCB is two-layer and fits within the customary 100 x 100 mm limit of most board manufacturers. The DIPTrace PCB layout and circuit schematics can be downloaded here and here, respectively, while the ready-to-manufacture Gerber files with the NC drilling instructions are available from here.
This shield is currently designed and created within a Bachelor's thesis at the Institute of Automation, Measurement and Applied Informatics (IAMAI). The Institute belongs to the Faculty of Mechanical Engineering, Slovak University of Technology in Bratislava in 2017/2018.
- Hardware design: Martin Vríčan, Erik Mikuláš, Gergely Takács
- Software design: Martin Vríčan, Gergely Takács
- Wiki documentation: Martin Gulan, Erik Mikuláš and Gergely Takács