Restore position with MpRobotFlex

Can anyone explain how Axis homing is intended to work with Mapp Robots? We have an axis wrapper that manages this typically, but on a machine we are working on currently we thought we could get away without having individual MpAxis Fubs and instead we are using only MpRobotFlex. We have Multi-turn absolute encoders and have setup the perm data on the drive, but it doesn’t seem to work how I would expect. I thought the intention was that on bootup, if the endless position data was valid it would just automatically restore it, but we aren’t seeing that; if we just trigger a robot “Home” it does a direct home.

This is our Mapp Axis Wrapper that we usually use:
https://github.com/loupeteam/AxisLib/blob/main/src/Ar/AxisLib/AxisReference.c

At some point we did not like the behavior of restore pos and that we were breaking the relationship between that data and drive so we made this PR, but I’m not sure what would work better:

One of the core problems that we have with the default behavior of tying the data directly to the drive is that once it is initialized we can’t change the data and restore a previous calibration. We backup our perm data to a file, so that we can restore it if the perm data gets corrupted, but there is not way to restore it once the drive takes over that data.

Hi Josh @c159699
this works as you expect but it may depend on the motion version you are using. I’m using 5.24 for the example below.

If you configure the RestorePosition homing mode and variable under the drive configuration…

image

the axes positions are restored after boot up and a Home command on the robot function block.
There is no need for the individual axis function block interaction or even the function block itself.

HomeRestorePosition with robot

This obviously only works after the restore position variables have been initialized by homing each joint with a direct home for example in mappCockpit. Unlike in the past, there is also no other functions blocks required anymore.

I hope this makes sense! Maybe share your motion version and we go from there.

Hi Marcel! Thanks for the info. I think that does explain the behavior we see.

We currently have the homing mode set to “direct” on the drive. Our expected behavior is that if you give it a PV, if the data is valid it would restore it on boot up without requiring a home, and the home configured on the drive would be how to “calibrate” the home position.

Based on your explanation it seems like there is no built in way to “calibrate” without mapp cockpit or extra homing function blocks. Is that true?

It seems a little strange to me that you can specify a restore position PV if you are not using that mode in the physical view since it won’t actually use it by default. Don’t you have to call init home with restore and a PV to restore pos if it isn’t set in the hardware?

mcHOMING_DEFAULT means as much as “use the configured values”.

Based on your explanation it seems like there is no built in way to “calibrate” without mapp cockpit or extra homing function blocks. Is that true?

That is true, but that has always been the same base concept for B&R axis! You always have to home an axis once in order to be able to “restore” the position with an homing offset or a PV. That also makes sense for me, because you need to align the axis with the machine, so you need to home at least once right?! :slight_smile:

It seems a little strange to me that you can specify a restore position PV if you are not using that mode in the physical view since it won’t actually use it by default. Don’t you have to call init home with restore and a PV to restore pos if it isn’t set in the hardware?

Yes, if the PV was not mapped in the module configuration, you’ll have to call MC_BR_InitHome_AcpAx / MC_BR_InitHome_StpAx by yourself! But I can’t quite follow your question. If you are specifying the PV in the physical view, you don’t have to call the InitFB and can just use the RestorePosition homing after the initial “calibration” homing. You just have to change the mode used in the software. Don’t use mcDEFAULT, but depending on your usecase mcHOMING_DIRECT for the initial homing (e.g.) and mcHOMING_RESTORE_POSITION afterwards.

Best regards!

My main point is that the MpRobotFlex doesn’t have a homing mode parameter.

All the other homing modes can be used completely with the block, but the restore position has 2 operations that need to be done

1: Initial calibration
2: Restore previous calibration

If we set up the physical view for restore, we have to write code to do the initial calibration.

If I understand correctly we have to call Home init to set the calibration homing parameters, then call home on each individual axis.

That’s why my question was about the “intention”. It seems like this could be improved by having the restore pos mode on the drive have a section for calibration homing mode, and a way to use it on MpRobotFlex.

It may not been a much known feature (I also didn’t know for a long time), but that’s not exactly true for MpAxisBasic. If you use MpAxisBasic and configure some homing mode AND connect a restore position variable, the axis will be automatically homed with restore position if the variable is valid.
image
You will see the IsHomed status of the MpAxisBasic going to true without ever giving a home command. If you need to calibrate your axis, you can just call MpAxisBasic.Home with mode default and it will use the configured mode.

@c159699 Josh, this is really a MpAxisBasic feature, as it is also an option on the MpAxisBasicParType structure to not use this feature. You could still just call the MpAxisBasic function blocks, but give all the commands on the MpRoboticsFlex function block. The MpAxisBasic FBs will then just give you this additional functionality.

