 ## Modal Synthesis Method for Control Systems with an Example. C Code and Octave Script

### 1. Abbreviation ### 2. Introduction

##### Figure 2-1 shows an Analog Modal Control System: Figure 2-1: Analog Modal Control System

##### Let’s write down the closed system Laplace transfer function for Figure 2-1: ##### Then the characteristic equation of the differential equation: ##### By selecting the values: ##### we will get the necessary roots: ##### Figure 2-2: Analog Kalman-Bucy Filter

##### Stable correction: Hsc(s) is selected in such a way that transients in the Kalman-Bucy filter was an order of magnitude faster than in the control system: ##### In this case the control system will take the form shown in Figure 2-3: Figure 2-3: Analog Modal Control System with the Kalman-Bucy Filter

### 3. Analog Example

##### Let there be a second-order control object described by a Laplace transfer function: ##### The step response of the object is shown in Figure 3-1: Figure 3-1: Step Response on the Control Object without Regulator

##### Choosing the real roots (15) of the characteristic equation, we can write: ##### Let’s rewrite (13) for our example: ##### Comparing (22) and (24), we get: ##### Then: ##### the formula for calculating the generalized tau was proved: ##### Applying the (27) to the (11) and using the (22): ##### If root values are selected: ##### Then from (28) and (29): ##### Now let’s use the rule of the three tau for the transient process: ##### Thus in order to provide the necessary transient process, it is necessary to choose the roots of the characteristic equation according to the formula: ##### Let’s set the time of the transient process in the control system: ##### Then by the formula (30): ##### From (32) roots will be choosed: ##### Now the values of Ki, Kd, d1 are calculated for our example using (25): ##### Thus: ##### The Step Response of the control system is shown in Figure 3-2: Figure 3-2: Step Response of the Analog Modal Control System (37)

##### Since the degree of the numerator is greater than the degree of the denominator in (36), it is necessary to apply the Kalman-Bucy Filter (see also the (16)). To design this filter, we also use the modal method using (17), (30), (31): ##### Laplace transfer function of the Kalman-Bucy filter from Figure 2-2: ##### Note for (40): ##### The stable correction Hsc(s) will be searched in the form: ##### Then: ##### The characteristic equation for Kalman-Bucy filter will take the form: ##### For our example (18), the characteristic equation for Kalman-Bucy filter will be written: ##### Then: ##### Now from (39) the roots of the characteristic equation are selected: ##### Then: ##### Comparing (44a) and (46), we get: ##### Solving (47) with respect to T1, T2, Ksc, we obtain: ##### For our example: ##### As a result: ### 4. Selecting the Sampling Rate for the Digital Regulator

##### (52) for our example:  Figure 4-1: Analog Modal Control: Bode Diagram of the External Open Loop

##### The sampling frequency choice based on 5 degrees = 0.0873 radians of uncertainty caused by sampling, at a cross frequency of 6.28 Rad/s (see the Figure 4-1). In this case, the stability reserves will worsen for the digital control system by about 5 degrees. The uncertainty of the phase is calculated by the formula: ##### Then for external loop: ##### Now let’s open the internal feedback loop (see the Figure 2-1) and write down the Laplace transfer function:  Figure 4-2: Analog Modal Control: Bode Diagram of the Internal Open Loop

##### The cross frequency in this case is 57.5 Rad/s (see the Figure 4-2) then for internal loop: ### 5. Digital Regulator

##### The structure of the digital regulator is shown in Figure 5-1 Figure 5-1: Digital Modal Control System with the Kalman-Bucy Filter

##### Dynamic Correction: ##### Stable Correction: ##### Object Prediction: ##### Zero Order Hold: ##### Object: ##### The Step Response of the digital control system is shown in Figure 5-2. Figure 5-2: Step Response of the Digital Regulator

### 7. Octave GNU file ModalControl.m

#### The m script generates magnitude, phase and step responses, test signals and checks the analog/digital modal control systems. To do this, the following functions are defined in this file:

% Plotting the Step Response of the Analog Filter: (…+b1*s^2+b2*s+b3)/(…+a1*s^2+a2*s+a3)
% Input parameters:
% SB — numerator
% SA — denominator
% TimeVector – Time space
function plot_StepResponseAnalogFilter(sys, TimeVector, Text)

% Plotting the Step Response for the Digital Filter: (b1+b2*z^-1+b3*z^-2+…)/(a1+a2*z^-1+a3*z^-2+…)
% Input parameters:
% ZB — numerator
% ZA — denominator
% SampleNumber – Sample number of the step function
function plot_StepResponseDigitalFilter(ZB, ZA, SampleNumber, Text)

% Digital Close Loop: Localization Regulator
% Input parameters:
% ZB_object — numerator
% ZA_object — denominator
% ZB_staticCorrection — nummerator
% ZA_staticCorrection — denominator
% ZD_dynamicCorrection — nummerator
% ZB_dynamicCorrection — denominator
% ZB_stableCorrection — nummerator
% ZA_stableCorrection — denominator
% x_input – input signal
function [y_output] = DigitalModalCloseLoopRegulator(ZB_object, ZA_object, ZB_staticCorrection, ZA_staticCorrection, ZD_dynamicCorrection, ZB_dynamicCorrection, ZB_stableCorrection, ZA_stableCorrection, x_input)

% Float Table to File
% Support C-Code
% Input parameters:
% ParameterVector – data array
% FileNameString – output file name
function FloatParamVector2file(ParameterVector, FileNameString)

### 8. C Language ModalControl.c/h

##### Functions:

/*
Control System Initialization
Clear the working arrays
Input: void
Return: void
*/
void ControlSystemInit(void)

/*
IIR Filter with Transposed Form II
Input
float input – filter input
Return
float – filter output
*/
float iir_filter(float input, float const* all_coef_ptr, float* all_history_ptr, uint8 sos_nmb)

/*
Regulator
Input
float require – require value
float object – object value
Return
float – control value
*/
float Regulator(float require, float object)

/*
Object Simulation
Input
float control – control value
Return
float – object output value
*/
float ObjectSimulation(float control)