![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Control a robot with two motors and two servos to pick up ping pong balls via bluetooth
Dependencies: mbed Servo 4DGL-uLCD-SE Motor
Ping Pong Scorer
This project's purpose is to create the machinery and controls necessary to make a robot pick up and deposit ping pong balls as part of the Ping Pong Collection Game.
Project Members
This project was a product of the following members:
- Christina Lee
- Boyan Mirov
- Sai A. Narray
- Alex Rao
For ECE 4180 at Georgia Tech
Linked Project
This project was created in tandem with the Object Counter. While it is certainly viable on its own, it's primary purpose is only served when using both programs on separate MBEDs.
Demonstration
Here is a video of the robot interacting with the Object Counter
Installation
To create this, you'll need the following parts:
- LPC1768 MBED
- 2x Motor
- Servo
- Sub-Micro Servo
- Robot Construction Set
- 2x Power Adapters
- Dual H Bridge Inverter
- Bluetooth LE UART friend
Power Coupling
Because of the way servos and motors interact with the power received, connecting them both to the same circuit can cause undefined (and often unexpected) behavior. As such, it is recommended to ensure that they are always on separate systems. In other words, we recommend connecting the servos to a secondary power supply, different from the supply for the motors.
This guide follows this recommendation
Motors
MBED | H Bridge | Left Motor | Right Motor |
---|---|---|---|
Gnd | Gnd | Gnd | Gnd |
+5V | VMOT | ||
+3.3V | VCC | ||
+3.3V | STBY | ||
p21 | PWMA | ||
p15 | AIN1 | ||
p19 | AIN2 | ||
p22 | PWMB | ||
p18 | BIN1 | ||
p16 | BIN2 | ||
A01 | + | ||
A02 | - | ||
B01 | + | ||
B02 | - |
Servos
MBED | Servo (Arm) | Servo (Handle) |
---|---|---|
Gnd | Gnd (black) | Gnd (black) |
+5V | + (red) | + (red) |
p23 | CTRL (yellow) | |
p24 | CTRL (yellow) |
Bluetooth
MBED | Bluetooth UART LE |
---|---|
Gnd | Gnd |
+5V | +5V |
Gnd | CTS |
p27 | TXO |
p28 | RXI |
Revision 0:57bba5ff2155, committed 2019-04-15
- Comitter:
- boyanmirov
- Date:
- Mon Apr 15 03:25:34 2019 +0000
- Commit message:
- Completed Robot Controls code
Changed in this revision
diff -r 000000000000 -r 57bba5ff2155 4DGL-uLCD-SE.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/4DGL-uLCD-SE.lib Mon Apr 15 03:25:34 2019 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/4180_1/code/4DGL-uLCD-SE/#e39a44de229a
diff -r 000000000000 -r 57bba5ff2155 Motor.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Motor.lib Mon Apr 15 03:25:34 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/simon/code/Motor/#f265e441bcd9
diff -r 000000000000 -r 57bba5ff2155 Servo.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.lib Mon Apr 15 03:25:34 2019 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r 57bba5ff2155 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Apr 15 03:25:34 2019 +0000 @@ -0,0 +1,111 @@ +// Sweep the motor speed from full-speed reverse (-1.0) to full speed forwards (1.0) + +#include "mbed.h" +#include "Motor.h" +#include "uLCD_4DGL.h" +#include "Servo.h" + +Serial blue(p28,p27); +BusOut myled(LED1,LED2,LED3,LED4); + +Motor left(p21, p15, p19); // pwm, fwd, rev +Motor right(p22, p18, p16); +Servo arm(p23); +Servo handle(p24); + +union f_or_char { + float f; + char c[4]; +}; + +int main() +{ + char bchecksum=0; + char temp=0; + union f_or_char x,y,z; + char bnum=0; + char bhit=0; + arm = 0.9; + handle = 0.9; + + while(1) { + if (blue.readable()) { + if (blue.getc()=='!') { + if (blue.getc()=='B') { //button data packet + bnum = blue.getc(); //button number + bhit = blue.getc(); //1=hit, 0=release + if (blue.getc()==char(~('!' + 'B' + bnum + bhit))) { //checksum OK? + switch (bnum) { + case '1': //number button 1: + if (bhit=='1') + arm = arm + 0.05; + break; + case '2': //number button 2 + if (bhit=='1') + handle = handle + 0.1; + break; + case '3': //number button 3 + if (bhit=='1') + { + if (arm.read() <= 0.5) + arm = arm; + else + arm = arm - 0.05; + } + break; + case '4': //number button 4 + if (bhit=='1') + { + if (handle.read() <= 0.5 & arm.read() <= 0.5) + handle = handle; + else + handle = handle - 0.1; + //printf("position = %.1f\n", handle.read()); + } + break; + case '5': //button 5 up arrow + if (bhit=='1') { + left.speed(-1.0); + right.speed(-1.0); + } else { + left.speed(0); + right.speed(0); + } + break; + case '6': //button 6 down arrow + if (bhit=='1') { + left.speed(1.0); + right.speed(1.0); + } + else { + left.speed(0); + right.speed(0); + } + break; + case '7': //button 7 left arrow + if (bhit=='1') { + left.speed(-1.0); + right.speed(1.0); + } + else { + left.speed(0); + right.speed(0); + } + break; + case '8': //button 8 right arrow + if (bhit=='1') { + left.speed(1.0); + right.speed(-1.0); + } + else { + left.speed(0); + right.speed(0); + } + break; + } + } + } + } + } // end readable + } +} \ No newline at end of file
diff -r 000000000000 -r 57bba5ff2155 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Apr 15 03:25:34 2019 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b \ No newline at end of file