2223 RBC Basic Booklet V5
2223 RBC Basic Booklet V5
Name:
Page | 1
TIME EVENT
TABLE OF CONTENTS
CHAPTER 2 Locomotion 4
CHAPTER 3 Extension 11
CHAPTER 4 Actuator 14
CHAPTER 6 Fastener 25
CHAPTER 7 Materials 26
CHAPTER 8 Software 30
CHAPTER 9 Sensor 31
CHAPTER 13 C Programming 52
A robot is an automatically guided machine which can do tasks on its own, almost always due to
electronically-programmed instructions.
CHAPTER 2 LOCOMOTION
Locomotion
Enables the robot to move from one position to another
● Movement depends on two separately driven wheels which are placed on either side of the robot.
● Direction can be changed by varying the rpm of the wheels.
Advantages:
● Can change direction while moving without rotate
● Fast movement
● Higher Speed Maneuvers
Disadvantages:
● Four points problem (slipping of wheels)
● Different motor output performance
● Easily affected by different angles of motor position
Caster
An undriven single, double or compound wheel that is designed to be mounted to the bottom of a
larger object (the “vehicle”) so that it enables the object to be easily moved.
Example of 3-point
omni-directional robot movement
The usage of the Omni wheel enables the robot to move in ALL directions.
Advantage:
● Maneuverability
Disadvantages:
● (Usually)less pushing force
● Complex in terms of mechanism and programming
● Movement depends on the four mecanum wheels placed with an X-shaped from the top view of
the robot.
● Move by resolving the vectors of each wheel and the direction depends on the movement of
each wheel.
Advantages:
● Maneuverability
Disadvantages:
● Complex in terms of programming
Advantages:
● Increased stability
● Increased Traction
● Increased Torque
Disadvantages:
● Lack of speed under certain situations
● Reduce turning ability under certain situations
● Not as energy efficient as wheels
2.1.6 Ways to overcome the 4-point base problem (non-uniformed normal force on each wheel)
● Movement depends on the leg mechanism, a legged robot usually has 2 or 4 legs.
● Less efficiency compared to wheeled robots.
● Complex in design and programming.
CHAPTER 3 EXTENSION
It is a mechanism which can be extended or change in size, length or position of an object using a slider
mechanism and bearing
Advantages
● Simple structure
● More rigid
Disadvantages
● Limited length extension
Before After
Advantages
● Saves space
● Able to extend to a great length
Disadvantages
● Complex attachment
● Not rigid (has a lot of joints)
● Low stability
Advantages
● Less friction
Disadvantages
● Complex attachment
● Heavy
3.6 PE slider
Advantages
● Shaped easily
● Simple attachment
Disadvantages
● Time-consuming in making the PE
● High Friction
3.7 Gripper
CHAPTER 4 ACTUATOR
Move a mechanism using mechanical devices. Uses air and electric current.
Types of Actuator
4.7 Elastic
Example: rubber and spring
● Cheap
● Simple usage
➢ No proper control
➢ Cannot last long
4.8 Servo
● Precise
● Simple usage
➢ Slow speed
➢ Gear will break easily when high torque is required
5.1 Tools
b. Combination spanner
The ring end allows stronger force to be applied
d. Crescent wrench
The width of ‘jaw’ is adjustable to fit different sizes of fasteners
5.1.2 Pliers
a. Combination pliers
For gripping and holding objects or cutting, wires Can be used to bend a light metal rod
b. Needle-nose pliers
To cut and bend wires or electrical wiring Reaches tight and narrow spots
c. Circlip pliers
To insert or remove circlips
Internal circlip
d.Diagonal cutter
Useful for cutting the wires. Not used to grab or turn anything
e Locking pliers
Can be used as both plier or wrench. Able to grip and hold on to object(s) firmly Width of
the ‘jaw’ is adjustable
5.1.3 Hammers
a. Claw Hammer
To hammer nails into an object, specifically wood. The claw is used to draw nails from
wood
c. Mallet
To adjust the position between joint objects by a slight degree Prevent dents or marks
when shaping objects such as aluminium
5.1.4 Saws
a. Handsaw
For cutting wood or other material
b. Hacksaw
Suitable for cutting wood and light metal
Can cut almost any size or shape of metal object
c. Screwdrivers
A tool for fastening screws, bolts and nails
5.1.7 File
Used to shave excess metal
To smoothen or roughen metal surfaces
5.1.8 L-ruler
Useful when measuring perpendicularly to an object
Used to outline cutting
5.1.9 Riveter
Use to rivet two surfaces together.
Rivet has strong shear and tensile strength
5.1.11 G-clamp
To clamp an object to a work surface for sawing or drilling
To prevent denting of workpiece, always use a piece of scrap wood between jaws of the
clamp
5.2 Machines
Advantage of MIG
● Higher welding speeds with high quality
● The process is easily automated process
● No flux requires in most cases
● MIG welding is versatile and can be used with a wide variety of metals and
alloys
● The MIG process can be operated in several ways, including semi and
fully automatic
Disadvantages of MIG
● Higher initial setup cost
● Higher maintenance cost due to the extra electronic component
● The equipment is complex
● MIG welding can only be used on thin to medium-thick metals
Safety precaution
● Work in a well-ventilated area
● Wear a welder cap and safety glasses
with shields
● Keep your head out of fumes
● Wear completely body protection
● Wear dry insulating gloves
5.3 3D printer
A 3D printer is a type of industrial robot which
conducts 3D printing. 3D printing is also known as a
process used to make a 3D object. In 3D printing,
successive layers of material (PLA, ABS, etc) are laid
down under computer control. These objects can be
of almost any shape or geometry and are produced
from a 3D model or other electronic data sources.
Type of 3D printer
Cartesian 3D printer
1. Named after the dimensional coordinate
system — the X, Y, and Z-axis — which is
used to determine where and how to move in
three dimensions
2. Advantage: This is a mechanically simpler
design, and therefore easier to maintain
3. Disadvantage: no overall problems, any
disadvantages of Cartesian style printers
depend on the manufacturer
Delta 3D printer
1. The extruder is suspended above the print bed by three arms
in a triangular configuration
2. Advantage: One of the main advantages of a Delta printer is
its speed. These printers were designed for quick printing.
Delta print heads are built to be as light as possible, which
results in a quicker printing process.
3. Disadvantage: One is the precision of the printer. As the
speed of the printer increases, its precision decreases
CHAPTER 6 FASTENER
6.1.2 Nut
6.1.4 Rivet
A permanent mechanical fastener
CHAPTER 7 MATERIALS
Poly-Ethylene (PE)
Perspex
Carbon Fiber
• Composed of carbon atoms bonded together to form a long chain.
• Extremely stiff, strong, and light.
• Used in many processes to create excellent building materials.
• Advantage: Strong, Light, very Durable
7.1 Aluminium: hollow tubes, hollow bar, L bar, flat bar, rod
● Advantages: light, solid
● Disadvantages: soft, expensive
7.4 Stainless steel: hollow bar, L bar, flat bar, rod, tube
● Advantages: solid, long-lasting
● Disadvantages: heavy, difficult to cut, expensive
7.6 Perspex
● Advantages: less friction, light, long-lasting
CHAPTER 8 SOFTWARE
8.1 SolidWorks
Widely used by students in Universiti Teknologi Malaysia
● Is a 3D mechanical CAD software
● Used to design 3D projects
● Able to do stimulation, analysis of projects, etc
CHAPTER 9 SENSOR
Obtains feedback from the surroundings
Measures a physical quantity and converts it into signal
Divided into categories according to their physical quantity feedback
9.3.3 Encoder
converts the angular position or motion of the shaft to an analog or digital value
9.5.2 Gyroscope
Measures rate of rotation and maintains orientation using the principle of angular
momentum
10.1.1 Resistor
Function:
● limits the flow of current
Unit: ohm, Ω
Obeys Ohm’s Law; V = IR (V = voltage, I = current, R = resistance)
Symbol:
resistor
variable resistor
10.1.2 Capacitor
Function:
● Stores electricity or electrical energy
● Acts as a filter
● Passes alternating current (AC) and blocks direct current (DC)
● Stabilizes voltage level and eliminates bouncing effect of contact switch
Unit: Farad, F
Symbol:
Multiplier
No. 1st 2nd Unit Result (Farad, F)
(x 103)
value value
1 4 7 3 pico 47×10-12×103=47 nF
2 3 3 0 pico
3 1 6 1 pico
Components that can deliver power to the circuit. Functions as a source of power in the
circuit. They are components that rely on an energy source to function or act as
amplifying components.
Example: ___________________________
10.2.1 Diode
Function:
● a semiconductor device which allows current to flow through in one
direction (from anode to cathode) aka forward bias.
Symbol:
10.2.3 Transistor
Function: used as a signal-controlled switch or amplifier.
Symbol:
10.2.4 Switch
Function: used to turn on and off circuits
Symbols:
Symbol:
➢ Application hints:
o The input voltage should always be greater than the output voltage (at least by 2.5V).
o The input current and output current are almost identical. (Max at 1.5A)
o Must attach heat sink when use in high current applications.
o Why? ___________________________
Advantages:
● Saves cost
● High performance
● Saves space
● Power saving (consumes only little amount of energy)
11.2 Solder
A fusible metal alloy used to join metal pieces.
Have a melting point below of the subject piece.
11.7 Tweezers
Used for picking up objects too small to be handled by human hands.
Example: surface mount components, IC chips
11.10 Multimeter
An electronic measuring instrument that combines several functions in one unit
Example: measuring voltage, resistance, capacitance, etc.
12.3 Microcontroller
▪ A circuit consisting of a microcontroller will work only if there are the elements below:
1. Power source: VDD (5V) and VSS (GND/ 0V)
2. Reset button: Resets the microcontroller back to the beginning of the program,
like a restart of a computer. It is an active low connection.
When the switch is not pushed, the output voltage will be high (5V). The pull-up resistor (4.7kῼ) ensures
it is high
When the switch is pushed, the output voltage is shorted to the ground. Thus, the voltage is low (0V)
When the switch is not pushed, the output voltage will be low (0V)
When the switch is pushed, the output voltage is shorted to Vcc, thus the voltage is high (5V)
12.9 Sensor
Using comparator to compare the feedback from sensor with the reference value
Vref
Vin
Connection of preset
ROBOCON WORKSHOP © UTM ROBOCON
Page | 48
Clockwise Counter-clockwise
Hands-on activities
1. Breadboarding
2. Tinkercad
Steps:
a. Drag out an LED! (From the right section under basic
components)
b. Don’t forget about your power! Drag a 9v battery out.
c. Randomly connect the positive (red) end to the LED,
we will soon find out if it’s the correct way.
d. Press at the top right.
e. If your LED lights up, congratulations! If it does not, then you know it’s in the opposite way.
g. How do we solve it? We put a resistor in series! The resistor here functions as a current-
limiting resistor.
h. It is always a good practice to put a resistor in series with an LED.
i. Resistor + LED = 1 set. (That’s what my senior told me.)
Quick question:
What happens if we connect it in REVERSE BIAS? Any guesses?
Try it in Tinkercad!
t. Next, we change the resistor to a preset variable resistor. Change the value to 1k ohms.
u. Observe the brightness of the LED.
v. Now we add a push button. But how to connect? There are 4 pins.
w. This push button is what we call a SPST (Single Pole Single Throw) switch.
x. In laymen terms, it means that the switch has one input and one output only.
y. Thus, two of the four pins are input and the other two are outputs.
But which is which? How to test it out?
z. Try randomly connecting the push button in series with the LED. (Along with power please!)
CHAPTER 13 C Programming
● C is a general-purpose, structured programming language.
● It is a high-level language(compared to assembly language) that allows the programmer to write a
program.
● The program using C language can be compiled to become executable machine code.
● The C language consists of 3 things:-
a. The Environment
b. The Language
c. The C Standard Library
● The Environment is to describe the method to write and implement the C program
● The Language is to emphasize on the rule of syntax
● The Library provides a
collection of existing functions
to perform operations
● There are four phases for a C
program to become an executable:
a. Pre-processing
b. Compilation
c. Assembly
d. Linking
● Standards of C: C89, C99, C11,
C18, and Embedded C.
● Make sure to read the compiler
documentation when writing a C program for a microcontroller.
Example 1
Preprocessor directives #include <stdio.h>
return }
Example 2
Preprocessor directive: stdio #include <stdio.h>
stands for standard input output.
Below shows ranges of data types with different modifiers, and format specifiers on 32-bit GCC compiler.
Data type Mem Precision Range of values Format
/Byte Specifier
unsigned char 1 1 0 to 255 %c
signed char 1 1 -128 to 127 %c
short int 2 1 -32,768 to 32,767 %hd
unsigned short int 2 1 0 to 65,535 %hu
unsigned int 4 1 0 to 4,294,967,295 %u
int 4 1 -2,147,483,648 to 2,147,483,647 %d
long int 8 1 -2,147,483,648 to 2,147,483,647 %ld
unsigned long int 8 1 0 to 4,294,967,295 %lu
long long int 8 1 -9,223,372,036,854,775,808 to %lld
9223372036854775807
unsigned long long int 8 1 0 to 18,446,744,073,709,551,615 %llu
float 4 6 decimal digits 1.2E-38 to 3.4E+38 %f
double 8 15 decimal digits 2.3E-308 to 1.7E+308 %lf
long double 16 19 decimal digits 3.4E-4932 to 1.1E+4932 %Lf
It is possible to determine the range of values a data type can present according to memory size and the
way it contains the information. For example, int have 4 byte = 4*4 = 16 bits, thus it has 2^16 possible
values. int without unsigned modifiers has negative values, thus its upper bound is [(2^14)/2] - 1
while its lower bound is -1*[(2^14)/2]. In contrast, unsigned int has no negative values, so it has
an upper bound of (2^14)-1 and a lower bound of 0.
Also, sometimes long and short will be used alone. long rat; means rat’s data-type is long
int while short pen; means pen’s data-type is short int.
13.5 Functions
A function is a set of statements that take parameters as input, do some specific computation and return
value as output. General form of function is as below:
return_type function_name([ arg1_type arg1_name, ... ]) { code }
Example 1
#include <stdio.h>
Example 2
#include <stdio.h>
/* Function prototypes */
int main()
{
long int result;
result = combination(5, 2); /* The return value is assigned
to result */
info(); /* info returns nothing */
printf(“5C2 = %ld\n”, result);
return 0;
}
/* Function Definitions */
long
combination (int n, int r)
{
return permutation(n,r)/factorial(r);
}
void factorial (int n)
{
long i = 1;
while (n > 0) {
i = i * n;
n--;
}
return i;
}
void info (void) { printf(“This program is written by ME\n”); }
Remarks:
Function definition can be done in a single line or multiple line according to your preference. However, it
is best to always follow a neat formatting style to ease readability.
/* GLOBAL VARIABLES */
int energy = 60; // total energy available
int rice = 4; // energy needed for 1 fried rice
int noodle = 5; // energy needed for 1 fried noodle
return 0;
}
void fried_rice (int num) {
int i = num; /* local variable of this function, similarly, */
/* other functions cannot access this i */
energy -= rice*i;
13.7 Operators
Arithmetic Operators
+ addition int i = 5; // value of i is 5
i = i + 2; // value of i now is 7
Unary Operators
Unary operators are operators that act upon a single operand to produce a new value.
- unary minus int i = 5; // value of i is 5
int j = -i; // value of j is -5
Relational Operators
== equal to Single ‘=’ is an assignment operator, which
assigns values. This has two ‘=’, which
compares the values.
!= Not equal to
Logical Operators
&& logical and ((5>3)&&(4>5)) means ((true)&&(false)) means (false)
Bitwise Operators
Let char a = 0b01010101, b = 0b11001100, c = 0;
Operation Value of c Remarks
<< Shift left c = a<<3; 0b10101000 The left operand’s value is moved left by the
number of bits specified by the right operand,
the empty right bits are all filled with 0.
>> Shift right C = a>>3; 0b00001010 The left operand’s value is moved right by
the number of bits specified by the right
operand, the empty left bits are all filled with
0.
Remarks:
Integer constants can be written as binary constants, consisting of a sequence of ‘0’ and ‘1’ digits,
prefixed by ‘0b’ or ‘0B’. Similarly, there are hexadecimal, which prefix is ‘0x’, and octal which is ‘0’.
For example, a decimal 27 can be represented by 0b11011, 0x1b, or 033.
Assignment Operators
= is the most basic assignment operator, which assigns value of right operand to left operand.
Below show how each following a <operator> b can be expanded.
+= a = a + b >>= a = a >> b
-= a = a - b <<= a = a << b
*= a = a * b &= a = a & b
/= a = a / b |= a = a | b
%= a = a % b ~= a = ~ b
Other Operators
, comma a binary operator that evaluates its first operand and discards the result, it
then evaluates the second operand and returns this value (and type).
int x = 5, y = 4;
If-Else
/* Basic single line */
if (x > 6) printf(“yes\n”); // {} can be omitted since printf
// is only one statement.
if (x > 6) { i = 5; b = 5; } // 2 statements, thus {} is needed
/* if-else */
if (x > 6) {
printf(“yes\n”);
} else {
printf(“no\n”);
}
/* if-else-if */
if (x > 6) printf(“no\n”);
else if (y > 9) { printf(“yes\n”); }
else if (t < 3) {
printf(“tt\n”);
} else if (j != 6) {
x = 0; y = 0; j = 0; t = 100;
} else if ((t-x)==6) printf(“joke\n”);
else printf(“end\n”);
/* this code is valid, showing different styles available */
Switch
int i = 1; /* assign a value to i here */
switch (i) { /* Check the value of i */
case 1:
printf(“One\n”);
break; /* Program will exit from switch */
case 4:
printf(“Four\n’); /* Program will continue to execute */
case 5: /* code for next case, which is 5 */
printf(“Five\n”);
break;
default:
printf(“Wrong\n’);
}
/* If i is 1, the switch will print One */
/* If i is 4, the switch will print Four then Five. */
/* If i is 5, the switch will print Five only. */
/* For other values of i, the code will print Wrong */
Example 1
For While Do-while
i--;
int i;
for (i = 99; i != 10; i--) {
if (i == 71) break; /* force exit from the for loop if i is 71 */
printf(“%d “, i);
if (i%4 == 0) continue; /* continue will skip the rest part and directly
evaluate (i != 10) and also run i--, entering
next loop */
printf(“\n”);
#include instructs the preprocessor to paste the text of the given file into the current file
#if checks whether the value is true (in the C sense of everything but 0) and if so,
includes the code between it and the closing #else or, if no #else is present,
#endif statement.
#ifndef checks whether the given token has been #defined earlier in the file or in an
included file; if not, it includes the code between it and the closing #else or, if
no #else is present, #endif statement.
FILE a preprocessor macro that expands to full path to the current file.
LINE a preprocessor macro that expands to current line number in the source file, as an
integer
DATE a preprocessor macro that expands to current date (at compile time) in the form
mmm dd yyyy (e.g. "Jan 14 2012"), as a string.
TIME a preprocessor macro that expands to current time (at compile time) in the form
hh::mm::ss in 24 hour time (e.g. "22:29:12"), as a string.
TIMESTAMP a preprocessor macro that expands to current time (at compile time) in the form
Ddd Mmm Date hh::mm::ss yyyy (e.g. "Wed Jan 18 22:29:12 2012"), as a string.
Example 1
1 /*
2 ** Runge-Kutta Method
3 ** dv/dt = 9.81 - 0.1v, where v=0 at t=0
4 */
5 #include <stdio.h>
6
7 #define END 1
8 #define FNVD(x) (9.81 - 0.1*(x))
9 #define DEBUG
10
11 int main() {
12 float t = 0.0, v = 0.0, h = 0.1;
13 float k1 = 0.0;
14 float k2 = 0.0;
15 float k3 = 0.0;
16 float k4 = 0.0;
17 #ifdef DEBUG
18 printf(“We’re at %d in %s\n”, LINE , FILE );
19 printf(" k1 k2 k3 k4 ");
20 #endif
21 printf(" T -- V\n");
22 while (t < END) {
23 #ifdef DEBUG
24 printf("%.5f %.5f %.5f %.5f :: ",k1, k2, k3, k4);
25 #endif
26 printf("%.1f -- %8.5f\n", t, v);
27 k1 = h*FNVD(v);
28 k2 = h*FNVD(v+0.5*k1);
29 k3 = h*FNVD(v+0.5*k2);
30 k4 = h*FNVD(v+k3);
31 v = v + (k1 + 2*(k2+k3) + k4)/6;
32 t = t + h;
33 }
34 return 0;
35 }
Remarks:
END is a symbolic constant. The compiler sees line 22 as while (t < 1) {.
FNVD(x) is a macro. The compiler sees line 27 as k1 = h*(9.81 - 0.1*(v)). Also, every (
and ) matters. If we use #define FNVD(x) 9.81 - 0.1*x , the compiler will sees line 27 as
k1 = h*9.81 - 0.1*v , since the compiler directly copy-paste macro, so the resulting arithmetic
expression is not what we wanted.
Example 1
/*
** Sieve of Eratosthene
** - an algorithm for finding prime numbers
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
int input;
printf("List all primes number smaller than ");
scanf("%d", &input);
if (input > 100000 || input < 3) /* Limit the input range */
printf("Invalid range\n");
else
sieve(input);
return 0;
}
Example 2
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#if defined(_WIN32)
#include <windows.h>
#define clr system("cls")
#define slp(x) Sleep(x*1000)
#elif defined( linux )
#include <unistd.h>
#define clr system("clear")
#define slp(x) sleep(x)
#else
#define clr
#define slp
#endif
char bd[9];
char ci (char*);
void pb (void);
char cb (void);
clr;
ttl;
prt("Single or Multi (s/m): ");
inp;
if ((strlen(buf) == 1)&&(buf[0] == 's')) t = 0;
else if ((strlen(buf) == 1)&&(buf[0] == 'm')) t = 1;
else { prt("Undefined input.\n"); return 0; }
while(1) {
clr;
ttl;
if(e) { prt("Wrong Input!\n"); e = 0; } else prt("\n");
pb();
if (r != 9) {
if (t == 1) {
if ((r&1) == 0) {
prt("Player1's turn [0-9]: "); inp; chk; drx;
} else {
prt("Player2's turn [0-9]: "); inp; chk; dro;
}
} else {
if ((r&1) == 0) {
prt("Player's turn [0-9]: "); inp; chk; drx;
} else if (r!= 9){
prt("Computer's turn.");
fflush(stdout);
while(bd[(buf[0]=rand()%9)]!=' ');
buf[0]+='1';
dro;
slp(1);
}
}
} else { prt("Nobody wins!\n"); return 0; }
a = cb();
if (a != 0) break;
r++;
}
clr;
ttl;
if(a == 'x') {
if (t == 1) prt("Player1 wins!\n");
else prt("Player wins!\n");
} else if(a == 'o') {
if (t == 1) prt("Player2 wins!\n");
else prt("Computer wins!\n");
}
pb();
return 0;
}
/* Check Input */
char ci (char* buf)
{
if (buf[0] > 48 && buf[0] < 58 && buf[1] == 0)
if (bd[buf[0]-'1'] != ' ') return 1;
else return 0;
else return 1;
}
/* Print Board */
void pb (void)
{
int i,j;
for (i=0; i!=9; i+=3) {
for(j=0; j!=3; j++) printf("%d---",j+i+1);
prt("+\n");
for(j=0; j!=3; j++) printf("| %c ",bd[j+i]);
prt("|\n");
}
prt("+---+---+---+\n\n");
}
/* Check Board */
char cb (void)
{
int i;
for (i = 0; i != 9; i+=3)
if (bd[i]!=' ' && bd[i+1]!=' ' && bd[i+2]!=' ')
if (bd[i] == bd[i+1] && bd[i] == bd[i+2])
return bd[i];
for (i = 0; i != 3; i++ )
if (bd[i]!=' ' && bd[i+3]!=' ' && bd[i+6]!=' ')
if (bd[i] == bd[i+3] && bd[i] == bd[i+6])
return bd[i];
if (bd[0]!=' ' && bd[4]!=' ' && bd[8]!=' ')
if (bd[0] == bd[4] && bd[0] == bd[8]) return bd[0];
if (bd[2]!=' ' && bd[4]!=' ' && bd[6]!=' ')
if (bd[2] == bd[4] && bd[2] == bd[6]) return bd[2];
return 0;
CONTACT US:
utmrbc.com
utm.rbc