Hallo WeiserDruide,
versuch mal folgendes:
mit den variablen pwm_soft(1-6) werden die PWM-Werte für die jeweiligen Ausgänge eingestellt. Wenn du eine größere Auflösung möchtest, musst du pwm_soft(1-6) und ist_counter als z.b. word (16bit) deklarieren und ein paar zahlen verändern.Code:'Software PWM mit 6 Kanälen 'läuft auf 12,5kHz 'erweiterbar auf mehr Kanäle 'je mehr Kanäle, desto mehr Rechenleistung wird benötigt 'verwendet einen 8bit-Timer $regfile = "m32def.dat" $crystal = 16000000 $framesize = 60 $hwstack = 60 $swstack = 60 Config Timer2 = Timer , Prescale = 8 Timer2 = 96 On Timer2 Isr_von_timer2 Enable Timer2 Ddrc = &B11111111 Portc = &B00000000 Dim Pwm_soft(6) As Byte Dim Ist_counter As Byte Dim N As Byte Dim Pin_num As Byte Enable Interrupts Do 'Mainloop Loop End Isr_von_timer2: Timer2 = 96 Incr Ist_counter If Ist_counter = 255 Then Ist_counter = 0 For N = 1 To 6 Pin_num = N - 1 If Pwm_soft(n) <= Ist_counter Then Portc.pin_num = 0 Else Portc.pin_num = 1 End If Next N Return
Gruß
Chris







Zitieren

Lesezeichen