App Control a Rubber Band Gun on a Mecanum Car

by thomas9363 in Circuits > Arduino

363 Views, 1 Favorites, 0 Comments

App Control a Rubber Band Gun on a Mecanum Car

title.gif
empty.png

The goal of this project is to design a system for remotely operating a rubber band gun mounted on a car equipped with mecanum wheels. This functionality is enabled through an Android application, which establishes a Bluetooth connection. As the car moves, the user can launch a rubber band by tapping a "fire" button on his smartphone.

Supplies

  • Arduino Mega
  • CNC shield
  • A4988 Stepper Driver x4
  • Nema 17 Stepper motor x4
  • Mecanum wheels (2 pairs)
  • Buck converter 5A
  • PCA9685 servo driver
  • Bluetooth module
  • Jumper wires
  • Small breadboard
  • 3S lithium polymer battery
  • Small servo x3
  • Materials for building rubber band gun
  • 1/8” plexglass for building chassis
  • 5mW laser module

Stepper Motor

component.png

The car is designed using mecanum wheels, enabling movement in any direction while retaining its original orientation. This mobility is achieved through the control of stepper motors, specifically the MINEBEA 17PM-J503-P2ST STEPPER motors. These motors are classified as NEMA 17, featuring a stepping angle of 1.8 degrees, which allows for 200 steps per revolution in full-stepping mode.

 

Unlike traditional DC motors, it is crucial to control the maximum current flowing through the coils of stepper motors to avoid exceeding their specified current rating. To achieve this, I have utilized the A4988 driver, which is responsible for current regulation. This driver features a small trimmer potentiometer that allows for the adjustment of the current limit. In my configuration, I've set the limit to 350mA. A wealth of information is available on the internet, providing step-by-step instructions on how to configure the current limit.

CNC Shield

CNCLayout.png

The stepper motors and drivers are connected via a CNC shield, which is directly mounted onto the Mega board. This CNC shield also comes equipped with 4th axis capability. To activate this feature, two jumpers, indicated by the red markers in the diagram, are utilized. Adjacent to the illustration, you can find the Mega board's stepping and direction signal pins, which are crucial for control. The "Enable" pin on the CNC shield is responsible for regulating the power supply to the stepper motor drivers. In my setup, where 16 steps are used, each driver employs three jumpers, as depicted in the green sections of the diagram. This configuration ensures improved stepper motor movement, thereby enhancing overall performance.

Car Movement

MecanumMove.png

Mecanum wheels offer significant advantages in terms of maneuverability, as they eliminate the need for complex steering mechanisms and provide smooth, continuous motion in any direction.

 

Each wheel consists of several rollers, in my case, eight of them, mounted at a 45-degree angle around the perimeter of the wheel. These rollers can rotate freely around their own axes. This unique arrangement allows mecanum wheels to achieve omnidirectional movement through a combination of individual roller rotation.

 

Controlling the movement of a vehicle equipped with mecanum wheels is achieved by independently adjusting the speed and direction of rotation of each wheel. This control allows the vehicle to move in various directions, including forward, backward, sideways, diagonally, and rotation, as shown in the picture above.

Rubber Band Gun

RubberBanGun1.png

As illustrated above, I constructed my rubber band gun using handle tubes salvaged from a broken piece of luggage. The mechanical movement is achieved using three small servos. Two of these servos are employed for controlling pan and tilt actions, while the third servo is responsible for rotating an actogram, an eight-angled star polygon. Since this servo has a maximum rotation angle of 180 degrees, it can fire up to four rubber bands. To control these servos, I'm using the PCA 9865 servo driver.

 

I have included a small program called “ServoAngle.ino” that allows you to adjust servo angles using the Serial monitor. To utilize this program, you'll need to install the Adafruit PWM Servo Driver library, which offers a convenient way to control multiple servo motors through the I2C communication protocol. It's important to note that this library utilizes pulse length rather than angles for servo control. Therefore, you may need to fine-tune and experiment with the pulse length to ensure each rubber band can be loaded and fired accurately. Additionally, the pan-tilt function has been tested and confirmed to be correct.

Building the Vehicle

setup_mecanum_stepper.png

The chassis of my vehicle is constructed using 1/8” plexiglass. I've positioned the stepper motors and battery below the deck, while all the electronic components are placed above the deck. For power, I've opted for a 3S 1,500 mAh lipo battery, which, when fully charged, has a voltage of 12.6 volts. It's worth noting that the recommended voltage range for powering the Arduino Mega through its barrel jack falls between 7 and 12 volts. Using a voltage outside of this range could potentially damage the board.

 

To address this voltage disparity, I've employed a buck converter to reduce the voltage to 5V for the servo application. I've also chosen to split the output: one to power the PCA9685 servo driver and the other to power the Arduino Mega through its USB connection. You can refer to the wiring diagram provided above for a visual representation of this setup.

Software

MecanumApp.png

Android App

I am using MIT App Inventor to develop my app. The app, as depicted, utilizes Bluetooth for communication with the vehicle. The blue buttons are designated for driving the car, while the orange buttons are employed to control the rubber band gun. Specifically, the "fire" button serves the dual purpose of loading and firing the rubber bands. If you're interested, you can download the *.aia (Mecanum_Gun_Button.aia) file from my GitHub repository for further exploration.

 

Arduino Code

The Arduino code (Mecanum_Gun.ino) is relatively straightforward. The phone app sends a character via Bluetooth, and when there is at least one byte of data available to read, the Arduino Mega reads the character from the incoming serial data through the communication port. Depending on the character received, a switch statement is employed to create a control structure that enables the vehicle to execute various actions. Two libraries are utilized in this code: AccelStepper for controlling the stepper motors and Adafruit_PWMServoDriver for managing the servo motors.

Demonstration

App controlled rubber band gun on top of a mecanum car

The video demonstrates the rubber band gun turret in action. In the initial segment, the functioning of the mecanum wheels is illustrated, followed by a demonstration of how the rubber bands are loaded and fired. The last part showcases the car in motion, engaging in target shooting, which includes targets like Mike Wazowski, Kevin The Minions, and Cyborg Kuro-chan.

Bonus

Stepper Music - the Last Waltz

Stepper motors can indeed generate sounds due to the mechanical vibrations and movements they undergo during operation. By controlling the speed, direction, and step sequences of these motors, it is possible to make them produce a range of pitches and rhythms, similar to the operation of traditional musical instruments.

 

As a bonus feature, I have incorporated a musical composition titled "The Last Waltz" into my car. You can download it from my GitHub repository and then upload it to your mecanum car. Once you've done so, you'll be able to witness the car "dance" to the tune, synchronizing its movements with the musical composition.