Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

Get Started
Asked — Edited
Resolved Resolved by Rich!

Question About Hbridge Configuration

OK so I get to ask a question;) I have tried several variations and I have forward and reverse but left and right are inversed. I click right turn it turns left. Here's my arrangement can someone tell me what to switch so forward and reverse are still correct as well as right and left?
User-inserted image


Upgrade to ARC Pro

Harnessing the power of ARC Pro, your robot can be more than just a simple automated machine.

AI Support Bot
Related Content
Based on your post activity, we found some content that may be interesting to you. Explore these other tutorials and community conversations.
United Kingdom
H-Bridge configuration truth tables are on this topic if that's of any help.

Read through this without reading the last part and see if you can figure out where you went wrong before I finish explaining it:)

From the topic I linked to;


In4 | In3 | In2 | In1 | Function
0 | 0 | 0 | 0 | Stop/Free Wheel
0 | 0 | 0 | 1 | Motor 1 Forward
0 | 0 | 1 | 0 | Motor 1 Reverse
0 | 0 | 1 | 1 | Motor 1 Brake
0 | 1 | 0 | 0 | Motor 2 Forward
1 | 0 | 0 | 0 | Motor 2 Reverse
1 | 1 | 0 | 0 | Motor 2 Brake

So to use that on the robot, setting digital to on (1) and off (0) as follows


In4 | In3 | In2 | In1 | Function
0 | 1 | 0 | 1 | Robot Forward
1 | 0 | 1 | 0 | Robot Reverse
1 | 0 | 0 | 1 | Robot Turn Left (or right depending on motor orientation)
0 | 1 | 1 | 0 | Robot Turn Right (or left depending on motor orientation)
0 | 0 | 0 | 0 | Robot Stop

So look at the truth table. Look at what you can change to keep the highs and lows on Forward and Reverse the same. It may be easier if you looked at it like this. This is what you currently have;


Right Motor| | Left Motor|
D04 | D03 | | D01 | D02 | | Function
-----+-----| |-----+-----| |--------------
0 | 1 | | 0 | 1 | | Robot Forward (OK)
1 | 0 | | 1 | 0 | | Robot Reverse (OK)
1 | 0 | | 0 | 1 | | Robot Turn Left (WRONG)
0 | 1 | | 1 | 0 | | Robot Turn Right (WRONG)

Now if Left turns right and right turns left but forward is OK and reverse is OK. What can change for D2 and D3 to remain high and D1 and D4 low on forward, D2 and D3 to remain low and D1 and D4 high on reverse but change the left and right turn highs and lows? In the above table you can only change the D4, D3, D1 and D2 parts, the highs and lows for the functions must stay the same, they are fixed.

You need to swap left and right motors over so that when turning left the right motor moves reverse and the left moves in forwards. Turning left the right motor moves forwards and the left moves reverse.

We know forward and reverse are OK so that means the right and left motors left hand columns must be either D4 or D1. Reverse is OK too so the right and left motors right hand columns must be D3 or D2. Left and right are backwards so we know that we have to change something. If the right and left motors have the correct polarity it can only mean one thing can change.


Right Motor| | Left Motor|
D01 | D02 | | D04 | D03 | | Function
-----+-----| |-----+-----| |--------------
0 | 1 | | 0 | 1 | | Robot Forward
1 | 0 | | 1 | 0 | | Robot Reverse
1 | 0 | | 0 | 1 | | Robot Turn Left
0 | 1 | | 1 | 0 | | Robot Turn Right

Swap over both sides in their entirety. Change LTA to RTA and vice versa and LTB to RTB and vice versa.
OH ! I just have the right motor in the left output but the configuration only works one way. OK I will swap the left and right. I thought of doing that but after wiring all that stuff for three hours I kinda wanted to be done messing with wires for the night. In the tutorial it says it doesn't matter I could just change the configuration in ARC. OK I will swap and test when I get home man!
United Kingdom
I may have over complicated the answer... Leave the wires, change the config.

Change from what you have above to;
Left Trigger A = D3
Left Trigger B = D4
Right Trigger A = D2
Right Trigger B = D1
Alright I will adjust this soon as home.
yah you can also use a custom Movement Panel and do like what rich has shown and put the forward ro reverse pins to on using set(D1,on) etc inside the movement panel. I found this better because i could add additional code when moving forward, etc. and to add another H-Bridge would be supper easy (on the same chasis such as rover 5 where they both do the same thing) just do the same thing as before but for new ports add put them in the code of the custom movement panels. Also by doing it in custom Movement Panel you can control the PWM while pressing arrow keys, handing if you want to use if statements.

Ex: my L298N code consists of moving left by the right side moving forward and left side moving back, but i can also use q and e (u could use a and d) to turn by lowering the PWM on one side to turn, but if the PWM is at 0 then it prints "you must be driving for use". So an if statements sees if it is at 100 PWM or 0 PWM which tells if it is moving or not.


The file is also now on the cloud so I hope it can help you. The ports are different from yours but you could easily change your wiring or change the ports on the program.
United Kingdom
You could do that with the 4 wire h-bridge control panel too, just have a script that loops with;


If($direction = "forward")
# Run this code
ElseIf($direction = "reverse")
# Run that code
ElseIf($direction = "left")
# Run another code
ElseIf($direction = "right")
# Run more code
ElseIf($direction = "stop")
# Run something else
Alright cool . Thank you ! That fixed the direction problem I'm closing this thread.