Override or reset limit switch status via packet serial

General discussion of using Roboclaw motor controllers
Post Reply
falkoschindler
Posts: 4
Joined: Mon Aug 17, 2020 2:19 am
Override or reset limit switch status via packet serial

Post by falkoschindler »

We're trying to control a motor with two limit switches, both connected to S4. It rarely happens that the system boots with the motor touching one of the limit switches. If the RoboClaw assumes the wrong switch being pressed, there is no way to get out of this situation without manually moving the motor. This is especially problematic for our remotely operated robots.

Is there any way to override S4 and still move the motor with low power? We could observe the encoder and determine the right direction programmatically.

We thought about setting the pin mode for S4 to 0x00 Disabled and back to 0x72 Home(User)/Limit(Fwd). But the RoboClaw does not seem to reset the S4 state. And we are sceptical if changing the configuration during operation might "wear out" the flash memory too quickly.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Override or reset limit switch status via packet serial

Post by Basicmicro Support »

This is a limitation of the one wire dual limit switch system. You must NOT power down while the forward limit switch is triggered. Other wise you will get stuff and need to manually move the motor out of the limit switch.

I have not done this myself, but you should be able to disable the limit switch(change mode from both limit to none, move the motor backwards enough to be out of the forward limit, then re-enable the both limit mode, then proceed to manually home the motor.

This would have to be triggered manually by the operator in this case.
falkoschindler
Posts: 4
Joined: Mon Aug 17, 2020 2:19 am
Re: Override or reset limit switch status via packet serial

Post by falkoschindler »

Thanks for your quick reply!

Meanwhile, I managed to find the following workaround:

When the motor is in a limit switch and only can move forward, but the RoboClaw thinks it should move backwards, I can to the following sequence:

1. Disable the limit switch.
2. Power the motor backwards (into the limit) with very little duty.
3. Enable the limit switch again. The limit is recognised immediately, but this time with the correct direction.
4. Stop the motor.

Code: Select all

claw.SetPinFunctions(address, 0x01, 0x00, 0x00);
delay(10);
claw.DutyM1(address, -1);
delay(10);
claw.SetPinFunctions(address, 0x01, 0x72, 0x00);
delay(10);
claw.DutyM1(address, 0);
This is not perfect, but helps to avoid manual interventions.
falkoschindler
Posts: 4
Joined: Mon Aug 17, 2020 2:19 am
Re: Override or reset limit switch status via packet serial

Post by falkoschindler »

I just noticed that we don't have to mess with the pin functions in order to "reset" or "ignore" the limit switches. Simply powering the motor in one or both directions with minimum duty brings the RoboClaw back into the no-limit state:

Code: Select all

claw.DutyM1(address, -1);
delay(10);
claw.DutyM1(address, 1);
delay(10);
claw.DutyM1(address, 0);
I find this rather dangerous, since it allows the motor to power against a pressed limit switch. But the RoboClaw probably only observes positive edges on S4 and S5, so it does not know if the motor actually left the limit.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Override or reset limit switch status via packet serial

Post by Basicmicro Support »

Yes, Roboclaw is looking at edges.

Can you describe how you are doing this in more detail, because once the limit is triggered it shouldn't clear until it is no longer triggered and it shouldn't let you move into the limit switch, only out of it. Eg if the limit was triggered while moving forward it will block further forward power until the limit is released and if it was triggered while powering the motor backwards it will limit reverse power until the limit is released(eg triggered by an edge).

On power up the Roboclaw checks the state of the limit and assumes the last move was a reverse if the limit was triggered, which should prevent any reverse power at all until the limit switch is released.

Basically it sounds like you found an edge case that needs to be fixed, which will prevent you from doing what you are doing but will be safer over all.

Post Reply