The H-Bridge driver is used in conjunction with an H-bridge IC (integrated circuit) to enable and/or change the polarity of the voltage applied to a load and providing a much greater current flow by featuring a transistor H-Bridge circuit. They are often used to control a variety of DC motors, steppers, and relay actuators. Two motors can be run off of a single H-Bridge, but in this overview we will only run one, using half of the chip.
The H-Bridge driver for H-Bridge ICs has three parameters that need to be configured:
In this driver we use the Enable pin to control the speed of the motor in either direction. Any GP pin on the Builder Base can be used to control the enable pin as long as it is not already in use.
DC 1 Pin
In this driver we use DC pin 1 to control one direction of the motor. Any GP Pin which is not already in use on the builder base can be used for this pin.
DC 2 Pin
In this driver we use DC Pin 2 to control the direction of the motor opposite to that of DC Pin 1. Any GP Pin which is not already in use on the builder base can be used for this pin.
Two widely used H-Bridge ICs are the L293D from multiple suppliers and the SN754410 from Texas Instruments. Their pinout can be seen below:
Some important facts about the chip:
all 0V (GND) pins should be connected, since they also dissipate the heat from the chip
pin 16 (+V) should be at 5V to provide proper functionality while pin 8 (+Vmotor) can be anything between 3.5V and around 30V (depending on the chip).
An example datasheet for an H-Bridge (L293D) can be found here: datasheet
On the H-Bridge the GP0 pin is connected to Enable Pin, the GP1 Pin is connected to the DC 1 Pin, and the GP2 Pin is connected to the DC 2 pin, the 5V and GND pins on the Builder Base are then connected to the VCC and GND pins on the H-Bridge. We see that there is a switch, that can either switch our motor voltage to the 5V output of the Builder Base or to anything we want to supply with the barrel jack (3.5V - 12V).
GP0 (can be any GP pin)
Connected to Enable Pin
GP1 (can be any GP pin)
Connected to DC 1 Pin
GP2 (can be any GP pin)
Connected to DC 2 Pin
This pin provides the power
This pin provides the GND
How to write an App
Navigate to the App Builder and create a new application. You can find the “Motor” code object under the “Hardware” Tab in the object drop down menu on the left, or you can also use the search bar.
Drag the “Motor” object onto the grid.
Next, under the interface tab, locate the switch, slider percent, and slider analog interface objects. Next, drag two of the switch objects, a slider percent object, and slider analog object onto the grid.
Finally, connect a switch object to each the clockwise and counter clockwise ports on the motor object, connect the slider percent object to the speed port, and the Slider Analog to the Joystick Axle. For the sake of organization, label each of the interface objects, and save your application.
How to create a firmware
Navigate to the Firmware Builder and create a new firmware file.
Click the “+ Add Hardware” button and listed under the “Actuators” tab find the “Motor” hardware option.
Give your device a name, and click “Add Device”
Next, select the “MPU3050” under the driver dropdown menu.
For this example we select:
Enable Pin: GP0
DC 1 Pin: GP1
DC 2 Pin: GP2
You may now save your firmware file and upload it to one of your clients.