Using MTIdentLSQ to simulate finite step responses or finite impulse responses for the MTMpcSisoEnhanced function block

Hello,

I’m am trying to get the Model Predictive Control (MPC) function block up and running on my motor. I see that model predictive control function block, MTMpcSisoEnhanced, takes an array of 400 values that can either be finite step response (FSR) values or finite impulse response values (FIR) in order to generate the system model.

My question is, rather than getting these values experimentally through the motor, would it be possible to create a discrete transfer function from the MTIdentLSQ function block, and then with this system model, simulate what the values would be for either FSR or FIR by running it through a function block that I would make myself?

Any help would be greatly appreciated.

Thanks in advance.

Is there anyone in the BRCommunity who can help? Otherwise, @s_reilly please contact your local B&R office support.

I think that this topic is related to this newer thread: MTMpcSisoLite not allowing velocity to reduce - Ask Questions - B&R Community

Hello,

I have created a function that converts the output from MTIdentLSQ into an FSR. Here is the code for it:

FUNCTION_BLOCK DT_to_FSR

FOR j := 0 TO SysOrder - 1 DO
	TempNum[j] := Num[j];
END_FOR

FOR j := 0 TO SysOrder DO
	TempDen[j] := Den[j];
END_FOR


FOR j:=0 TO SysOrder - 1 DO
	Num[j] := TempNum[SysOrder-j-1];
END_FOR

FOR j := 0 TO SysOrder DO
	Den[j] := TempDen [SysOrder-j];
END_FOR

FOR k := 0 TO TotalSamples - 1 DO
	
	IF k = 0 THEN
		StepResponse[k] := 0;
	
	ELSIF k = 1 THEN
		StepResponse[k] := Num[0] - (Den[1] * StepResponse[k - 1]);
	
	ELSIF k = 2 THEN
		StepResponse[k] := Num[0] + Num[1] - (Den[1] * StepResponse[k - 1] + Den[2] * StepResponse[k -2]);
		
	ELSIF k = 3 THEN
		StepResponse[k] := Num[0] + Num[1] + Num[2] - (Den[1] * StepResponse[k - 1] + Den[2] * StepResponse[k -2] + Den[3] * StepResponse[k - 3]);
	
	ELSIF k = 4 THEN
		StepResponse[k] := Num[0] + Num[1] + Num[2] + Num[3] - (Den[1] * StepResponse[k - 1] + Den[2] * StepResponse[k -2] + Den[3] * StepResponse[k - 3] + Den[4] * StepResponse[k - 4]);
	
	ELSE 
		StepResponse[k] := Num[0] + Num[1] + Num[2] + Num[3] + Num[4] - (Den[1] * StepResponse[k - 1] + Den[2] * StepResponse[k -2] + Den[3] * StepResponse[k - 3] + Den[4] * StepResponse[k - 4] + Den[5] * StepResponse[k-5]);
	END_IF
		
END_FOR

END_FUNCTION_BLOCK

It goes off the idea of the Autoregressive Exogenous model (ARX model). Here’s a youtube video explaining what that is:
8. AutoRegressive eXogenous (ARX) model

The torque is still causing a problem however, so I am going to have to get in contact with some of the people from B&R it seems.

1 Like