Hallo
Ein delay() dauert ca. 1 ms und ist damit zu grob für eine vernünftige Servoansteuerung:
Code:
#include <nibobee/iodefs.h>
#include <nibobee/delay.h>
#include <nibobee/analog.h>
#include <stdlib.h>
unsigned int winkel, nibobee_initialization;
unsigned char i;
int main(void)
{
analog_init(); // wollen wir später wirklich alle ADC-Kanäle einlesen?
delay(3000); // wait4programmer ;)
while(1)
{
for(i=0; i<50; i++) // ein Zyklus dauert ca. 20 ms
{
PORTC |= (1 << PC3); // Implus senden
delay(1);
PORTC &= ~(1 << PC3); // Pause senden
delay(19);
}
for(i=0; i<50; i++)
{
PORTC |= (1 << PC3);
delay(2);
PORTC &= ~(1 << PC3);
delay(19);
}
for(i=0; i<100; i++)
{
winkel=1000;
while(winkel--) PORTC |= (1 << PC3); // Impulslänge als Zählschleife
PORTC &= ~(1 << PC3);
delay(19);
}
}
return 0;
}
Wenn es blockierend sein darf, würden Zählschleifen funktionieren :)
gruß
mic
Lesezeichen