Add Second Motor to X20SM1436

Hello,
I use X20SM1436 to operate stepper motors. How can I add a second stepper motor to this module? This motor has a different current and a different step angle. The settings in mappMotion remain the same. I would like to be able to select the motor in the program and swap it. Is that possible?

Hello Rene,

welcome to the B&R Community!

With mapp Motion parameters can be changed during runtime with this function block:
MC_BR_ProcessParam

In your case these elements are relevant:

Tip for writing parameters:

  1. Read the parameters with MC_BR_ProcessParam (to your structure variable)
  2. Change the values you want changed (on your sttructure variable)
  3. Write the parameters with MC_BR_ProcessParam (from your structure varable)

This way no accidential changes or missing values are written.

Hello Martin,
thank you very much for your quick reply.
I’m still struggling with the correct call.
my axis appears in component
but I don’t know exactly what comes in Datatype and DataAddress.
is there an example anywhere?
Thanks for your Help.

Hello,

i did not read whole post, but i think you are in seach of this help Page, where the change of Parameter during runtime is descriped more in detail.

AS-Help Changing Stepper Configuration while Runtime

There are other Community Posts about ProcessParam/Config:
Unbounded Arrays in Process Param/Config
Usage of Process Config/Param

Greetings
Michael

Hello,

here is a Example for the change of Axis Limits. You might adapt it to your Stepper Usecase.

You can import it in an existing Automation Studio Projekt. It is only a Task i use for the Motion Training.

SEM415_ParamCfg.zip (1.5 KB)

Greetings
Michael

1 Like

Thank you very much for your quick help.

Hello Michael,
Reading out the step angle works so far so well, even without needing ProcessConfig.
But when I try to write the step angle, I always get an error.
Do you have any tips?


2025_03_06_12_44_36-P__Bereich_BT_EBC_BundR_SPS-Programme_Tests_Test_Stepper_Test_Stepper.apj_Config

Greetings
Rene

Hello,

There might be an issue in the MC_BR_ProcessParam Documentation…
In the Details about this Configuration there is only the ProcessConfig listed.

I think there should be more details in Logger.

I may check this in a sample but will need time…

Greetings
Michael

Hi,

You can not just read or write the stepping angle but need to always read or write the whole structure (MC_BR_Mot instead of MC_BR_Mot.Motor.SteppingAngle). Which is why you should read it first to populate the whole structure, then overwrite the value of the ones you are interested in and then write the content. (In this case, the address of the StepperAngle is the same as the whole struct, but this is not true for any other element, so better just give it the ADR(MC_BR_Mot))
Also, your screenshots differ in what they show: Your watch shows you are writing, your code screenshot shows hardcoded reading access - please show the actual code.
Also note that usually you should put the FUB call below the parameterization (like in Michael’s example)

Generally speaking please check the error id in the help and look at the cause/remedy section - it tells you to look at the logger.

Best regards
Michael

Edit: Added note about the address incidentally being correct and the FUB call to be below the parameters

Hello,

I can now tell that the Documentation is missing on the details Page, so the MC_ProcessParam list is correct the functionblock supports both Read and Write.

Which brings us to the point of the Colleague “Michael W” that there was probably an issue with your Data you wanted to write. It is also not optimal that your Functionblock Call is ahead of your Input-Parameterisation.
As he suggested, please have a look in the logbook which error we have encounterd.
For example:

If you have missing Component Adress, this will lead to this logger entry.

If you have wrong Parameter, for example “McCfgStpAxMotType_Data.Motor.RotationDirection := 0.0;” This will lead to this error entry.


Attatched my Testcode:

CASE Step OF 
	0: 
		
	10: 
		// Read 
		IF MC_BR_ProcessParam_Data.Execute = 1 THEN 
			MC_BR_ProcessParam_Data.Execute := 0; 
		ELSE 
			MC_BR_ProcessParam_Data.Component					:= ADR(gAxis_1); 
			MC_BR_ProcessParam_Data.DataAddress					:= ADR(McCfgStpAxMotType_Data); 
			MC_BR_ProcessParam_Data.DataType					:= mcCFG_STP_AX_MOT;
			MC_BR_ProcessParam_Data.Mode						:= mcPPM_READ; 
			MC_BR_ProcessParam_Data.AdvancedParameters.Name 	:= ''; 
			MC_BR_ProcessParam_Data.ExecutionMode				:= mcEM_IMMEDIATELY; 
			MC_BR_ProcessParam_Data.Execute 					:= 1; 
			Step	:= 20; 
		END_IF 
	
	15: 
		// Write 
		IF MC_BR_ProcessParam_Data.Execute = 1 THEN 
			MC_BR_ProcessParam_Data.Execute := 0; 
		ELSE 
			MC_BR_ProcessParam_Data.Component					:= ADR(gAxis_1); 
			MC_BR_ProcessParam_Data.DataAddress					:= ADR(McCfgStpAxMotType_Data); 
			MC_BR_ProcessParam_Data.DataType					:= mcCFG_STP_AX_MOT;
			MC_BR_ProcessParam_Data.Mode						:= mcPPM_WRITE; 
			MC_BR_ProcessParam_Data.AdvancedParameters.Name 	:= ''; 
			MC_BR_ProcessParam_Data.ExecutionMode				:= mcEM_IMMEDIATELY; 
			MC_BR_ProcessParam_Data.Execute 					:= 1; 
			Step	:= 20; 
		END_IF 	
		
		
	20: 
		IF MC_BR_ProcessParam_Data.Done THEN 
			// Success
			Step := 30; 
		ELSIF MC_BR_ProcessParam_Data.Error THEN 
			// Error 
			Step := 999; 
		END_IF 

	
END_CASE 
MC_BR_ProcessParam_Data();

EDIT: The Documentation Topic has been reported to the B&R Support.

Greetings
Michael

Hello,

In an Analysis of the logger entries it turned out, that changing of the “Stepping Angle” is not allowed. Only a change of “Rotation direction” leads to a success of the Functionblock. (Mapp 5.28.2)

For the moment the “Stepping Angle” is only changeable via MC_BR_ProccessConfig and executing a restart of the PLC. The restart can be executed manualy or via application SYS_Lib - SYSreset().

An updated Documentation will inform about this behaviour in future. Sorry for the
confusion generated by the missing details documentation.

Greetings
Michael Bertsch

Hello Michael
Thank you very much for your efforts and patience with me.
I will think about how to solve the problem.

Kind regards
Rene