I am doing work in which the goal is to design a state observer to estimate the speed of a DC motor using only armature current. The first part is ready, where I got the engine characteristics and designed the observer on MATLAB. My difficulty now is to implement the observer in arduino. The observer expression is: x '^ = (A-LC) x ^ + B * u + L * y

Where A, L, C, B are already defined matrices, u = armature voltage (voltage applied to the motor) and y = armature current. My difficulty is assembling this expression in code, can someone help me. Remembering that u and y will be real time readings of the armature voltage and current respectively.

Its my first time using Arduino and i really don’t know how to program this.

i have done this code so far and i don’t know if it’s right. The “for” part is not working.

float Va = 0;

float y = 0;

const double matr_A_LC[2][2] = {

{-8, 46400},

{-7, -959}

};

const double matr_L[2][1] = {

{-29889},

{-261}

};

const double ent[1][1] = {

{Va}

};

const double saida[1][1] = {

{y}

};

const double B[2][1] = {

{0},

{289.8551}

};

double states[2][1] = {

{0},

{0}

};

double nstates[2][1] = {

{0},

{0}

};

void setup() {

Serial.begin(9600);

}

void loop() {

Va = analogRead(0);

Va = map(Va, 0, 1023, 0, 15);

y = analogRead(1);

for (int i = 0; i<2; i++){

for (int j = 0; j < 2; j++){

nstates *= matr_A_LC [j]states[j]; //+ ent + matr_L_saida;_*

** }**

** }**

*}*