Final Project¶
For my final project I decided to make mobile robot. This mobile robot can be used for educational purposes or just for fun.
Description of my final project¶
As I have written before, I teach at the Technical School. I wanted to make a mobile robot with the goal of attracting students to robotics, programming and electronics. It might be an educational robot that students can use.
In the picture above is the idea for the final project. It’s a mobile robot that I might call ForkBot. The idea is that it can be programmed to perform various tasks (e.g. cargo transport, line tracking…). It would be compatible with arduino software. It would be equipped with various sensors such as ultrasonic sensor, line sensor. The case would mostly be 3D printed, some parts will be laser cut. Mobile robot will have operated forks or grippers in front. It can be used for moving load. I will make the robot using additive and subtractive fabrication. I’ll also design PCB for mobile robot.
Who’s done what beforehand?¶
Farhan Ali Shah – Fab Mobile Robot
Kota Tomaru – Mobile platform for research activities
3D design¶
For 3D design I used Fusion 360. I started with the robot body. That is the basic part of my robot. In robot body I will putt main battery and electronics, that is my PCB and driver board for motors. You can see the layout and 3D model of robot body in a following picture
There is a prepared holes for motors and for the cover. I extruded the outer walls and make a necessary holes. There are cutouts for wires and for ultrasonix sensor. Then I added the upper cover which can be opened.
I then modeled forks mechanism where stepper motor will be placed and operated. One fork is unmovable while other is movable. In the middle goes threaded rod.
I modeled threaded rod for the lifting operation with this parameters.
I continued to model upper assembly with threaded rod and also solid rods to hold the assembly
Small back wheel was added together with holders and rod.
You can see the whole mobile robot 3D design and assembly here.
3D printing – additive manufacturing¶
I print all the parts with Ender 3 and Prusa Mk3 3D printers. I saved all the parts from Fusion as stl and opened in Cura. In Cura I set pretty much standard parameters for 3D print. I set layer height to 0.2mm, infill density 20%, three outer walls 1.2mm thickness.
2D design¶
Because I need to include a subtractive manufacturing in my final project I decided to go with laser cutter. I designed the wheels of my robot in Adobe Illustrator.
For the curved text on my wheels I use Type on a Path tool to get desired form. For the FabLab logo I imported svg picture and go to Image trace -> make and expand to get vectors. I also needed to create outlines for the text.
Subtractive fabrication¶
After I designed the wheels, next step is to laser cut it. Material that I used is plywood, 3mm thickness. I engrave text and logo, the rest is cut.
For engraving I set 15% power and 80% speed. For cutting I set 95% power and 20% speed.
This is the parts for both wheels.
Parts and electronics design¶
Motors¶
For main drive I used geared DC motor with encoder. Motor have a marking JGY371. It’s 12V DC motor with 100rpm.
You can see motor layout and dimensions
Technical specifications of the motor:
- Power supply: 12V
- Speed without a load: 10-100 rpm
Here are pinouts description:
- RED – motor connection
- BLACK – encoder connection GND
- YELLOW – sensor 1 signal
- GREEN – sensor 2 signal
- BLUE – encoder connection Vcc
- WHITE – motor connection
For lifting operations I will use 5V stepper motors. It comes with 5 wires. Stepper has a marking 28BYJ-48. So, this is unipolar stepper motor with following characteristics and pinouts
Motor driver¶
For driving DC geared motor I used 2-Way DC Motor PWM H-Bridge Driver Module. I used this board because geared DC motors can draw a lot of current. This module has a mark ZS-H1.
Technical specifications of the module:
- Number of output channels: 2
- Working voltage: 5-36v (limit: 40V)
- Double channel maximum current: 16A
- Single channel rate current: 8A
- Rated output reference power of each circuit :(12V power supply) 96W (36V power supply) 288W
- Control signal voltage: 3-5v
- Current per control signal: 2-10ma
- Support PWM frequency range: 2-20k (ideal)
- Support PWM duty ratio range :0-99%
- PWM minimum effective pulse width :10US
- Working temperature: - 10 ℃ – 80 ℃
- Dimensions: 695015mm
- Weight: about 26g
We can control direction and speed of the motors through pins (DIR1, PWM1, EN1 for motor 1 and DIR2, PWM2, EN2 for motor 2). Truth table are dispalyed on the back of PCB.
1-way control signal logic truth table:
- Motor Forward: EN1=1 DIR1=1 PWM1=PWM(0-99%)
- Motor Reversal: EN1=1 DIR1=0 PWM1=PWM(0-99%)
- Brake: EN1=1 DIR1=X PWM1=0
- Parking: EN1=0 DIR1=X PWM1=X
2-way control signal logic truth table:
- Motor Forward: EN2 =1 DIR2=1 PWM2=PWM(0-99%)
- Motor Reversal: EN2 =1 DIR2=0 PWM2=PWM(0-99%)
- Brake: EN2=1 DIR2=X PWM2=0
- Parking: EN2=0 DIR2=X PWM2=XEN2 =0 DIR2=X PWM2=X
Inputs¶
HC-SR04 Ultrasonic distance sensor consists of two ultrasonic transducers. The one acts as a transmitter which converts electrical signal into 40 KHz ultrasonic sound pulses. The receiver listens for the transmitted pulses. If it receives them it produces an output pulse whose width can be used to determine the distance the pulse travelled. The sensor offers excellent non-contact range detection between 2 cm to 400 cm with an accuracy of 3mm. On the following picture you can see pinouts of ultrasonic sensor (HC-SR04).
- Vcc – 5V power supply pin
- Trigger - used to trigger the ultrasonic sound pulses
- Echo - produces a pulse when the reflected signal is received
- Gnd – ground pin
It all starts, when a pulse of at least 10 µS (10 microseconds) in duration is applied to the Trigger pin. In response to that the sensor transmits a sonic burst of eight pulses at 40 KHz. The eight ultrasonic pulses travel through the air away from the transmitter. Meanwhile the Echo pin goes HIGH to start forming the beginning of the echo-back signal. If those pulses are reflected back the Echo pin goes low as soon as the signal is received. This produces a pulse whose width varies between 150 µS to 25 mS, depending upon the time it took for the signal to be received.
Other type of sensors that I use is IR obstacle avoidance sensor(img source: http://qqtrading.com.my).
An infrared sensor emits and/or detects infrared radiation to sense its surroundings. … The basic concept of an Infrared Sensor which is used as Obstacle detector is to transmit an infrared signal, this infrared signal bounces from the surface of an object and the signal is received at the infrared receiver. Interface Description (3-wire):
- VCC: external 3.3V-5V voltage (can be directly connected to 5v MCU and 3.3v MCU)
- GND: GND External
- OUT: digital output (0 and 1)
Schematic and PCB design¶
I statred design my board for mobile robot. I used KiCad for schematic and PCB design. Microcontroller that I use is ATMega328. I know it’s a little old but this is what I have. I placed all the components and drew schematic.
After that I check performed electrical rules check. Everything was ok, no errors. I generated netlist and run pcbnew to create PCB.
I loaded the netlist and started routing the PCB. After some time, trials and errors and finally succeeded to route all the traces.
I drew a cut-out with holes. This shape of cut-out is because this board is going on top of DC motor driver board. I will use plastic stadoffs for this. Next step is to prepare for milling. I use modsproject for that. I selected MDX mill program. First I upload the traces png and started setting the parameters:
- Tool diameter: 0.4mm
- Cut depth: 0.11mm
- Offset: 4
- Cut speed: 1mm/s
For PCB outline and holes I used same speed, but different tool, 0.8mm end mill. I saved traces and outlines RML files. I open DropOut and send files to Roland MDX-15.
Completed PCB.
Next step was to solder the components. First I solder the microcontroller ATMega328 because this is the most difficult to solder. After that I solder all the other components.
This microcontroller already had bootloader so I programmed it through FTDI header. I uploaded a simple blink sketch to see if it work. It works.
Mobile robot assembly and BOM¶
I started assembly by putting the DC geared motors inside the case. I tighten the motor with M3 screws.
In front I assemble the forks and stepepr motor with threaded rod and guides for moving left and right. Holes and grooves are for ultrasonic sensors.
I also added guides for lifting operations. Above will be placed stepper motor.
I laser cut the wheels with with FabLab logo and glued od both sides with plastic part to hold it.
I screw the IR sensors bellow and also back ball.
I use plastic standoffs to put DC motor driver board first, then on top of that, I placed my PCB.
For power supply I use 3S LiPo battery which gives 12V on the output. I used velcro to hold the battery in place. This is good for powering DC motors, but it’s too much for microcontroller. So, I used DC-DC converter. To hold DC-DC converter in place I used double sided tape. On the input of DC-DC converter I connect 3S battery, on the output of DC-DC converter I set 5V and connect with microcontroller board. Input voltage of this power module can be 7-32V and output can be set from 0.8-28V using trimpot. Max current is 12A. In the following picture you can see the parts and system integration. It’s all packed inside mobile robot.
Fully assembled mobile robot
Whole block diagram can be seen in a following picture.
BOM¶
In the following table you can find complete BOM. I’m a remote student so I found and order all the parts that I needed.
Qty | Description | Price | Link |
---|---|---|---|
2 | Stepper motor 5V + driver board | 5.73 $ | https://www.ebay.com/itm/122832406645?hash=item1c9961c875:g:PDEAAOSw6N1f5eZ2 |
2 | Geared DC motor 100rpm | 13.30 $ | https://www.ebay.com/itm/363387504198?hash=item549b954646:g:YTgAAOSws81gqPX7 |
1 | 16A DC Motor PWM H-Bridge Driver Module | 14.55 $ | https://www.ebay.com/itm/253991510804 |
1 | DC-DC converter 12V | 5.37 $ | https://www.ebay.com/itm/273499961778?hash=item3fadde39b2:g:buUAAOSw5cRZMQV- |
1 | 3S LiPo battery | 25.49 $ | https://www.ebay.com/itm/133451129971?hash=item1f124ea473:g:sB8AAOSwNXBe-P6A |
8 | Plastic standoffs | - $ | salvaged from drone |
1 | ATMega328P | - $ | salvaged from old board |
3 | 100 nF | - $ | salvaged from old board |
1 | 10kOhm | - $ | salvaged from old board |
1 | 16 MHz crystal | - $ | salvaged from old board |
2 | 22pF | - $ | salvaged from old board |
1 | Male headers | 3.49 $ | https://www.ebay.com/itm/353180769799?hash=item523b36de07:g:K~YAAOSwrdVfRFpa |
1 | Jumper wire cables female to female | 3.63 $ | https://www.ebay.com/itm/123806249467?hash=item1cd36d71fb:g:H~kAAOSwLrtdCK7f |
14 | M3 x 12 screws | 3 $ | local store |
1 | PLA fillament | 15 $ | local store |
1 | FR1 PCB board | 3 $ | local store |
Total: 92.56 $
Mobile robot programming and testing¶
For programming the robot I used Arduino software. Microcontroller already have a bootloader so I used FTDI interface and USB to UART bridge to program it. First I program mobile robot to follow the line. I needed to figure out the movement of the robot. In the following code you can see mobile robot movement functions.
Forward function for example, I set ENABLE pins to HIGH, this turn on the motor. Speed is set on the PWM pins. I used 80% duty cycle for this. Rotation can be set on DIRECTION pins. I set one to HIGH, other to LOW, because motors are across each other.
In stop function I set PWM pins to 0. Regardless what value other pins have, the motor wil be stoped. This is all from truth table of DC motor driver board. You can see it few sections above.
For line following I read the state of the IR sensors and based on that states robot turns left or right. IR sensor interpret black line as logic “1” and white areas as logic “0”.
For moving object I use stepper motors. I defined all the connections and set steppers speed to 15. Mobile robot perform distance calculation and has a control variable called flag. if distance is less than or equal 6cm flag is set to “1”. if distance is more than 6cm flag is set to “0”. These are two routines. First mobile robot needs to detect object, then one stepper grab the object and stepper picks it up. After that robot go backward and turns left, go to the position and drop the object.
This is some of possibilities this mobile robot can do. Full codes and videos of mobile robot operations can be seen bellow.
/*
* Fab mobile robot line following
* Microcontroller: ATMega328P
* Author: Ivan Matasović
*
*/
#include <AFMotor.h>
#include <Wire.h>
#define DIR_1 5 //right motor direction1
#define PWM_1 6 //right motor pwm1
#define EN_1 7 //right motor enable1
#define DIR_2 8 //left motor direction2
#define PWM_2 9 //left motor pwm2
#define EN_2 10 //left motor enable2
#define rightIR 11 //left and right IR sensor
#define leftIR 12
long stanje_rightIR, stanje_leftIR;
void setup() {
pinMode(DIR_1, OUTPUT);
pinMode(DIR_2, OUTPUT);
pinMode(EN_1, OUTPUT);
pinMode(EN_2, OUTPUT);
pinMode(PWM_1, OUTPUT);
pinMode(PWM_2, OUTPUT);
pinMode(rightIR, INPUT_PULLUP);
pinMode(leftIR, INPUT_PULLUP);
}
void loop(){
//read the status of IR sensors
stanje_rightIR = digitalRead(rightIR);
stanje_leftIR = digitalRead(leftIR);
if(stanje_rightIR == 1 && stanje_leftIR == 1) {
stopp();
}
else if(stanje_rightIR == 0 && stanje_leftIR == 1) {
left();
}
else if(stanje_rightIR == 1 && stanje_leftIR == 0) {
right();
}
else if(stanje_rightIR == 0 && stanje_leftIR == 0) {
forward();
}
}
//mobile robot movements
void forward(){
digitalWrite(EN_1, HIGH);
analogWrite(PWM_1, 80);
digitalWrite(DIR_1, HIGH);
digitalWrite(EN_2, HIGH);
analogWrite(PWM_2, 80);
digitalWrite(DIR_2, LOW);
}
void right(){
digitalWrite(EN_1, HIGH);
analogWrite(PWM_1, 80);
digitalWrite(DIR_1, HIGH);
digitalWrite(EN_2, HIGH);
analogWrite(PWM_2, 80);
digitalWrite(DIR_2, HIGH);
}
void left(){
digitalWrite(EN_1, HIGH);
analogWrite(PWM_1, 80);
digitalWrite(DIR_1, LOW);
digitalWrite(EN_2, HIGH);
analogWrite(PWM_2, 80);
digitalWrite(DIR_2, LOW);
}
void stopp(){
digitalWrite(EN_1, HIGH);
analogWrite(PWM_1, 0);
digitalWrite(DIR_1, LOW);
digitalWrite(EN_2, HIGH);
analogWrite(PWM_2, 0);
digitalWrite(DIR_2, HIGH);
}
/*
* Fab mobile robot moving object code
* Microcontroller: ATMega328P
* Author: Ivan Matasović
*
*/
#include <AFMotor.h>
#include <Wire.h>
#include <Stepper.h>
Stepper backStepper(2048, A2, A4, A3, A5);
Stepper upStepper(2048, 1, 3, 2, 4);
#define DIR_1 5 //right motor connections
#define PWM_1 6 //right motor connections
#define EN_1 7 //right motor connections
#define DIR_2 8 //left motor connections
#define PWM_2 9 //left motor connections
#define EN_2 10 //left motor connections
#define rightIR 11 //IR sensors
#define leftIR 12
#define echo A1 //ultrasonic sensor connection echo pin
#define trig A0 //ultrasonic sensor connection trig pin
long time1, distance, stanje_rightIR, stanje_leftIR;
void setup() {
pinMode(DIR_1, OUTPUT);
pinMode(DIR_2, OUTPUT);
pinMode(EN_1, OUTPUT);
pinMode(EN_2, OUTPUT);
pinMode(PWM_1, OUTPUT);
pinMode(PWM_2, OUTPUT);
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
pinMode(rightIR, INPUT_PULLUP);
pinMode(leftIR, INPUT_PULLUP);
backStepper.setSpeed(15);
upStepper.setSpeed(15);
}
void loop(){
int flag = 0; //variable to keep track of the status
digitalWrite(trig, HIGH);
delay(30);
digitalWrite(trig, LOW);
time1 = pulseIn(echo, HIGH);
distance = time1 * 0.034 / 2; //calculating distance
if(distance <= 6) { //if distance is less than 6cm set flag to 1
flag = 1;
}
if(distance > 6) { //if distance is more than 6cm set flag to 0
flag = 0;
}
if (flag==0) {
forward();
if(distance <= 6){
flag=1;
}
}
if (flag == 1) {
stopp();
backStepper.step(1900);
delay(1000);
upStepper.step(-3900);
delay(1000);
flag=2;
}
if (flag == 2) {
back();
delay(1300);
left();
delay(1200);
forward();
delay(2000);
stopp();
backStepper.step(-3700);
delay(1000);
back();
delay(1500);
}
}
//mobile robot movement functions
void forward(){
digitalWrite(EN_1, HIGH);
analogWrite(PWM_1, 80);
digitalWrite(DIR_1, HIGH);
digitalWrite(EN_2, HIGH);
analogWrite(PWM_2, 80);
digitalWrite(DIR_2, LOW);
}
void left(){
digitalWrite(EN_1, HIGH);
analogWrite(PWM_1, 80);
digitalWrite(DIR_1, HIGH);
digitalWrite(EN_2, HIGH);
analogWrite(PWM_2, 80);
digitalWrite(DIR_2, HIGH);
}
void right(){
digitalWrite(EN_1, HIGH);
analogWrite(PWM_1, 80);
digitalWrite(DIR_1, LOW);
digitalWrite(EN_2, HIGH);
analogWrite(PWM_2, 80);
digitalWrite(DIR_2, LOW);
}
void stopp(){
digitalWrite(EN_1, HIGH);
analogWrite(PWM_1, 0);
digitalWrite(DIR_1, LOW);
digitalWrite(EN_2, HIGH);
analogWrite(PWM_2, 0);
digitalWrite(DIR_2, HIGH);
}
void back() {
digitalWrite(EN_1, HIGH);
analogWrite(PWM_1, 60);
digitalWrite(DIR_1, LOW);
digitalWrite(EN_2, HIGH);
analogWrite(PWM_2, 60);
digitalWrite(DIR_2, HIGH);
}
Line following video
Moving barrel video
What questions were answered?¶
I had a doubt how to power it. I found a solution by connecting 3S LiPo battery and DC-DC converter. It was a problem because DC motor uses 12V, but microcontroller and steppers uses 5V. I also needed to figure out how to program this mobie robot. In the end I succeeded.
What worked? What didn’t?¶
As you can in a video, mobile robot is working. It can be programmed in a multiple ways to perform various tasks. All sensors and motors are good. During the assemby one stepper motor driver was not working properly so I replaced it. I also spend some time to program the mobile robot.
How was it evaluated?¶
I think my mobile robot should be successful because I included 2D, 3D design, additive and subtractive fabrication processes, electronics design and production, embedded microcontroller interfacing and programming, system integration and packaging. I used 2D design for wheels and laser-cutting. I use 3D design for mobile robot. I 3D printed out the parts for robot. Design and production of the PCB will cover the electronics. Inputs will be ultrasonic sensor and IR sensor. Outputs will be two stepper motors and two DC motors.
What are the implications?¶
In the future I planned to develop even more this mobile robot (add even more sensors, maybe redesign the case…). Also if it possible I will use this mobile robot in a class to tech children electronics and programming.
Final project presentation
Design files for download:
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License