Saturday, July 11, 2009

kuda hitam_my first line follower



Mini Race Car Background

This project requires combination of knowledge of mechanical, electronics, software, and automation system. Basically, the mini race car will be built by these three basics component:

1. Sensor

2. Motor

3. PIC 16F877A

These are the basic component to develop the project. The basic idea is that, when the sensor detects the line, motor will rotate, causing the race car to move in the desired path. The PIC16F877A will be the brain in controlling the motor, of which the direction the race car will go. Two sets of motor will be use, as right and left motor to enable the race car to turn right or left or even move backwards. We will discuss it more in motor segment.


The sensor technology

In this project, there are many ways in designing the sensor. Many types of sensor can also be used. However, the basic engineering concept is to design a product with minimum cost. Therefore, the most suitable sensor device that we will use is the Infra Red (IR) sensor. To develop these IR sensors, we need IR emitter and IR receiver. These two components will be put side to side in order to enable the IR receiver to receive the emitting signal from IR emitter. In this case, the IR sensors will detect white line. When the sensor detects white or reflective line, it gives low byte (0) to the PIC16F877A, while if it detects black or non reflective surface, it will give high byte (1) to the PIC16F877A.

In this project, we use three sets of IR sensors, which we place it at the middle, right, and left. These three sensors will determine the direction of the motor.



IR sensor mounted at the bottom of the race car

Each set of this sensor is connected to a pair or red LED as indicator. When sensor detects white line, LED will turn OFF. When sensor did not detect white line, the LED will turn ON.

These are the results of the sensor reading.

Sensor

LED

Motor response

Left

Middle

Right

Left

Middle

Right

0

0

0

off

off

off

Go Straight

0

1

1

off

on

on

Turn left

1

1

0

on

on

off

Turn Right

1

1

1

on

on

on

Sharp turn clockwise

Table 1: The result of sensor reading.

This is the concept of a line following robot. We can see that when the middle sensor detects the line, the robot will move forward. This is because the line is in the center of the robot. But when the left sensor or the right sensor detects the black line, this means that the robot have strayed from the line. If the robot strayed to the right, the left sensor will detect the line and the brain will react by turning left to go back to the line. As for the right sensor, it reacts in the opposite way.

Before we can use the sensor, we have to teach the sensor so that it can give us the desired result. Firstly, we have to ensure that the LED will response to the sensor. Secondly, we have to adjust the variable resistor, in order to get the correct distance of the sensor. This is done by looking at the LED. LED should turn off when sensor detects white line. If this does not happen, adjust the variable resistor so that LED will turned off, that means, the sensor is at the correct distance.

We also design the sensor to make sharp turn of the race car. This will happen when the race car strayed from its path, giving high byte (1) to the PIC16F877A from all three sensors. We will discuss more about the motor rotation in the motor section.

Mechanical Parts:

Tamiya Double Gearbox


The Tamiya #70168 double gearbox is a compact unit with two independent motors and gear trains. The kit includes two motors and all gears and parts to build any of the four possible gear ratio configurations (12.7:1, 38:1, 115:1, and 344:1). Although it is not typical, it is possible to assemble each side with different gear ratios. There are two possible output axle locations (for any given gear ratio, only one output location is possible). The output shafts are 3 mm hexagonal axles that are 10 cm (about four inches) from tip to tip. The axles work with of the wheels we carry, giving many options for the race car’s speed.

Tamiya Ball Caster

The Tamiya 70144 ball caster from Tamiya’s educational construction series is a small steel ball that rests on metal rollers inside a plastic housing. The caster can be assembled in two different ways, so that it has a total height of either 25 mm or 35 mm. The kit contains two complete ball casters and various types of mounting screws as well as spacers for small height adjustments.

Tamiya Tire Set

Use the pair of tires in the Tamiya 70145 narrow tire set for mechatronics race car that must make precise movements. With a 58 mm diameter and solid, rounded, 16 mm treads, these wheels will let your robot turn with little friction, even on rough surfaces like carpet.


the program

The programming:

#include

__CONFIG(0x3F32);

void main()

{

/* Sensor: L M R

RD0 RD1 RD2

Traffic light: RD3

sensor

Start button= RB0

Motors: L R

PWM RC1 RC2

RB5 RB7

RB4 RB6

*/ unsigned char j;

TRISB=0b00000001;

PORTB=0b00000000;

TRISC=0b00000000;

PORTC=0b11111111;

TRISD=0b11111111;

PORTD=0b00000000;

for (;;)

{

if (RB0==0) //check start button

break;

}

for(;;)

{

if (RD3==0) //check traffic light sensor

{

PORTB=0b00001111; //stop both motor

j=0b00001111; //save memory

}

else if (RD1==0) //check middle sensor

{

PORTB=0b10011111; //move forward

j=0b10011111; //save memory

}

else if (RD0==0) //check left sensor

{

PORTB=0b10001111; //move right motor

j=0b10001111; //save memory

else if (RD2==0) //check right sensor

{

PORTB=0b00011111; //move left motor

j=0b00011111; //save memory

}

else

{

PORTB=j; //read memory

}

}

}

The figure above is part of the program. If the robot is not moving in the direction that is supposed to, change the value for Port B that is circled in the program above. The four values represent RB7, RB6, RB5 and RB4 respectively. So to change the direction of the right wheel, change the value for RB7 and RB6 (first 2 digit) from 01 to 10. For the left wheel, change the value for RB5 and RB4 (next 2 digit) from 01 to 10. If the value is 00, that means that the motor stops. The value for ‘j’ has to be the same as Port B.


it's simple actually, just follow what cytron tells you to do, download mplab and picc lite, then you can finished the project in less than a week, trust me, but it has to be followed by great deal of efforts!!!


some other pictures of my kuda hitam..


my final product<>


control circuit


this is where u put ur creativity, hide the batteries, make it simple but absolute beauty



<>

1 comment:

  1. lo mw beli caster wheel yang depan kya gitu dimana ya?
    tanks
    hariagung.prabowo@yahoo.com

    ReplyDelete