Hallo,

Zitat Zitat von Goblin
das wäre supi. dann bewegt sich meine kamera auch endlich vernünftig....
da habe ich leider schlechte Nachrichten für Dich, wenn Du bei 1 MHz bleiben willst - es geht nicht, nie und nimmer.. Kann auch nicht, wenn ich mir die angelegte Interruptroutine ansehe.

Mit 4 MHz geht es dann mit Ach und Krach, die Wiederholrate von 31 mS verträgt z.B. der Servo von Conrad netterweise gerade noch.

Die Werte für 4 MHz im Einzelnen:

Reload = 1
Servo Mitte: 80
Servo Rechts: 125
Servo Links: 40

Zu viel anderem ist der Prozessor dann nicht mehr zu gebrauchen, weil er vollauf mit der Servosteuerung beschäftigt ist.
Bei dem Thema Servo dürfte mir im Augenblick kein MCS-Verantwortlicher persönlich begegnen. Nicht weil es nicht funktioniert, das tut es ja innerhalb der gegebenen Grenzen., sondern weil die Beschreibung so grottenfalsch ist, daß man erst mal das Oszilloskop hernehmen muss, um der Sache auf die Schliche zu kommen.
Das war ja nun schon öfter Thema und ist Mark auch bekannt, scheint aber nicht zu interessieren.

Das benutzte Testprogramm hier (englisch, weil ich es mit Rüffel demnächst ins englische Forum stellen will - aber erst wenn ich mich abgekühlt habe):

Code:
'--------------------------- Servotest -----------------------------------------

$regfile = "m8def.dat"
$crystal = 4000000                           'internal choosen
'$crystal = 7372800
'$crystal = 14745600
'$crystal = 16000000

$hwstack = 64
$swstack = 64
$framesize = 64

$lib "mcsbyteint.lbx"

'-------------------------------------------------------------------------------
'The following remarks are valid and tested with Bascom V.1.11.5.2

'Servos need a positive pulse in order to operate. In general the pulse has to
'have a width of 1 mS (left) to 2 mS (right). This pulse has to be repeated
'approximately every 20 mS.
'With the config statement CONFIG Servos we can specify how many servo's we
'will use and which port pins are used.
'A maximum of 14 Servos can be used.
'The SERVO statements use one byte for an interrupt counter and the TIMER0.
'This means that you can not use TIMER0 anymore.
'The reload value specifies the repetition interval of the pulse.
'
'To gain the requierd  intervall of 20 mS, a reload value of 10 will work with
'a crystall of 16 Mhz, a reload value of 5 with a crystal of 8 Mhz.
'
'4 Mhz works with a reload of 1 but we never ever will get the standard repe-
'titon rate of 20 mS. The best to be reached is 31 mS. This still will work
'with most servos, but side effects may occur.
'
'Lower clockfrequencies simply don't work!
'
'The pulsewidth depends on the value we write to the corresponding  servo array
'-Servo(n)-. In praxis and as a rule of thumb this means for 8 MHz 84 to 168
'-(1 mS to 2 mS), for 16 MHz 78 to 156 and for 4 Mhz 35 to 130.


Const S_middle = 80
Const S_right = 125
Const S_left = 40

Config Servos = 1 , Servo1 = Portd.3 , Reload = 1

Config Portd.3 = Output

Enable Interrupts


Servo(1) = S_middle

Do

Waitms 20

    Servo(1) = S_middle
    Waitms 100
    Servo(1) = S_right
    Waitms 100
    Servo(1) = S_middle
    Waitms 100
    Servo(1) = S_left
    Waitms 100

Loop

End


'The relevant ISR:
'+0000002F:   930F        PUSH    R16              Push register on stack
'+00000030:   938F        PUSH    R24              Push register on stack
'+00000031:   B78F        IN      R24,0x3F         In from I/O location
'+00000032:   938F        PUSH    R24              Push register on stack
'+00000033:   93AF        PUSH    R26              Push register on stack
'+00000034:   93BF        PUSH    R27              Push register on stack
'+00000035:   939F        PUSH    R25              Push register on stack
'+00000036:   E6A0        LDI     R26,0x60         Load immediate
'+00000037:   E0B0        LDI     R27,0x00         Load immediate
'+00000038:   918D        LD      R24,X+           Load indirect and postincrement
'+00000039:   919C        LD      R25,X            Load indirect
'+0000003A:   9601        ADIW    R24,0x01         Add immediate to word
'+0000003B:   939C        ST      X,R25            Store indirect
'+0000003C:   938E        ST      -X,R24           Store indirect and predecrement
'+0000003D:   2700        CLR     R16              Clear Register
'+0000003E:   3081        CPI     R24,0x01         Compare with immediate
'+0000003F:   0790        CPC     R25,R16          Compare with carry
'+00000040:   F411        BRNE    PC+0x03          Branch if not equal
'+00000041:   9A93        SBI     0x12,3           Set bit in I/O register
'+00000042:   C00F        RJMP    PC+0x0010        Relative jump
'+00000043:   3090        CPI     R25,0x00         Compare with immediate
'+00000044:   F041        BREQ    PC+0x09          Branch if equal
'+00000045:   3D80        CPI     R24,0xD0         Compare with immediate
'+00000046:   E007        LDI     R16,0x07         Load immediate
'+00000047:   0790        CPC     R25,R16          Compare with carry
'+00000048:   F048        BRCS    PC+0x0A          Branch if carry set
'+00000049:   2700        CLR     R16              Clear Register
'+0000004A:   930D        ST      X+,R16           Store indirect and postincrement
'+0000004B:   930C        ST      X,R16            Store indirect
'+0000004C:   C005        RJMP    PC+0x0006        Relative jump
'+0000004D:   9612        ADIW    R26,0x02         Add immediate to word
'+0000004E:   919D        LD      R25,X+           Load indirect and postincrement
'+0000004F:   1789        CP      R24,R25          Compare
'+00000050:   F008        BRCS    PC+0x02          Branch if carry set
'+00000051:   9893        CBI     0x12,3           Clear bit in I/O register
'+00000052:   EF8D        LDI     R24,0xFD         Load immediate
'+00000053:   BF82        OUT     0x32,R24         Out to I/O location
'+00000054:   919F        POP     R25              Pop register from stack
'+00000055:   91BF        POP     R27              Pop register from stack
'+00000056:   91AF        POP     R26              Pop register from stack
'+00000057:   918F        POP     R24              Pop register from stack
'+00000058:   BF8F        OUT     0x3F,R24         Out to I/O location
'+00000059:   918F        POP     R24              Pop register from stack
'+0000005A:   910F        POP     R16              Pop register from stack
'+0000005B:   9518        RETI                     Interrupt return
BTW: Das alles gilt für die aktuelle Version V1.11.8.2

Grüße
Henrik