You are on page 1of 11

2008 BLACK CARRIER

6. Instruction on programming
In order to operate Carrier robot, you need to know all the functions required for Black Line Pro Max. This instruction does not include explanation on basic functions in programming. 1) Initiating servo motor positions Before your robot starts moving, you need to put all the Servo motors to initial positions. As you see in the picture below, servo setting program has to be downloaded in order to put Servos in position.
#include "main.h" int main(void) { start(0,300); // Initiation of robot // The rest is omitted // Please start your program below this line. servo1(0); servo2(100); servo3(100); delay_ms(500); // Servo runs for 0.5 second end(); // All actions completed return 0; } After running the robot with the above program, fix the arms to initial positions as shown in the pictures below:

2) Running servo motors Once initial positions are set, make program as below and download it to the robot. If you run the downloaded program, the robot will move as the picture below before it repeats the action indefinitely.
#include "main.h" int main(void) { start(0,300); // Initiation of robot // The rest is omitted // Please start your program from the line below. while(1) // Repeat indefinitely { servo1(0); servo2(100); servo3(100); delay_ms(500); // Servo runs for 0.5 second servo1(100); servo2(0); servo3(0); delay_ms(500); // Servo runs for 0.5 second } end(); // All actions completed return 0; }

3) Running Servo using #define commands #define commands visualize the program and express the positions in words, instead of numbers which need to be memorized. For example, #define S1IN 100 means that S1IN is the same as value 100. Servo position values, 0 and 100 in servo1(0); servo2(100); servo3(100); were supposed to be memorized. When expressed in words, however, you can program with more convenience.
#include "main.h" #define S1IN 0 #define S2IN 0 #define S3IN 100 #define S1OUT 100 #define S2OUT 100 #define S3OUT 0 int main(void) { start(0,300); // Initiation of robot // The rest omitted // Please start your program below this line. while(1) // Repeat indefinitely { servo1(S1IN); servo2(S2OUT); servo3(S3IN); delay_ms(500); // Run Servo for 0.5 second

servo1(S1OUT); servo2(S2IN); servo3(S3OUT); delay_ms(500); // Run Servo for 0.5 second } end(); // All actions completed return 0; }

4) Grabbing scoring objects This program is for taking scoring objects (ping pong balls, golf balls or tennis balls) as shown below. Before taking an object, robot has to recognize the pillar by using limit switch. Limit switch is connected to IN2 of Black Line Pro CPU. Robot will do the line tracing until the Limit switch is pressed. in2line(IN2 sensor options, speed, back brake time); 1. IN2 sensor options: ON (until the object is sensed), OFF (until it is no longer sensed) 2. Speed: 0 ~ 20 3. Back brake time: -3000 ~ 3000

#include "main.h" #define S1IN 0 #define S2IN 0 #define S3IN 100 #define S1OUT 100 #define S2OUT 100 #define S3OUT 0 int main(void) { start(0,300); // Initiation of robot // The rest omitted // Please start your program from the line below driver(20,16,12,8); // or driver(20,13,10,5); servo1(S1IN); servo2(S2OUT); servo3(S3IN); delay_ms(1000); line(pp,ff,20,0); // line(pp,ff,20,0); // in2line(ON,10,0); // Tracing line with speed 10 until the limit switch on IN2 is pressed servo2(S2IN); // Collecting a scoring object delay_ms(500); end(); // All actions completed return 0; }

- Remarks: When your robot senses the pillar No.3 from Crossing No.2, use a speed lower than 20 so that it can collect the object safely. (in2line(ON, 10, 0);) - Collecting of object is done by applying S2IN, which has been set with #define, to Servo2.

5) Getting away from pillar Once collection of scoring object is completed, your robot needs to make U-turn and get away from the pillar. You need to use Motor function first to move back enough distance so that the robot would not hit the pillar while making U-turn. The program example below includes program to collect the scoring object No.4.

#include "main.h" #define S1IN 0 #define S2IN 0 #define S3IN 100 #define S1OUT 100 #define S3OUT 0 #define S2OUT 100 int main(void) { start(0,300); // Initiation of robot. // The rest omitted // Please start your program below this line. driver(20,16,12,8); // or driver(20,13,10,5); servo1(S1IN); servo3(S3IN); servo2(S2OUT); delay_ms(1000); line(pp,ff,20,0); line(pp,ff,20,0); in2line(ON,10,0); servo2(S2IN); delay_ms(1000); motor(-20,-20,400?); // Moving back to clear the pillar. Optimal value 200 to 500 right4(10,0); // Turn until sensor No.4 right4(10,0); // Turn until sensor No.4 line(pp,ff,20,0); // end(); // All actions completed return 0; }

