Hi, we're building a robot, which can pick up a golfball and drop it after a while.
We are having some problems, it's like the Arduino isn't working right, sometimes it's getting pulses, sometimes it's just changing it's way, doing nothing at all.
Everything worked well on our test models, but now, when everything is in our final model (which is way smaller), it just won't work.
I'm not a professional electronic specialist, so could it be that the arduino's (we tested two atmega168 models and one atmega8) are messed up because of an magnetic field => produced inside one of the servo's?
This is what we got:
Hardware
-2 modified servo motors ( futuba s3001) for driving
-1 regular servo motor for gripping the ball.
-an Arduino sending pulses to the 3 servo motors
-a rechargable 9V battery for powering the arduino (with a switch to power off/on)
-4 rechargable 1.5V batteries for powering the servo motors (with a switch to power off/on)
software
:exclamation
/* Project iRobot
* ---------------
* Last updated: 13/03/2007
*
* Pieter Carette www.pieterc.be
* Loic De Buck www.technicum.net
* Ken Ketelslegers www.hoepertingen.be
*
* 2Ba. IPO
* Product development
* Hogeschool Antwerpen
* www.arduino.cc
*
*/
/* - - - - - - - - - - - - - - V A R I A B E L E N - - - - - - - - - - - - - - - - */
// D R I V E
int servoPinrechts = 9;//De aansluiting van de rechterservo zit op pinnetje 9
int servoPinlinks = 10;//De aansluiting van de linkerservo zit op pinnetje 8
int pulse = 1502;//Integer van de pulse
int count = 0;//Deze variabele wordt gebruikt om een tijdsaanduiding te hebben
int traagvoor = 1520; //pulse moet traag vooruit
int snelvoor = 1990; //pulse snel vooruit
int traagachter = 3000-traagvoor; //pulse moet traag achteruit
int snelachter = 3000-snelvoor; //pulse moet snel achteruit
int pauze = 1502; //pulse moet snel achteruit
// G R I P
int servoPingrip = 5; //Pinnetje van de grip zit op 10
int doelbereikt = 0; //Variabele om aan te geven als doel bereikt is
/* - - - - - - - - - - - - - - - - F U N C T I O N S - - - - - - - - - - - - - - - - - */
// D R I V E
void draaien(int pulse) { //Deze functie laat beide motoren vooruit of achteruit gaan met dezelfde snelheid
count += 1; //optellen plus 1
digitalWrite(servoPinrechts, HIGH); //Startpuls Rechts
digitalWrite(servoPinlinks, HIGH); //Startpuls Links
delayMicroseconds(pulse); //Snelheid van de puls
digitalWrite(servoPinrechts, LOW); //Eind van de puls Rechts
digitalWrite(servoPinlinks, LOW); //Eind van de puls Links
delay(20); //Tussentijd van een puls
}
void rijden(int pulse) { //Deze functie laat beide motoren in tegengestelde richting gaan => Links of rechts draaien dus
count += 1; //optellen plus 1
digitalWrite(servoPinlinks, HIGH); //Startpuls Links
delayMicroseconds(pulse); //Snelheid van de puls
digitalWrite(servoPinlinks, LOW); //Eind van de puls Links
delay(20); //Tussentijd van een puls
digitalWrite(servoPinrechts, HIGH); //Startpuls Rechts
delayMicroseconds(3000-pulse); //Snelheid van de puls
digitalWrite(servoPinrechts, LOW); //Eind van de puls Rechts
delay(20); //Tussentijd van een puls
}
// G R I P
void grijp(int pulse) { //Deze functie laat het grijpen toe
count += 1; //optellen plus 1
digitalWrite(servoPingrip, HIGH); //Stuur een pulse door
delayMicroseconds(pulse); // pulse zelf
digitalWrite(servoPingrip, LOW); //Breek pulse af
delay(20); //Tussentijd => 20 om een ononderbroken lijn te draaien.
}
void setup() {
pinMode(servoPinrechts, OUTPUT);
pinMode(servoPinlinks, OUTPUT);
pinMode(servoPingrip, OUTPUT);
}
/* - - - - - - - - - - - - - - - - L O O P - - - - - - - - - - - - - - - - - */
void loop() {
if (count < 200) {
rijden(snelvoor);
}
if (count >= 200 && count < 400) {
rijden(snelachter);
}
if (count >= 400) {
draaien(snelachter);
}
}
[smiley=dankk2.gif] in advance.