HBridge - 4 Wire HBridge PWM

How To Add This Control To Your Project

Step #1) Load the most recent release of EZ-Builder
Step #2) Press the Project tab from the top menu bar of EZ-Builder
Step #3) Press Add Control from the button ribbon bar of EZ-Builder
Step #4) Choose the HBridge category tab
Step #5) Press the 4 Wire HBridge PWM icon to add the control to your project


Description

An H bridge is an electronic circuit that enables a voltage to be applied across a load in either direction. These circuits are often used in robotics and other applications to allow DC motors to run forwards and backwards. H bridges are available as integrated circuits, or can be built from discrete components.


Wiring

1) Connect L298 VCC to either your battery supply positive or EZ-B power (red) on pin D0
2) Connect L298 GND to either your battery supply positive or EZ-B power (gnd) on pin D0
3) Connect L298 IN1 to EZ-B Signal Pin D0 (white)
4) Connect L298 IN2 to EZ-B Signal Pin D1 (white)
5) Connect L298 IN3 to EZ-B Signal Pin D2 (white)
6) Connect L298 IN4 to EZ-B Signal Pin D3 (white)
7) Connect L298 ENA to EZ-B Signal Pin D4 (white)
7) Connect L298 ENB to EZ-B Signal Pin D5 (white)
9) Connect L298 OUT1 to Motor 1
10) Connect L298 OUT2 to Motor 2

*Note: Because the above diagram is powering the HBridge off VCC (direct from battery), the switch will need to be Pressed Down. Although, please note that some HBridge versions reverse the direction of the switch and it will operate better UP. You will know which way the switch needs to be because the motors will not turn if the switch is incorrect position.

hbridge.jpg

In EZ-Builder, use the HBridge Motor Control. Press the Config button and select the pins that you connected the L298's INPUT Pins too (example D0, D1, D2, D3, etc).

Diagnose

If the robot moves in reverse directions, simply go back into the CONFIG menu of the HBridge Control and swap the configuration around to [D3, D2, D1, D0] or [D1, D0, D3, D2] or [D2, D3, D0, D1]. You may need to try a few combinations to get it right. Sometimes it confuses us too!

There is a great tutorial from Rich that you can find here.

Speed Control

The PWM in the title of this control means the HBridge will accept a PWM (pulse width modulation) signal from the EZ-B. That is how the EZ-B will control speed of the HBridge. As you recall from the How Servo Works tutorial, you know what PWM is, right? Because this control will allow speed adjustments, this gives your project the ability to use joysticks and other controls that manage speed. Read more about how Movement Panels work in the Activities Guide.

Initialize Code

When the EZ-B connection is made, there will be no PWM signal. The PWM signal for this control is specified by the SetSpeed() command. This is usually initialized in your Init script, or in the Connection Control's Connection Established Command.

  • Locate the Connection Control and press the Gear Configuration button.
  • In the connection control's dialog settings window, locate the 0 - Connection Established Command. This is the script which will execute when the EZ-B Board #0 is connected to an EZ-B. Press the Script Edit button for the Board #0 Established Command.
  • Insert or append the following code and press SAVE to close all dialog windows.

# This sets the speed for the HBridge Motor Controller
# The speed is a number between 0 and 255
# Setting this speed will initialize the PWM on the motor controller
SetSpeed(255)


Related Tutorials & Activities

Movement Panels

Movement Panels

One of the powerful features of EZ-Builder is the concept of Movement Panels. A Movement Panel is a control which is responsible for how your robot moves in directions (forward, left, right, stop, r...

Last Modified on 2/11/2017

Created by EZ-Robot


My Current Dewy Drive Train Setup + Info

Ok. So. People who might be unsure how they're supposed to connect h-bridges to the ez-b V4 will wanna check this one out for an idea. I made this video to show people how my Dewy drivetrain is currently setup. If it helped anyone, let me know! If I was wrong at any point in the video leave a comment on it. Thanks guys, And I hope it helps! Tech.

Last Modified on 9/15/2015

Created by Cardboard Hacker


L298n H-bridge

Setting Up L298n H-Bridge This tutorial assumes only a single combined speed control for both motors. For independent speed of each motor the tutorial will be slightly different - See post #2 of this topic. Assuming ports D15, D16, D17, D18 & D19 D15 Signal > Left Trigger A (In 1) D16 Signal > Left Trigger B (In 2) D17 Signal > Right Trigger A (In 3) D18 Signal > Right Trigger B (In 4) D19 VCC > H-Bridge 5V D19 Ground > H-Bridge Ground D19 Signal > H-Bridge...

Last Modified on 9/15/2015

Created by Rich


Use Arduino for Wheel Encoder Counter

Have your Arduino count motor encoder rotations. Connect the Arduino to your EZ-B UART #0 port to send the encoder counts.

Last Modified on 5/26/2016

Created by ezrobot


Control Meccano Meccanoid

Connect a Meccanoid to your EZ-B by using an Arduino as the translator.

Last Modified on 6/5/2016

Created by ezrobot


Related Products

2.5 Amp Motor Controller

This 2.5 Amp DC Dual Motor Controller is great for driving a set of small and medium sized DC motors. This is more than enough juice for Omnibots...

Rover Body with HBridge

Two adjustable height rubber tracks with powerful motors and included HBridge for your custom Revolution robot. With 13 EZ-Bit connection points,...

Related Articles: N/A