pwmAsm.spin

Bildergalarie

Beide Kanäle mit unterschiedlichen sDuty Werten.

Gegentaktausgang eines Kanals.

(Quelle:)

Datenblatt

Modul

Anschaltung an Propeller

1..4 beliebige Pin's

PinA1 = PWM1 PinA2 = PWM1 negiert PinB1 = PWM2 PinB2 = PWM2 negiert

Durch eintragen einer Pinnummer wird der Ausgang zugewiesen. Durch eintragen von -1 wird die Funktion keinem Ausgang zugewiesen.

Es ist zu beachten das schwankungen der Betriebsspannung des Propellers sich auf das Ausgangssignal auswirken. Wie man auf beiden Bildern oben erkennen kann.

Softwaremodule

PUB-Routinen

PUB Init(PinA1,PinA2,PinB1,PinB2) : okay
'start pwm on Pin @ 8 kHz 0..100,00%
  stop
  longfill(@sDutyA, 0, 9)

  sDutyA    := 10000/3
  sDutyB    := 10000/2
  sPinAOut1 := |< PinA1
  sPinAOut2 := |< PinA2
  sPinBOut1 := |< PinB1
  sPinBOut2 := |< PinB2
'  sCtraVal  := %00100 << 26 + PinA1
'  sCtrbVal  := %00100 << 26 + PinB1
  sCtraVal  := %00101 << 26 + PinA1 + PINA2 << 9
  sCtrbVal  := %00101 << 26 + PinB1 + PINB2 << 9
  sPeriod   := 10000

  okay := cogon := (cog := cognew(@entry,@sDutyA)) > 0

PUB stop
'' Stop object - frees a cog
  if cogon~
    cogstop(cog)
  longfill(@sDutyA, 0, 9)

PUB SetPeriod(counts)
' set pwm period in clock cycles, frequency = (_clkfreq / period)
   sPeriod := counts

PUB SetDutyA(counts)
   if (counts < 0)
     counts := 0
   if (counts > 10000)
     counts := 10000
   sDutyA :=counts

PUB SetDutyB(counts)
   if (counts < 0)
     counts := 0
   if (counts > 10000)
     counts := 10000
   sDutyB :=counts
schnipsel/pwm.txt · Zuletzt geändert: 17.09.2020 10:31 von pic18f2550
 
Falls nicht anders bezeichnet, ist der Inhalt dieses Wikis unter der folgenden Lizenz veröffentlicht: GNU Free Documentation License 1.3
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki