Reversing directions at limits (Roboclaw vs MCP)

Questions about using encoders with the Roboclaw product line
Post Reply
bgantner
Posts: 4
Joined: Fri Oct 27, 2017 11:36 am
Reversing directions at limits (Roboclaw vs MCP)

Post by bgantner »

I'm setting up a drum/tether winding system and wondering if I can do it with the roboclaw limit switches or if I need to get a MCP and do some programming.

In short, I have a motor that moves a tether guide left/right in front of a drum to lay down the rope evenly. I have two limit switches, one on the left side, one on the right side. I want the motor to run one direction until it hits a limit switch, then immediately switch to the other direction and move that way until it hits the other limit switch and continue this cycle until commanded to stop (via python/usb). It also has to remember the last moving direction so that it can start moving correctly when commanded to start again. (This also assumes that it can be told to move 'backwards' to send the rope back off the spool and have the same general behavior just starting in the opposite direction).

I've read through the manual and the forums and I think the roboclaws can handle this, but I wasn't 100% sure. If I put the two switches (NO) in parallel on the same S pin (e.g. S4) and set the mode to "Motor 1 Limit (Both)" this would appear to satisfy the wiring condition. However, I'm unsure if I can then set the roboclaw to continue moving in the opposite direction or if it will just stop and will have to be commanded (via python) to go the other way. I'm also unsure as to its behavior thereafter when told to move 'forward' or 'backward'. Will it 'remember' the flips or will I have to track that in software?

Any advice would be appreciated!

ps-Like a few others, I tried searching the forums for 'limits' and 'switches' and it returns nothing because it says these words are too common. It would be really nice if we get results on things like that even if they are really numerous.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Reversing directions at limits (Roboclaw vs MCP)

Post by Basicmicro Support »

The Roboclaw is not scriptable. What you need is either a Roboclaw with an external microprocessor to handle scripting or the MCP.

In either case you will have to command the movements explicitly via packet serial commands or an MCL script.
cyberdemon
Posts: 10
Joined: Sun Oct 08, 2017 3:41 am
Re: Reversing directions at limits (Roboclaw vs MCP)

Post by cyberdemon »

I don't think there is a command to read all of the digital inputs, and the "flip switch" input only works in "RC/Analog" modes. Nor are the limit switch inputs readable via the API.

However, you can read the "home" switch input state via the "Read Status" command (90).
If you were to connect your parallel switches to the "home" input, and continuously poll the "read status" command until you see a logic 1 for the "home" bit (0x4000), then you could use that as the trigger to reverse the motor.

Post Reply