Australia
Asked — Edited
Resolved Resolved by Rich!

Mecanum Wheels Movement Panel

Hello, I know there is another post by another EZ-Robot member but it had no answer. I would like to use two H-Bridge motor controllers simultaneously to provide my robot (custom built from meccano) with 4WD functionality AS WELL AS side to side and 360 degree movement. I know this can be done with omni wheels but I would like to be using MECANUM wheels because of their cool direction movement.

My Question: Is there a script I could use to do this inside the ARC software OR is there a way to do this already? Any help is appreciated! Cheers!


ARC Pro

Upgrade to ARC Pro

Your robot can be more than a simple automated machine with the power of ARC Pro!

United Kingdom
#1  

Yes.

I have provided some script examples for dual h-bridge controls with some explanations for how to control them with script commands.

It depends on the H-Bridge used but most are very similar. Basically

Set(DigitalPort,On/Off)

to set the correct port to On or Off will make the motor move one direction or the other. I will see if I can dig out the old topic with this explained however, if you check under the cloud at the Multi H-Bridge I put up, and check the examples too since there are more in there.

Hopefully those links will help, if not please feel free to ask more specific questions and I will gladly provide you with the correct script commands.

Australia
#2  

Hi Rich, Thanks for the quick reply. Can you explain how I use the download file and how to use the provided code? I have mainly used the 'built' components of ARC and havent really ventured into the code section!:) Cheers!

United Kingdom
#3  

It's more of an example to show you how you can set up the controls, since the example is for 2 H-Bridges as though it's 2 robots.

The easiest way would be to start by setting up scripts for each movement. So driving forwards, set up the script in script manager for that, using Set() commands to enable and disable the specific H-Bridge ports as needed.

For instance, assuming your H-Bridges are on the following ports;

HBridge1 In1 - D0 In2 - D1 In3 - D2 In4 - D3

Hbridge2 In1 - D4 In2 - D5 In3 - D6 In4 - D7

Usually, with a single H-Bridge you would set both motors to drive forwards, in this case setting D0 and D2 high and D1 and D3 low...

Set(D0, On)
Set(D1, Off)
Set(D2, On)
Set(D3, Off)

This would send the wheels both driving forwards. To make it 4wd you simply just add in the same for the other H-Bridge to set the other 2 motors to move forwards;

Set(D4, On)
Set(D5, Off)
Set(D6, On)
Set(D7, Off)

Now all 4 motors should run forwards. So you use both pieces of code in the script for the forward command. Personally I would add it to the script manager and then run a controlcommand("Script Manager", ScriptStart, "forwards") command in the custom movement panel.

Set(D0, On)
Set(D1, Off)
Set(D2, On)
Set(D3, Off)
Set(D4, On)
Set(D5, Off)
Set(D6, On)
Set(D7, Off)

For reverse, just change offs for ons and vice versa. Save as reverse.

I'm going to have to rush now as I need to get to bed in a second but hopefully it'll be enough information to get you going. If not I will expand on it tomorrow.

You will need to decide if you want left and right to turn left and right or move left and right. If move, to use the wheels as they are supposed to be, then I assume the front and rear wheels need to move in opposite directions for the sideways movement to work...

Set(D0, Off)
Set(D1, On)
Set(D2, Off)
Set(D3, On)

That should send the left and right hand side front wheels moving in reverse. Now to move the rear wheels forwards.

Set(D4, On)
Set(D5, Off)
Set(D6, On)
Set(D7, Off)

Save that as a script for slide left (or slide right if it moves to the right not left).

Reverse it again for it to move the other way.

Sorry this has become a bit of a mess towards the end, time is against me. If you are confused or if you haven't responded with positive results I will re-do this tomorrow so it is very clear.

United Kingdom
#4  

A much easier method of explaining is this.

Each motor is controlled by a pair of digital signals. So we have a truth table for each motor.


In1 | In2 | Function
 0  |  0  | Freewheel/Stop
 0  |  1  | Forward
 1  |  0  | Reverse
 1  |  1  | Brake

So for each motor you need 2 Set Digital commands to control it. Assuming D0 and D1 but you will need to change it for the other motors. Forward

Set(D0, On)
Set(D1, Off)

Reverse

Set(D0, Off)
Set(D1, On)

Stop

Set(D0, Off)
Set(D1, Off)

So with that in mind, if all 4 wheels need to move forwards, set the 8 digital ports as the above forward commands. To reverse, all 4 wheel as the reverse command. Left or right rotate, one side's wheels set to the forward command, the other side to the reverse command or vice versa. Left or right move, front wheels set to the forward command, rear wheels set to reverse or vice versa. To stop, all 8 ports as the stop command.

This is based on the 2.5A H-Bridge. Which means the ENA and ENB both need +5v or a PWM signal (for speed control)

Australia
#5  

Thanks Rich! That makes everything much clearer! I just noticed the ARC update and have found that the Movement Panel can be speed controlled via a joystick now. Thanks again for your help,much appreciated. Cheers

United Kingdom
#6  

I got a little bored so threw together an Example Project for this setup using Script Manager with the scripts to run the specific movements and key control. You can add your own custom Movement Panel and add ControlCommands to run the specific movements.

Note: There is no speed control used. This can be added if needed, just ask and I will provide info and examples.

Download or open from the cloud in ARC.

Note 2: I have not checked side to side movements, if the direction is backwards please tell me and I will adjust the project to suit.

#7  

@Rich,

I just want to say Thanks for all your answers to all the questions that are asked.

You are my hero and save me many hours of how to do something or understand how it works.

:):):):)

john

United Kingdom
#8  

You're all more than welcome:) I'm happy to help.

#9  

A custom Movement Panel with a couple of additional buttons for left and right movement would be a neat enhancement for ARC. May be we can get DJ to think about it.