## Control of Non Linear Object Using the Vostrikov’s Localization Method. C Code and Octave Script

### 2. Introduction

##### From what has been said the control system will take the form shown in the Figure 2-1

Figure 2-1: Localization Control System

##### In [1], [2] it is proved that the choice of parameters according to formula (18) makes it possible to divide the system into two subsystems of fast and slow processes / motions, while fast motions are described by linear differential equations, which simplifies the assessment of the stability of the control system. Figure 2-2 shows the subsystem of fast motions.

Figure 2-2: Subsystem of Fast Motions

### 3. Example of an Analog Regulator

##### Note This equation for the control object is taken as an example from [2]

Figure 3-1: Non Linear Object

##### Step response on the required transfer function is showed in the Figure 3-2

Figure 3-2: Required Step Response

##### The Figure 3-3 shows Example of the Localization Control System with analog Regulator:

Figure 3-3: Example of the Localization Control System with analog Regulator

### 4. Selecting the Sampling Rate for the Digital Regulator

##### Now let’s make a transfer function for the open control system shown in Figure 4-1 using the linearized control object (37):

Figure 4-1: Analog Open Loop Magnitude and Phase Response of Linearization Control System

### 5. Example of a Digital Regulator

##### The structure of the digital controller is shown in Figure 5-1

Figure 5-1: Localization Control System with Digital Regulator

##### A nonlinear control object in digital form is shown in Figure 5-2:

Figure 5-2: Digital Non Linear Object

##### The step response of the digital control system is shown in Figure 5-3:

Figure 5-3: Step Response of the Digital Regulator

### 7. Octave GNU file LocalizationForNonLinearObject.m

##### The m script generates magnitude, phase and step responses, test signals and checks the analog/digital localization 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:
% sys – object of the analog filter
% TimeVector – Time space
% Text – plot titel
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
% Text – plot titel
function plot_StepResponseDigitalFilter(ZB, ZA, SampleNumber, Text)

% Digital Close Loop with 3d order derivative filter (DF3): Localization for Non Linear Object
% Input parameters:
% x_input – input signal
% K — gain
% w_required – required transient process parameter
% Q_required – required transient process parameter
% SA_derivative3 – derivative polynomial
% a_obj_1 – object parameter
% a_obj_0 – object parameter
% b_obj – object parameter
% Ts – sample time
% Output parameter:
% y_output — output
function [y_output] = DigitalCloseLoopLocalizationNonLinearDF3(x_input, K_gain, w_required, Q_required, SA_derivative3, a_obj_1, a_obj_0, b_obj, Ts)

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

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

##### Functions:

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

/*
Bilinear Integrator
y(n)=y(n-1)+(Ts/2)(x(n)+x(n-1))
Input
float input – input
integrator_data_s* history_ptr – integrator history
Return
float – output
*/
float bilinear_integrator(float input, integrator_data_s* history_ptr)

/*
Zero Order Hold
y(n)=(1/2)(x(n)+x(n-1))
Input
float input – input
float* previous_ptr – previous input
Return
float – output
*/
float zero_order_hold(float input, float* previous_ptr)

/*
Regulator
Input
float x_require – require value
float y_object – object/measurement value
Return
float – u_control value
*/
float Regulator(float x_require, float y_object)