2 Motors + Servo

Overview

The 2 Motors and Servo prototype project utilizes two H-bridge controlled DC motors and a servo to create a rear wheel drive RC car. We initially built our RC car prototype on a breadboard, and then developed the idea into a moving and steering capable wireless vehicle.

This project mirrors our Steering Car DIY Kit, so it uses the same application file, but the firmware file varies.

intermediate

1 hour

1 Client


Hardware Components

Picture

Name

Quantity

Link

Picture

Name

Quantity

Link

 

9G servo

1

Included in Component Kit

Or you can purchase it here

 

1 - 6V DC Motor

2

One is included in the Component Kit

You can purchase the second here

 

L293D

1

One is included in the Component Kit

But you can purchase the second here

 

Jumper Cables (MM)

~20

Included in Component Kit

Or you can purchase it here

Q-Client Builder Base

1

Q-Client

Tools Used

Picture

Name

Quantity

Link

Picture

Name

Quantity

Link

Small slotted-head screwdriver

1

Included in Component Kit

or you can pick from one on our Recommended Tools List


Assemble the Circuit

Gather all of the components listed in the parts list above.

Start by placing the L293D H-Bridge on the Bread Board and connect the GND and 5V ports from the Builder Base to the GND and VCC rails on the Bread Board.

Now, we will connect the four GND pins on the H-bridge to the GND rail on the Breadboard, and the Vcc1 and Vcc2 pins on the H-Bridge to the power rail on the Breadboard.

 

Now, make the connections between the H-Bridge and the Builder Base as detailed in the diagram and table below:

H-Bridge

Builder Base

H-Bridge

Builder Base

1,2EN

GP5

1A

GP1

2A

GP0

Vcc2

5V

Vcc1

5V

4A

GP3

3A

GP4

3,4EN

GP6

We will now connect the Motors to the H-bridge as follows:

Motor

Lead

H-Bridge

 

Motor

Lead

H-Bridge

 

M1

-

1Y

 

M1

+

2Y

 

M2

-

3Y

 

M2

+

4Y

 

Lastly, we will connect the servo to the Builder Base.

On most 9G servos the GND lead is brown, the Vcc lead is orange, and the yellow lead is data, but be sure to check the data sheet of your specific servo before you proceed.

Start by taking the GND and Vcc leads from the servo and connect them to the GND and Vcc rails on the bread board. Lastly, connect the data pin to the GP2 port on the builder base. Here is a table that lists the connections:

Servo

Builder Base

Servo

Builder Base

GND (Brown)

GND

Vcc (Orange)

5V

Data (Yellow)

GP2

Congrats, the hardware assembly for this project is complete!


Pair the Builder Base

Now we want to pair the Builder Base with our Q-Server. In order to do so, go to the Homescreen of your Q-Server.

Next click on the lift side symbol labeled “Clients”. Switch to the “Unpaired” tab at the top middle of the screen.

You should see your unpaired Builder Base. If not, check if you have plugged in the power supply for the Builder Base. Now move to the three dots below “Actions” and click “Pair”.

Once your Client is paired, click the “Setup” button.

Now you can edit your Client. Give him a Name you want and also a location where you are going to use it. Hit “Save” when you finished.


Build the Firmware

Remember: All Apps and Firmware Files are available in the resources section at the bottom of the page!

Navigate to the Firmware Builder and create a new Firmware file. We named ours Steering Car.

Next, click the “+ Add Hardware” button and find the Motor device via the search bar, select it, name it, and then click “Add Hardware”. We named ours Motor BL.

Repeat these steps again, but this time name the motor: Motor BR.

Next, add a servo. We named ours Servo.

You should now have two motors and a servo in your devices list.

To configure the drivers for the Motor BL device, select the L293D H-Bridge driver from the driver dropdown menu.

Now, configure the driver as follows:

Enable Pin

DC 1 Pin

DC 2 Pin

Enable Pin

DC 1 Pin

DC 2 Pin

GP6

GP3

GP4

We will now configure the Motor BR driver:

Enable Pin

DC 1 Pin

DC 2 Pin

Enable Pin

