so leute, mittlerweile arbeitet mein 5 achs roboterarm auf der basis von dirks servo lib schon richtig. jetzt hab ich nur noch ein problem in meinem programm. und zwar sollte der arm nach einem kompletten arbeitszyklus solange in seiner grundstellung bleiben, bis wieder ein teil erkennt.

leider ist das momentan noch nicht der fall, da der arm nach einem komplett zyklus selbstständig wieder von vorne anfängt mit dem greifer zu greifen und sich anschließend den kompletten arbeitszyklus selbsständigt wiederholt.

das problem dürfte an meiner stopwatch2() liegen. irgendwie startet sie immer wieder selbstständig, ohne dass ein teil erkannt wird (hab es mit der terminal meldung überprüft).

hier mein bisheriges programm:

Code:
 // Uncommented Version of RP6ControlServo.c
// written by Dirk
// ------------------------------------------------------------------------------------------

#include "RP6ControlLib.h"
#include "RP6ControlServoLib.h"



//Servo 1 => PC2
//Servo 2 => PC3
//Servo 3=> PC4 
//Servo 4=> PC5 
//Servo 5=> PC6
//Reflexkoppler => PD6

uint8_t a;

void task_teil_erkannt(void)
{if (PIND & (1<<6))
	{
	a=1;
	writeString_P("kein Teil erkannt\n");}
	
else {a=0;
	writeString_P("Teil erkannt\n");

	startStopwatch2();
	
	}
}
void task_servoansteuerung(void)
{if (getStopwatch2() >100 && getStopwatch2() <6500)
	{
	servo1_position = 0;
	writeString_P("Greifer zu\n");
	}
	
if (getStopwatch2() > 2000 && getStopwatch2()<2200)
	{
	servo3_position = 50;
	servo4_position = 150;
	writeString_P("Arm hoch\n");
	writeString_P("start stopwatch2\n");}

if (getStopwatch2() >2200 && getStopwatch2() <2400)
	{servo4_position = 130;}

if (getStopwatch2() >2400 && getStopwatch2() <2600)
	{servo4_position = 110;}
	
if (getStopwatch2() >2600 && getStopwatch2() <2800)
	{servo4_position = 90;}
	
if (getStopwatch2() >2800 && getStopwatch2() <3000)
	{servo4_position = 80;}
	
if (getStopwatch2() >3000 && getStopwatch2() <3200)
	{servo4_position = 70;}
	
if (getStopwatch2() >3200 && getStopwatch2() <3400)
	{servo4_position = 60;}
	
if (getStopwatch2() >3400 && getStopwatch2() <3600)
	{servo4_position = 50;}
	
if (getStopwatch2() >3600 && getStopwatch2() <3800)
	{servo4_position = 40;}
	
if (getStopwatch2() > 3800 && getStopwatch2() <5000)
	{servo4_position = 30;}
	
if (getStopwatch2() >4500 && getStopwatch2() <9500)
	{servo5_position = 0;}

if (getStopwatch2() >5000 && getStopwatch2() <8500)
	{servo4_position = 0;}

if (getStopwatch2() >5500 && getStopwatch2() <7500)
	{servo2_position = 50;
	writeString_P("Greifer drehen\n");}
	
if (getStopwatch2() >6500)
	{servo1_position = RIGHT_TOUCH;}
	
if (getStopwatch2() >7500 )
	{servo2_position = 150;
	}
	
if (getStopwatch2() >8500 && getStopwatch2() <10500)
	{servo4_position = 100;}
	
if (getStopwatch2() >9500)
	{servo5_position = MIDDLE_POSITION;}
	
if (getStopwatch2() >10500)
	{servo4_position = 120;
	servo3_position = RIGHT_TOUCH;}
	
if (getStopwatch2() >10900)
	{servo4_position = 140;}
	
if (getStopwatch2() >11300 && getStopwatch2()< 11500)
	{servo4_position = RIGHT_TOUCH;}
	
if (getStopwatch2() >11500)
	{setStopwatch2(0);
	writeString_P("setStopwatch2 auf 0\n");}
	
}

int main(void)
{ 
   initRP6Control();
   DDRD &=~ (1<<6);		//Eingang für Reflexkoppler
   
   initSERVO(SERVO1|SERVO2|SERVO3|SERVO4|SERVO5);
	servo1_position = RIGHT_TOUCH;
	servo2_position = 150;
	servo3_position = RIGHT_TOUCH;
	servo4_position = RIGHT_TOUCH;
	servo5_position = MIDDLE_POSITION;
 
   
   while(true) 
   {task_servoansteuerung();

    task_teil_erkannt();
      

      task_SERVO();

      mSleep(3);
   }
   return 0;
}
fällt irgendjemand auf, was ich falsch programmiert habe.

p.s. demnächst stell ich ein video von meinem arm online, aber natürlich erst wenn der arm korrekt funktioniert.

mfg andi