naja, also es tut nun zwar, allerdings habe ich die kanone nun auf einen mini-servo von conrad gepackt, und ihn mit gnd, vdd und scl verbunden. ich habe keine erweiterungsplatine angeschlossen.doch wenn ich den servo dann mit dem tv-remote beispiel ansteuern wollte, dann hat er nicht geschossen, es lag wahrscheinlich daran, dass der cpu überlastet war! also mein programm(also davon der teil für den servo) sah so aus:vielen dank schon mal im vorraus !!Code:/** * INIT SERVO * * Call this once before using the servo task. * */ void initSERVO(void) { DDRC |= SERVO_OUT; // SERVO_OUT -> OUTPUT PORTC &= ~SERVO_OUT; // SERVO_OUT -> LO startStopwatch5(); // Needed for 20ms pulse repetition } /** * PULSE SERVO * * This is the servo pulse generation. This function * must be called every 20ms (pulse repetition). * * position = 0 : Left touch * position = RIGHT_TOUCH : Right touch * * ATTENTION: ! This function is BLOCKING all other activities for about 1 ! * ! to 2ms (depending on the value of position)!!! ! * ! If you generate a pulse every 20ms 5-10% of the processor's ! * ! calculating time is wasted by this kind of pulse generation. ! * ! If this is a problem for the rest of your program, you ! * ! cannot use this method. ! * ! You will need an interrupt-based solution instead. ! * */ void pulseSERVO(uint8_t position) { cli(); PORTC |= SERVO_OUT; // SERVO_OUT -> HI (pulse start) delayCycles(LEFT_TOUCH); while (position--) { delayCycles(PULSE_ADJUST); } PORTC &= ~SERVO_OUT; // SERVO_OUT -> LO (pulse end) sei(); } /** * SERVO TASK * * This is the servo demo task. * The positioning demo shows the servo lever rapidly * moving to the left touch, then slowly moving to * the right touch and so on ... * */ void task_SERVO(void) { if (getStopwatch5() > PULSE_REPETITION) { // Pulse every ~20ms pulseSERVO(pos); // Servo pulse [1..2ms] // --------------------------------------------------------------------- setStopwatch5(0); } }
Lesezeichen