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

**URL:** <https://community.br-automation.com/t/using-mtidentlsq-to-simulate-finite-step-responses-or-finite-impulse-responses-for-the-mtmpcsisoenhanced-function-block/7416>\
**Category:** Controls & Vision\
**Tags:** automation-studio, plc\
**Created:** [June 26, 2025, 9:41am UTC](https://community.br-automation.com/t/using-mtidentlsq-to-simulate-finite-step-responses-or-finite-impulse-responses-for-the-mtmpcsisoenhanced-function-block/7416 "2025-06-26T09:41:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![s\_reilly](https://avatars.discourse-cdn.com/v4/letter/s/FF8800/32.png) [@s\_reilly](https://community.br-automation.com/u/s_reilly)\
**Post date:** [June 26, 2025, 9:41am UTC](https://community.br-automation.com/t/using-mtidentlsq-to-simulate-finite-step-responses-or-finite-impulse-responses-for-the-mtmpcsisoenhanced-function-block/7416/1 "2025-06-26T09:41:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kovarj](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/kovarj/32/537_2.png) [@kovarj](https://community.br-automation.com/u/kovarj)\
**Post date:** [July 11, 2025, 5:13am UTC](https://community.br-automation.com/t/using-mtidentlsq-to-simulate-finite-step-responses-or-finite-impulse-responses-for-the-mtmpcsisoenhanced-function-block/7416/2 "2025-07-11T05:13:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![marcusbnr](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/marcusbnr/32/256_2.png) [@marcusbnr](https://community.br-automation.com/u/marcusbnr)\
**Post date:** [July 18, 2025, 12:42pm UTC](https://community.br-automation.com/t/using-mtidentlsq-to-simulate-finite-step-responses-or-finite-impulse-responses-for-the-mtmpcsisoenhanced-function-block/7416/3 "2025-07-18T12:42:27Z")

</div>

I think that this topic is related to this newer thread: [MTMpcSisoLite not allowing velocity to reduce - Ask Questions - B&R Community](https://community.br-automation.com/t/mtmpcsisolite-not-allowing-velocity-to-reduce/7560)

---

<div class="post-metadata">

**Author:** ![s\_reilly](https://avatars.discourse-cdn.com/v4/letter/s/FF8800/32.png) [@s\_reilly](https://community.br-automation.com/u/s_reilly)\
**Post date:** [July 22, 2025, 10:01am UTC](https://community.br-automation.com/t/using-mtidentlsq-to-simulate-finite-step-responses-or-finite-impulse-responses-for-the-mtmpcsisoenhanced-function-block/7416/4 "2025-07-22T10:01:30Z")

</div>

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](https://www.youtube.com/watch?v=ixsPlNrc1gM&msockid=7f4b699366e211f0846b9176b0d1f1f5)

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.