Remarks: When moving back using Motor function, your robot might not move straight due to the difference of RPM between two motors. Use bbspeed function to balance the backward speed. (Please refer to bbspeed function in Black Line PRO manual.) You may like to reduce turning speed since there are cases where the scoring object drops while making U-turn.

6) Handing over the objects After collecting scoring objects, the robots need to go to a meeting point to hand them over to each other. Caution is required not to fall since the meeting point is on a bridge with width of only 25cm. When a robot reaches meeting point, the other robot may or may not be there. Use linesensor function here: linesensor(Choice of IN1 or IN2 sensor, method of recognizing the crossing, moving direction after sensing the crossing, speed, back brake time); 1. Choice of IN1 or IN2 sensor: 1(IN1), 2(IN2), 3(IN1+IN2) 2. Method of recognizing the crossing: PP0, PP1, PP3(+,), TT1, TT2, TT3(,,,)
3. Moving direction after sensing the crossing: PP cross (FF, LL, RR, SS), TT cross (FF, FL, FR, LL, RR, SS, SL, SR)

4. Speed: 0 ~ 20 5. Back brake time: -3000 ~ 3000 - linesensor function stops the robot either using sensors IN1 or IN2, or using the different method of crossing in Line function. Upon reaching the meeting point, the robot has to wait for the other robot to arrive, sensing it with IN1 sensor. While(1) //infinite loop { if(IN1) //if sensed by IN1 { break; //breaking out from infinite loop } }
#include "main.h" #define S1IN 0 #define S2IN 0 #define S3IN 100 #define S1OUT 100 Meeting point #define S3OUT 0 #define S2OUT 100 int main(void) { Drop from the field start(0,300); // Initiation of robot // The rest omitted // Please start your program from the line below. driver(20,16,12,8); //or driver(20,13,10,5); line(pp,ff,20,0); // linedelay(20,1000?,0); // linesensor(1,tt,ss,10,0); // stops by IN1 sensor or TT crossing method while(1) // infinite loop { if(IN1) break; // Break out from infinite loop when sensed by IN1 } delay_ms(500); servo1(S1OUT); // handing over scoring objects delay_ms(500); servo1(S1IN); // servo1 back to original position delay_ms(500); end(); // All actions completed return 0; }

Remarks: The reason ss method was used for TT crossing in linesensor function is that the robot needs to stop when either one of the sensors senses crossing. 6) Going back after handing over scoring objects After handing over an object, robot has to move back first so that it would not hit the other robot while turning. Caution is required also not to fall from the bridge.

#include "main.h" #define S1IN 0 #define S2IN 0 #define S3IN 100 #define S1OUT 100 #define S3OUT 0 #define S2OUT 100 int main(void) { start(0,300); // Initiation of robot // The rest omitted // Please start your program from the line below. driver(20,16,12,8); //or driver(20,13,10,5); motor(-20,-20,300?); // left4(10,0); // line(pp,ff,20,0); // end(); // All actions completed return 0; }

Handover point

Drop from the field

Remarks: When moving back using MOTOR Function, your robot might not move straight due to the differences of RPM between two motors. Use bbspeed function to balance the backward speed. (Please refer to bbspeed function in Black Line PRO manual.) Make sure that your robot moves back straight since there are cases where robots fall off the bridge while making U-turn.

7) Discharging scoring objects You need to drop objects from the other robot in the scoring area in order to score points. While you use sensors to sense pillars and the other robot, you are not using sensors to recognize scoring area. linedelay function is used to halt robot at an appropriate place.

#include "main.h" #define S1IN 0 #define S2IN 0 #define S3IN 100 #define S1OUT 100 #define S3OUT 0 #define S2OUT 100 int main(void) { start(0,300); // Initiation of robot // The rest omitted. // Please start your program from the line below: driver(20,16,12,8); //or driver(20,13,10,5); line(pp,ff,20,0); // linedelay(10,1000?,0); // delay_ms(500); // servo3(S3OUT); // Discharging the scoring object delay_ms(500); servo3(S3IN); //Servo back to original position delay_ms(500); end(); // All the actions completed return 0; }

Scoring area

Remarks: The height of scoring area wall is 5cm. You need to find an optimal value for time in linedelay function to avoid pushing the scoring area too much. 8) Getting away from scoring area As at pillars, your robot needs to move back a little before making U-turn.
#include "main.h" #define S1IN 0 #define S2IN 0 #define S3IN 100 #define S1OUT #define S3OUT #define S2OUT int main(void) 100 0 100