Additionally the MpAxisBasic function blocks internally connect to the MpRobotics funtion blocks for the homing mode. As you may have seen, there are no homing parameters on the MpRobotics FBs. In order to set the homing parameters you can set the parameters on the MpAxisBasicParType parameters and call the MpRoboticsFlex.Home command.

[EDIT]Sample

PROGRAM _INIT
	AxisBasicQ1.Enable := TRUE;
	AxisBasicQ2.Enable := TRUE;
	
	RoboFlex.Enable := TRUE;
	RoboFlex.Override := 100.0;
	
	// Will be connected to MpRobotics FB
	AxisBasicParQ1.Homing.Mode := mcHOMING_DEFAULT;
	AxisBasicParQ2.Homing.Mode := mcHOMING_DEFAULT;
END_PROGRAM

PROGRAM _CYCLIC
	// MpAxisBasic FBs for automatic restore position handling and homing mode selection
	AxisBasicQ1.MpLink := ADR(gAxisQ1);
	AxisBasicQ1.Parameters := ADR(AxisBasicParQ1);
	AxisBasicQ1();
	AxisBasicQ2.MpLink := ADR(gAxisQ2);
	AxisBasicQ2.Parameters := ADR(AxisBasicParQ2);
	AxisBasicQ2();
	
	// MpRoboticsFlex FBS for all commands and status
	RoboFlex.MpLink := ADR(g2AxDeltaB);
	RoboFlex.Parameters := ADR(RoboFlexPar);
	RoboFlex();
END_PROGRAM

[SECTION EDITED]
Otherwise it is also possible to use the MC_BR_GroupHome_N function block for homing.
For calibration you could set the mode to mcHOMING_DEFAULT to select the configured mode from physical.
For normal operation you could set the mode to mcHOMING_RESTORE_POSITION to use the configured restore PV of the physical view. If the PV is not valid, this will then fail and you know you will need a calibration. This is also the big advantage of configuring the restore position in the physical view, as you can just use the mcHOMING_RESTORE_POSITION mode without initializing it with function blocks.

2 Likes

Thanks Patrick, exactly! We had set up the physical axes to use that and I was surprised when MpRobotFlex had different behavior. It would be nice if MpRobotFlex had the same behavior so that we didn’t have to use extra MpAxesBasic blocks. Maybe a future feature :wink:

Thanks for the info!
“Again what learned!”
:smiley:

Feel free to contact your local B&R office for a product request :grin:.

At the same time it is not as simple for a whole robot as for a single axis. The restore position thing is no big issue, but how will you handle if it fails? How do you know which axis failed? Also, when you calibrate, you usually have to do it every axis at a time. So you cannot set a single homing mode or command for the whole robot anyway. This means that if you want to calibrate, you need to handle single axes anyways.

I would argue it is pretty simple, any axis that has a position that can be restored should do it automatically. If all the axes are homed then the robot is homed.

If there are any failures (invalid home data, error while homing, axes that aren’t setup to Autohome… ) then the robot is not homed and you are in the same situation you are without that feature, with the exception that you can actually use the “Home” on the function block as if there was no restore position PV on the drive. Then the user can jog in the Axis Coordinate System to the home position and direct home (or do whatever the default homing is).

I think the most complicated reason NOT to do this is because if you are a using MpAxisBasic AND MpRobotFlex then it isn’t clear which one would handle this. Although, I imagine that could be solved…

Blockquote I think the most complicated reason NOT to do this is because if you are a using MpAxisBasic AND MpRobotFlex then it isn’t clear which one would handle this. Although, I imagine that could be solved…

I’ll try to clarify this, so you can decide what suits you best and have no doubt what happens inside:

  • when you use MpRobotFlex (or any other MpRobot FB) + MpAxisBasic for joint axis, then the robot FB detects the usage of MpAxisBasic. When Robot.Home command is set the homing parametrization will be based on the parameters assigned to each individual MpAxisBasic joint FB. This includes possibility that homing parameters including the RestorePositionVariable are solely defined in parameters structure and not configured. The homing is still executed in Robot scope which allow to use functionalities like configured homing order.
    Additionally as already mentioned above by @patrick.tanner MpAxisBasic has a feature that during FB activation (Enable command) it automatically homes the axis with restore position mode when the data is valid. This can be disabled in Parameters when unwanted. So once calibration is done.

  • when the MpRobotFlex is used alone then the homing mode is the “Default” meaning each axis is homed based on current parametrization loaded from configuration. In this case you can still change the homing mode on runtime by MC_BR_ProcessParam or MC_BR_InitHome.

I hope I’ve made the point more clear :slight_smile: