pobieranie; pdf; ebook; download; do ÂściÂągnięcia
 
Cytat
Felicitas multos habet amicos - szczęście ma wielu przyjaciół.
Indeks Eddings_Dav D20021169 arteuza
 
  Witamy


[ Pobierz całość w formacie PDF ]

{ if (start==true) // start is a flag which is set on completion of input
{sensors_read(); //Reads sensor values and computes sensor sum and weighted average
pid_calc(); //Calculates position[set point] and computes Kp,Ki and Kd
calc_turn(); //Computes the error to be corrected
motor_drive(right_speed, left_speed);
}
else
motor_drive(0,0); }
float set( float a)
{ delay(100);
\Aneesh Vartakavi/ \m/. .\m/ P. Shrikrishna
Building Autonomous Line Followers with Arduino and PID! Page | 24
lcd.setCursor(0,1);
lcd.print(a);
while(digitalRead(select_switch)==LOW) //LCD print KI or KP or KD on one line
//dependant on select_count and display current value
{ delay(100);
if(digitalRead(up_switch)==HIGH) //If the button has been pressed
{ delay(100);
a*=10; // increment by .1 you can change this if you need to.
a++;
a/=10;
lcd.setCursor(0,1);
lcd.print(a);
}
if(digitalRead(down_switch)==HIGH)
{ delay(100);
a*=10;
a--;
a/=10;
lcd.setCursor(0,1);
lcd.print(a);
}
delay(70);// Delay to prevent debounce
}
delay(100);
return(a);
\Aneesh Vartakavi/ \m/. .\m/ P. Shrikrishna
Building Autonomous Line Followers with Arduino and PID! Page | 25
}
voidpush_button_set() //This is for changing the values of Ki,kp and kd
{
++select_count;
if (select_count==1)
{ lcd.clear();
lcd.print("Set Kp - ");
Kp=set(Kp);
++select_count;
}
delay(100);
if(select_count==2)
{ lcd.clear();
lcd.print("Set Ki - ");
Ki=set(Ki);
++select_count;
}
delay(100);
if(select_count==3)
{ lcd.clear();
lcd.print("Set Kd - ");
Kd=set(Kd);
++select_count;
}
delay(100);
\Aneesh Vartakavi/ \m/. .\m/ P. Shrikrishna
Building Autonomous Line Followers with Arduino and PID! Page | 26
if(select_count>3)
{start=true;
lcd.clear();
lcd.print("BRING IT ON!!!");
delay(3000);
}//LCD write push start button to start
}
I came across a funny problem when pins 0 and 1 dedicated to TX and RX on the Arduino were used. The
Arduino Software would not allow me to burn code while these pins were connected to some hardware,
and give me an error. This was solved when I removed the connections to these pins. I still don t know
why this happened, but if you face a similar problem you can try this and hopefully you ll get past it!
Pushbutton switches are susceptible to this problem called de-bounce, where the output voltage spikes
because of improper contact. You can eliminate this by introducing a delay, but remember you have to
hold the switch in position for a longer time for the code to register this as a change. It s always good to
add some delay in the code, but make sure it s not too less or too much to slow down process.
Sensor Thresholds
Another way you can achieve better control of your robot is to introduce a threshold value. Now say you
measured the reading on black to be about 500. Accounting for a little noise, you can assume any
reading in the range of 480 to 520 as black. The rest of the readings will be assumed as noise, and set to
zero. A code to implement this can run like this:
voidsensors_read()
{ sensors_average = 0;
sensors_sum = 0;
for (int i = 0; i
{
sensors[i] = analogRead(i);
// Readings less than threshold are filtered out for noise
\Aneesh Vartakavi/ \m/. .\m/ P. Shrikrishna
Building Autonomous Line Followers with Arduino and PID! Page | 27
if (sensors[i]
sensors[i] = 0;
sensors_average += sensors[i] * i * 1000; //Calculating the weighted mean of the sensor
readings
sensors_sum += int(sensors[i]); //Calculating sum of sensor readings
}
}
The sensors[i]
This threshold concept may help if your sensors do not give consistent readings. If you implement this
and find your bot does not work, vary the acceptable range a little. This is useful only if your robot
moves on a track of the same color throughout.
Detecting Discontinuities
Sometimes you may need to count the number of color discontinuities in the track. For example, a black
track with red breaks.
To count this, first note down the sensor readings when the bot is over red. This is an important
calibration step. Add a little threshold if you wish, and use flags to detect a transition. The code can run
like this :
if (sensors[i] red_threshold-threshold_offset)
//setting flags for counting
previous_red=true;
else
present_red=false;
if(previous_red== true &&present_red== false) //When the bot has moved from red to black,
count increments.
{ red_count++; digitalWrite(13,HIGH);
delay(50);
}
digitalWrite(13,LOW);
prev_red=pres_red;
\Aneesh Vartakavi/ \m/. .\m/ P. Shrikrishna
Building Autonomous Line Followers with Arduino and PID! Page | 28
}
Here we count the number of times the bot has moved from red to black. Counting the number of times
the bot moves from black to red requires a simple manipulation. I ve included an LED attached at pin 13
to flash whenever the transition is made. Once you test your robot and see this flash properly, you can
add a count variable and display it on the LCD panel if you used one.
Thinking Ahead
There are still things to do after you ve come this far. Things like right angle turns, discontinuities and
intersections are still left to be done! You can also use the bi-directional motor control feature too.
Maybe your current hardware is not enough to handle these, but that s for you to find out! You can re-
orient the sensors and make a wall-follower or maze solver robot too!
We hope you ve enjoyed learning, and found all this useful! This took much longer than we expected to
write out, and we don t know if we ll be writing more stuff like this again.
Contact Us!
We hope you like this, and would really like your feedback! We d love to know if you used some of this
and scaled greater heights or even if you really liked it! It s a good feeling to know a hell lot of work has
been appreciated! ;-)
Do mail us at barahir.bregor@gmail.com
And yeah& do keep your questions to the forums, and don t bombard us with them! ;-)
Peace!!!
\Aneesh Vartakavi/ \m/. .\m/ P. Shrikrishna [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • natalcia94.xlx.pl
  • comp
    IndeksLine of Fire W E B GriffinFred Saberhagen Berserker 14 Berserker's StarJanez Jalen Bobri 3, Vrhphenyl 2 alkenes.aldol grobJackson Lilian Braun Kot, który...18 Kot, który lubiśÂ‚ seryBenzoni Juliette Katarzyna tom 6Understanding the Galdrabók 1Mercedes Lackey Bardic Voices 03 Eagle and the Nightingales(1)241. Armstrong Lindsay śąona dla AustralijczykaColin Evans Great Feuds in History, Ten of the Liveliest Disputes Ever (2001)
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • rafalradomski.pev.pl
  • Cytat

    Długi język ma krótkie nogi. Krzysztof Mętrak
    Historia kroczy dziwnymi grogami. Grecy uczyli się od Trojan, uciekinierzy z Troi założyli Rzym, a Rzymianie podbili Grecję, po to jednak, by przejąć jej kulturę. Erik Durschmied
    A cruce salus - z krzyża (pochodzi) zbawienie.
    A ten zwycięzcą, kto drugim da / Najwięcej światła od siebie! Adam Asnyk, Dzisiejszym idealistom
    Ja błędy popełniam nieustannie, ale uważam, że to jest nieuniknione i nie ma co się wobec tego napinać i kontrolować, bo przestanę być normalnym człowiekiem i ze spontanicznej osoby zmienię się w poprawną nauczycielkę. Jeżeli mam uczyć dalej, to pod warunkiem, że będę sobą, ze swoimi wszystkimi głupotami i mądrościami, wadami i zaletami. s. 87 Zofia Kucówna - Zdarzenia potoczne

    Valid HTML 4.01 Transitional

    Free website template provided by freeweblooks.com