Award
Congratulations Rich, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

Mecanum Wheels Movement Panel

Assistance Requested

Help askpaul with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

askpaul claims to have checked these sources:
 
#1

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 EZ-Builder software OR is there a way to do this already?
Any help is appreciated!
Cheers!

I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.


Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


#2

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

Code:

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.

#3

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 EZ-Builder and havent really ventured into the code section! Smile
Cheers!

#4

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...

Code:

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;

Code:

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"Winky command in the custom Movement Panel.

Code:

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...

Code:

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.

Code:

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.

#5

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.

Code:


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

Code:

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



Reverse

Code:

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



Stop

Code:

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)

#6

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

#7

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 EZ-Builder.

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.

#8

@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.



Smile Smile Smile Smile

john

#9

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

#10

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