Servo Ansteuerung: Unterschied zwischen den Versionen

Aus Ethersex_Wiki
Wechseln zu: Navigation, Suche
Zeile 62: Zeile 62:
 
<br>
 
<br>
 
<br>
 
<br>
 +
<br>
 +
<br>achso.. schuldigung, warum ich nicht das pwm servo modul im esex direkt nehme...
 +
<br>also irgend was ist dort sehr buggy.....
 +
<br>dieses ist nur als test gedacht um zu schauen ob der servo den ok ist, oder wo das problem sein könnte
 +
<br>
 +
<br>pwm servo_init
 +
<br>pwm servo_set 0 0  --> Pulsweite 4mS @ 9 Hz
 +
<br>pwm servo_set 0 225  -->  Pulsweite 15mS @ 9 Hz
 
<br>
 
<br>
 
<br>
 
<br>

Version vom 4. August 2009, 11:59 Uhr


Hier Mal ein kleines Alternatives Servo Test Programm,
Geschrieben für einen ATMega644 @ 16 MHz

Servo ausgang liegt am PortC - PC7

Frequenz 25 Hz, Pulsweite 1520 mS (Mittel Stellung)

... warum zum geier kann ich die variable pos nicht über ecmd so setzen das es auch funktioniert ?
... bitte vorsicht.... wen über ecmd die variable einen belibigen wert erhält, geht die pulsweite auf 4mS ...
... 4mS ... = Motor mehr als zum endanschlag... put put... :-)


dnl ################################################################################
dnl # This program is free software; you can redistribute it and/or modify it      #
dnl # under the terms of the GNU General Public License (either version 2 or       #
dnl # version 3) as published by the Free Software Foundation.                     #
dnl #                                                                              #
dnl # This program is distributed in the hope that it will be useful,              #
dnl # but WITHOUT ANY WARRANTY; without even the implied warranty of               #
dnl # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
dnl # GNU General Public License for more details.                                 #
dnl #                                                                              #
dnl # You should have received a copy of the GNU General Public License            #
dnl # along with this program; if not, write to the Free Software                  #
dnl # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                    #
dnl #                                                                              #
dnl # For more information on the GPL, please go to:                               #
dnl # http://www.gnu.org/copyleft/gpl.html                                         #
dnl #                                                                              #
dnl #                                                                              #
dnl # Daten Analyse und Programm Erstellung:                                       #
dnl #   Copyright (c) 08/2009 - Michael Schultz <ethersex@keyb.de>                 #
dnl #                                                                              #
dnl ################################################################################
dnl
CONTROL_START
        ECMD_GLOBAL(pos, 175, uint8_t);         dnl     Mittel Position @ 16 MHz
        THREAD(pwm_on)
                PORTC = 255 ;
                TCNT0 = pos ;
                PT_YIELD(pt);
        THREAD_END(pwm_on)
        ON STARTUP DO
                TCCR0B |=  _BV(CS02);           dnl     TCCR0B(CS02)=1          clkI/O/256 (From prescaler)
                TCCR0B &= ~_BV(CS01);           dnl     TCCR0B(CS01)=0          clkI/O/256 (From prescaler)
                TCCR0B &= ~_BV(CS00);           dnl     TCCR0B(CS00)=0          clkI/O/256 (From prescaler)
                TIMSK0 |=  _BV(TOIE0);          dnl     TIMSK0(TOIE0) = 1       Interrupt on Timer Overflow aktivieren
                DDRC = 255;
                PINC = 0;
                THREAD_START(pwm_on)
        END
CONTROL_END

ISR(TIMER0_OVF_vect)
{
        PORTC = 0 ;
        TCNT0 = pos ;
}





achso.. schuldigung, warum ich nicht das pwm servo modul im esex direkt nehme...
also irgend was ist dort sehr buggy.....
dieses ist nur als test gedacht um zu schauen ob der servo den ok ist, oder wo das problem sein könnte

pwm servo_init
pwm servo_set 0 0 --> Pulsweite 4mS @ 9 Hz
pwm servo_set 0 225 --> Pulsweite 15mS @ 9 Hz