Scoring area
{ start(0,300); // Initiation of robot // The rest omitted // Please start your program from the line below. driver(20,16,12,8); //or driver(20,13,10,5); motor(-20,-20,400?); // lefft4(10,0); // left4(10,0); // line(pp,ff,20,0); // end(); // All actions completed. return 0; }

Remarks: When making U-turn, move back sufficiently so that your robot do not hit the scoring area wall.

9) Completing 1 cycle

Bridge area

Handover point

Scoring area

Drop from the field

#include "main.h" #define S1IN 0 #define S2IN 0 #define S3IN 100 #define S1OUT #define S3OUT #define S2OUT 100 0 100

int main(void) { start(0,300); // Initiation of robot // The rest omitted. // Please start your program from the line below. driver(20,16,12,8); servo1(S1IN); servo2(S2OUT); servo3(S3IN); line(pp,ff,20,0); // 1 line(pp,ff,20,0); // 2 left4(10,0); // 2-1 in2line(1,10,0); // 3 delay_ms(500); // 3-1 servo2 (S2IN); // 3-2 delay_ms(500); // 3-3 motor(-20,-20,400?); // 4 right4(10,0); // 4-1 right4(10,0); // 4-2 line(pp,ff,20,0); // 5 line(pp,ff,20,0); // 6

line(pp,ff,20,0); // 7 right4(10,0); // 7-1 line(pp,ff,20,0); // 8 linedelay(20,2000?,0); // 9 linesensor(1,tt,ss,10,0); // 9-1 while(1) // 9-2 { if(IN1) break; // 9-3 } delay_ms(500); // 9-4 servo1(S1OUT); // 9-5 delay_ms(500); // 9-6 servo1(S1IN); // 9-7 delay_ms(500); // 9-8 motor(-20,-20,400?); // 10 right4(10,0); // 10-1 line(pp,ff,20,0); // 10-2 line(pp,ff,20,0); // 11 left4(10,0); // 11-1 line(pp,ff,20,0); // 12 line(pp,ff,20,0); // 13 right4(10,0); // 13-1 linedelay(10,500?,0); // 14 servo3(S3OUT); // 14-1 delay_ms(500); // 14-2 servo3(S3IN); // 14-3 delay_ms(500); // 14-4 end(); // All actions completed. return 0; }

10) Infinite repeat of the cycle

#include "main.h" #define S1IN 0 #define S2IN 0 #define S3IN 100 #define S1OUT 100 #define S3OUT 0 #define S2OUT 100 int main(void) { start(0,300); // Initiation of robot // The rest omitted. // Please start your program from the line below. driver(20,16,12,8); servo1(S1IN); servo2(S2OUT); servo3(S3IN); line(pp,ff,20,0); // 1 line(pp,ff,20,0); // 2 left4(10,0); // 2-1 while(1) { in2line(1,10,0); // 3 delay_ms(500); // 3-1 servo2(S2IN); // 3-2 delay_ms(500); // 3-3 motor(-20,-20,400?); // 4 right4(10,0); // 4-1 right4(10,0); // 4-2 line(pp,ff,20,0); // 5 line(pp,ff,20,0); // 6 line(pp,ff,20,0); // 7 right4(10,0); // 7-1 line(pp,ff,20,0); // 8

linedelay(20,2000?,0); // 9 linesensor(1,tt,ss,10,0); // 9-1 while(1) // 9-2 { if(IN1) break; // 9-3 } delay_ms(500); // 9-4 servo1(S1OUT); // 9-5 delay_ms(500); // 9-6 servo1(S1IN); // 9-7 delay_ms(500); // 9-8 motor(-20,-20,400?); // 10 right4(10,0); // 10-1 line(pp,ff,20,0); // 10-2 line(pp,ff,20,0); // 11 left4(10,0); // 11-1 line(pp,ff,20,0); // 12 line(pp,ff,20,0); // 13 right4(10,0); // 13-1 linedelay(10,500?,0); // 14 servo3(S3OUT); // 14-1 delay_ms(500); // 14-2 servo3(S3IN); // 14-3 delay_ms(500); // 14-4 servo2(S2OUT); motor(-20,-20,400?); //15-1 left4(10,0); //15-2 line(pp,ff,20,0); //16 } end(); // return 0; } //15

All actions completed.

11) Trying out a real game Please perform the mission in the play field below for 3 minutes. Mission: 1 > 4 > 2 > 1 > 4 > free sequence. Handover point is in the middle of bridge A

You might also like