Thumbnail

Dual Hbridge W/PWM

How to add the Dual Hbridge W/PWM robot skill

  1. Load the most recent release of ARC (Get ARC).
  2. Press the Project tab from the top menu bar in ARC.
  3. Press Add Robot Skill from the button ribbon bar in ARC.
  4. Choose the Movement Panels category tab.
  5. Press the Dual Hbridge W/PWM icon to add the robot skill to your project.

Don't have a robot yet?

Follow the Getting Started Guide to build a robot and use the Dual Hbridge W/PWM robot skill.


How to use the Dual Hbridge W/PWM robot skill

A movement panel for using a two-channel hbridge that uses DC motors. This will also control the speed of the motors using PWM signals to increase the robot's mobility.

An H-Bridge is an electronic circuit that enables a voltage to be applied across a motor in either direction. It's triggered by TTL signals from a microcontroller, such as an EZ-B. These circuits are often used in robotics and other applications to allow DC motors to run forward and reverse. A Dual H-Bridge (such as the EZ-Robot 2.5 Amp H-Bridge) controls two motors and can be connected to an EZ-B by six digital signal wires. 2 wires control each motor, and two wires are for PWM. PWM signals control the speed of each motor. This skill controls movement as well as the speed of 2 motors.


This movement panel operates like the other movement panels and can be controlled by scripting or other skills that interact with it. Movement Panels are skills that move your robot forward, reverse, left, and right. The Movement Panel directions can be modified by other skills, such as camera, voice, script, joystick, and radar.

*Note: The I/O ports on an EZ-B cannot directly provide enough current to power a motor. Instead, use an EZ-B to control an H-Bridge that sends power to a motor. Think of the H-Bridge as a worker and the EZ-B as the boss. Also, note that if you don't require PWM speed adjustment, you can use the simpler version of this skill here.

Main Window



1. Movement Panel
These buttons will allow you to control the directional movement of the entire robot (left, right, forward, reverse, and stop).

2. PWM Sliders
These sliders control the amount of PWM signal (0-100%) delivered to the H-Bridge enable pins. *Note: These sliders need to be moved upward to activate the PWM signal. The sliders are at 0% (OFF) by default. If you think your H-Bridge isn't working, check here first.

Settings



1. Title Field
This field contains the title of the Dual H-Bridge w/PWM skill. You can change it if you'd like. *Note: Changing the title here will also change the title in the controlCommand() associated with this skill.

2. Left Motor Control Buttons
These buttons allow you to change the signal and PWM ports for the Left motor.

3. Right Motor Control Buttons
These buttons allow you to change the signal and PWM ports for the Right motor.

Wiring Diagram


hbridge.jpg


1) Connect Dual H-Bridge VCC to either your battery supply positive or EZ-B power (red) on pin D0
2) Connect Dual H-Bridge GND to either your battery supply positive or EZ-B power (black) on pin D0
3) Connect Dual H-Bridge IN1 to EZ-B Signal Pin D0 (white)
4) Connect Dual H-Bridge IN2 to EZ-B Signal Pin D1 (white)
5) Connect Dual H-Bridge IN3 to EZ-B Signal Pin D2 (white)
6) Connect Dual H-Bridge IN4 to EZ-B Signal Pin D3 (white)
7) Connect Dual H-Bridge ENA to EZ-B Signal Pin D4 (white)
8) Connect Dual H-Bridge ENB to EZ-B Signal Pin D5 (white)
9) Connect Dual H-Bridge OUTA to Left Motor Red Wire
10) Connect Dual H-Bridge OUTB to Left Motor Black Wire
11) Connect Dual H-Bridge OUTC to Right Motor Red Wire
12) Connect Dual H-Bridge OUTD to Right Motor Black Wire

*Note: The wiring diagram above depicts powering the Dual H-Bridge off of +V (direct from the input voltage); in this case, the switch onboard the Dual H-Bridge will have to be pushed down. Although, please note that some H-Bridge versions reverse the direction of the switch, and it will activate in the up position. You will know if the H-Bridge is on when the power LED on the Dual H-Bridge board lights up.

How to Use Dual H-Bridge w/PWM


1) Physically connect the EZ-B to the Dual H-Bridge using the wiring diagram above as a reference. Also, connect motors to the Dual H-bridge.

2) Add the Dual H-Bridge w/PWM Skill to your ARC project (Project -> Add Skill -> Movement Panels -> Dual H-Bridge w/PWM).

3) In the Settings menu, select the ports you connected to the H-Bridge's INPUT Pins (D0, D1, D2, D3, D4 & D5, for example).

4) Move the PWM Sliders to the desired speed in the main window.

5) In the main window, press the direction buttons to move your robot.

Code Sample


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

  • Locate the Connection skill and press the triple-dot button.
  • In the Connection skill's scripts tab, locate the 0 - Connection Established Command. This script will execute when the EZ-B Index #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 Dual H-Bridge motor controller
# The speed is a number between 0 and 255
# Setting this speed will initialize the PWM on the motor controller
SetSpeed(255)


Videos






Requirements


Resources


If your robot moves in the reverse direction, or spins instead of going straight, reverse the wire connections from the motor to the Dual H-Bridge. You could swap the signal sequence around in the skill's Settings menu if it's too difficult to reach these connections. Change [D0, D1, D2, D3] to [D1, D0, D2, D3] or [D0, D1, D3, D2] or [D1, D0, D3, D2]. You may need to try a few combinations to get it right. Sometimes it confuses us too!

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

Speed Control
The PWM in the title of this skill means the HBridge will accept a PWM (pulse width modulation) signal from the EZ-B. That is how the EZ-B will control the speed of the Dual H-Bridge, as you may recall from the How Servo Works tutorial, you know what PWM is. This skill will allow speed adjustments, allowing your project to use joysticks and other skills that manage speed. Read more about how Movement Panels work here .

Related Tutorials

Related Hack Events

Related Questions


ARC Pro

Upgrade to ARC Pro

Stay at the forefront of robot programming innovation with ARC Pro, ensuring your robot is always equipped with the latest advancements.