Hallo,

ich wollte mal fragen, ob es eine "Stopwatch" mit höherer auflösung als die vorhandene gibt?
Selbst die sleep() Funktion ermöglicht nur eine Pulsgeneration auf 10° genau. Gibt es da vielleicht eine kleine Erweitrung für die Lib???

Hier mal mein Code. Mein Testservo hängt am ADC3 des M32 Boards.
Code:
// Includes:

#include "RP6ControlLib.h" 		// The RP6 Control Library. 
								// Always needs to be included!
#define		CLOCKWISE			4		//minimal value = 4
#define		COUNTERCLOCKWISE	22		//maximal value = 22
#define		SPEED				0		//set impulse increasement/decreasement Speed in ms (0 bis <40 ist Ruckelfrei)
#define		ADJUSTTIME			200		//Set the servo's time needed to rotate 180° in ms (ausbauen und Pausenzeit auf ein minimum reudzieren)



// Main function - The program starts here:

int main(void)
{
	initRP6Control(); // Always call this first! The Processor will not work
					  // correctly otherwise. 

	setStopwatch1(0);
	startStopwatch1();
	DDRA |= (ADC3);
	
	uint8_t pulse = CLOCKWISE;
	uint8_t countup = true;
	
	while(true) 
	{
		PORTA |= ADC3;
		sleep(pulse);
		PORTA &= ~ADC3;
		mSleep(20);         //könnte man noch durch eine Stopwatch ersetzen
		
		if(getStopwatch1() >= SPEED)		// nach ablauf der Zeit wird die nächste Position angefahren
		{
			if (pulse>=COUNTERCLOCKWISE)	// wechsel der drehrichtung
			{
				countup = false;
				mSleep(ADJUSTTIME);			// muss noch optimiert werden, damit es pausenlos läuft
			}
			else if (pulse<=CLOCKWISE)
			{
				countup = true;
				mSleep(ADJUSTTIME);
			}

			if (countup == true)			// ändrung der Richtung
				pulse++;
			else
				pulse--;
				
			setStopwatch1(0);
		}
	}
	return 0;
}
Das ist schon recht Simpel gehalten, aber dennoch mit einem besseren Timer ausbaufähig.

mfg WarChild