Mein RP6 ist grad eingemottet, ich kann's deshalb nicht testen:
Die Beschreibung von sleep() in der Library:Code:// Servoansteuerung mit sleep(), Servoimpuls an ADC0 10.1.09 mic #include "RP6RobotBaseLib.h" int main(void) { initRobotBase(); // initialisieren DDRA |= 1; // Datenrichtung Port A Bit 0 (das ist ADC0) auf Ausgang while(true) // endlos Impulse für Servomitte senden { PORTA |= 1; // Ausgang auf high setzen (Impulsstart für Servo) sleep(15); // sleep(1) verzögert ca. 100µsec, sleep(15) dann ca. 1,5ms=Servomitte PORTA &= ~1; // Ausgang auf low setzen (Impulsende für Servo) sleep(200-15); // 20ms-Impulslänge warten vor nächstem Impuls } return(0); }
Infos zum Impulstimeing der Servos gibt's im RN-Wissen./**
* Delay with the help of the 10kHz timer.
* sleep(10) delays for *about* 1ms! Not exaclty, as we do not use assembly routines
* anywhere in this library!
*
* This is a blocking routine, which means that the processor
* will loop in this routine and (except for interrupts) the
* normal program flow is stopped!
* Thus you should use the Stopwatch functions wherever you can!
*
* Example:
* sleep(1); // delay 1 * 100us = 100us = 0.1ms
* sleep(10); // delay 10 * 100us = 1000us = 1ms
* sleep(100); // delay 100 * 100us = 10000us = 10ms
* // The maximum delay is:
* sleep(255); // delay 255 * 100us = 25500us = 25.5ms
*/
void sleep(uint8_t time)
{
for (delay_timer = 0; delay_timer < time;
}
Gruß
mic
Lesezeichen