PWM_32_v2 Frquency set math
Hello I have been looking at Beau's object and want to know how to figure the Period of the PWM.Duty comand to get adifferent frequency.
example:
PWM.Duty(7,50,5000)
I understand this is a PWM signal on Pin 7 at 50% duty cycle but I cant wrap my head around what frequncy the 5000 represents and how to figure it to a different frquency.
Thanks
example:
PWM.Duty(7,50,5000)
I understand this is a PWM signal on Pin 7 at 50% duty cycle but I cant wrap my head around what frequncy the 5000 represents and how to figure it to a different frquency.
Thanks

Comments
PUB Duty(Pin,DutyCycle,Period)|BasePeriod,Ton,Toff '' Pin = 0 to 31 If Period <> 0 If DutyCycle == 0 '' DutyCycle = 0 to 100 DutyMode(Pin,2) StateMode(Pin,1) If DutyCycle == 100 DutyMode(Pin,1) StateMode(Pin,1) If DutyCycle <> 0 and DutyCycle <> 100 BasePeriod := (Period*1000)/Resolution '' [COLOR="red"]Period is in micro seconds and[/COLOR] Ton := (DutyCycle * BasePeriod) / 100 '' [COLOR="red"]represents the repetition rate[/COLOR] Toff := BasePeriod - Ton '' [COLOR="red"]of the PWM signal.[/COLOR] if Ton == 0 DutyMode(Pin,1) if Toff == 0 DutyMode(Pin,2) if Ton ==0 and Toff == 0 StateMode(Pin,0) if Ton<>0 or Toff<>0 PWM(Pin,Ton ,Toff) '' If Period = 0 then the pin is disabled DutyMode(Pin,0) else StateMode(Pin,0)PWM.Duty(1,50,125) = 1/8000hz = 0.000125ms (125us)
Is this correct?