DC 1 Pin

DC 2 Pin

GP5

GP0

GP1

Lastly, we will configure the Servo driver.

Select the Generic driver from the driver dropdown menu

Pin

GP2

Pin

GP2

That’s it for the firmware! Save your file by clicking the blue “Save” Button at the bottom of the screen.

Now you can upload your firmware to the client that you have attached to the Steering Car.


Build the App

Remember: All Apps and Firmware Files are available in the resources section at the bottom of the page!

Navigate to the Applications page and click the “+ Create New Button”, name your application, and click create.

You will now be directed to the App Builder Canvas. The app we build will look like this:

Using the search bar in the left hand tool-bar search for the Motor code object and drag two of them onto the canvas.

Name the Motor Objects as we do. This will help you to identify the motors during the application mapping. To rename them click on the motor object and change the name in the properties panel on the right.

In order to save the names you must click the “Save Properties” button at the bottom of the properties tab.

Next, search for and drag a Manual Ranging object onto the canvas.

Configure the Manual Ranging object as follows:

Value

In Min

In Max

Out Min

Out Max

Rounded

Value

In Min

In Max

Out Min

Out Max

Rounded

Trigger: on

0

4095

0

4095

false

To configure each port on the object click on the port and change the properties in the properties panel on the right side of the screen, and hit save properties at the bottom of the screen. If you don’t your changes will not be saved!

Next, connect the Value out port from the Manual Ranging object to the Motor objects as follows:

Now search for the “Joystick” object and drag two of them onto the canvas. Name one Left, and the other Right.

 

Now connect the Y-Axis port from the Joystick Left object to the Manual Ranging object as follows:

Your steering car will now move forwards and backwards with the left joystick. Next, we will work on the steering.

Search for and drag onto the canvas another Manual Ranging object and a Servo object.

We suggest that you name both of these objects.

Configure the ports on the Manual Ranging object as follows:

Value

In Min

In Max

Out Min

Out Max

Rounded

Value

In Min

In Max

Out Min

Out Max

Rounded

Trigger: on

0

4095

180

0

false

We set the out min as 180 and the out Max at 0 so that when the right joystick is at rest in the centered position 90 will be output by output by the joystick instead of 0.

With the Manual Ranging object configured we will connect the code objects as follows:

It is possible that you will have to adjust your 0 and 180 offsets to get the proper range of motion on your servo. If this is the case, you can follow our tutorial on offset adjustment here.

Your Steering Car is now totally usable with a set of joysticks. However, we will add some code objects that will allow the car to be controlled via the dashboard interface.

First we will start with steering. Drag three button interface objects and three static number objects onto the canvas. Arrange and name them as shown:

Now, label each of the Button objects to make them easily identifiable on the dashboard. Be sure to save the properties for each button. If you don’t, your changes will be lost!

Now make the connections highlighted in blue:

We will now move on to make the car drive forwards using the interface buttons.

Drag a Digital Toggle code object and an interface button onto the canvas. Be sure to name and label the button

Now make the following connections that are highlighted in blue:

Congrats, your app is now complete!

Hit “Save App” and go back to your applications page.


Map the Hardware

You should now be back on the Apps page.

Find your “Steered Chassis” app and hit the play button.

A list containing all of the devices in your application will expand.

Next click on the “Motor BL” device and the client dropdown menu will appear on the right.

Select the Motor BL driver from the dropdown menu and hit “Done”.

Repeat the same steps for the Motor BR and Servo devices, ensuring that you match the device name to the object name.

You can map the Joystick Devices in the same way, but make sure that you match the Left and Right Joystick drivers with the Left and Right Joystick devices.

If you have yet to build a Joystick project or DIY kit you can find out how to build one here.

Notice how the status symbols have changed to green checkmarks.

When mapping firmware devices to objects in your Apps it is important to note that only devices and objects of the same type can be mapped together. Using this app for example, we are only given the option to map the client with the button firmware to the button object.


Run the App!

Next, hit “Save + Run”.

Congratulations! Your prototype RC car is now complete, have fun!


Resources

Application

 

Firmware

 

Schematic

 

Diagrams