Announcement

REXYGEN forum has been moved. This one is closed.
Head over to the new REXYGEN Community Forum at https://forum.rexygen.com.

Looking forward to meeting you there!
 

#1 2016-10-12 06:52:26

contactform
Member
Registered: 2015-10-30
Posts: 45

PWM frequency

I'm playing with the PWM pins on the Raspberry Pi now. How can I lock in a frequency. I need a frequency of 1Hz, with 0-100% duty cycle. Is this possible?

Thanks!

Offline

#2 2016-10-12 12:38:53

jaroslav_sobota
Administrator
Registered: 2015-10-27
Posts: 535

Re: PWM frequency

Hi,
for such a low frequency you can do without hardware PWM. Use a task with 10ms sampling time (this gives you 100 levels within duty cycle of 1s) and put the PWM function block inside. Set pertm=1 (i.e. 1 second, 1 Hz) and you are done. Is there any specific reason to use the hardware PWM?

Hope this helps,
Jaroslav

Last edited by jaroslav_sobota (2016-10-12 13:28:15)

Offline

#3 2016-10-12 21:43:10

mikeyh
Member
From: New Zealand
Registered: 2016-04-28
Posts: 44

Re: PWM frequency

Thats for the reply Jaroslav,

I will play with the pwm block and let you know how it goes.

Are you saying because of the low frequency I could use any of the GPIO pins? In this case I could save the hardware pwm pin for something that really needs it.

Cheers

Mike

Offline

#4 2016-10-13 06:29:23

jaroslav_sobota
Administrator
Registered: 2015-10-27
Posts: 535

Re: PWM frequency

Hi Mike,
exactly. For such a low frequency you can use any GPIO pin.

Jaroslav

Offline

Board footer

Powered by FluxBB