Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

how to change the pulse width of a GPIO pin? #60

Open
withr opened this issue May 6, 2015 · 1 comment
Open

how to change the pulse width of a GPIO pin? #60

withr opened this issue May 6, 2015 · 1 comment

Comments

@withr
Copy link

withr commented May 6, 2015

In the example of "example4_pwm_lowlevel.py", it said we can add a new pulse to a subcycle. E.g.:

import RPIO.PWM as PWM

GPIO = 17
CHANNEL = 0

PWM.set_loglevel(PWM.LOG_LEVEL_DEBUG)

PWM.setup()
PWM.init_channel(CHANNEL)
PWM.print_channel(CHANNEL)

PWM.add_channel_pulse(CHANNEL, GPIO, 0, 50)
PWM.add_channel_pulse(CHANNEL, GPIO, 100, 50)

The above code will generate a pulse with two high levels, for each level, the width is 50*10us, the subcycle should looks like: --------__,

what if I want change the pulse to --? I don't think we can use PWM.add_channel_pulse(CHANNEL, GPIO, 50, 50), because I feel that will create: ------_, Am I right? how to change the pulse width smoothly?

@mlv
Copy link

mlv commented May 6, 2015

I use PWM.Servo, as in:

Set the servo period to one million uSec (1S), increments of 5us

(necessary for 25us pulse width)
s=RPIO.PWM.Servo(subcycle_time_us=1000000, pulse_incr_us=5)

Set pulse width to 25us

s.set_servo(18, 25)

This is for a 25us pulse once per second.

On Wed, May 6, 2015 at 4:59 AM, withr notifications@github.com wrote:

In the example of "example4_pwm_lowlevel.py", it said we can add a new
pulse to a subcycle. E.g.:

import RPIO.PWM as PWM

GPIO = 17
CHANNEL = 0

PWM.set_loglevel(PWM.LOG_LEVEL_DEBUG)

PWM.setup()
PWM.init_channel(CHANNEL)
PWM.print_channel(CHANNEL)

PWM.add_channel_pulse(CHANNEL, GPIO, 0, 50)
PWM.add_channel_pulse(CHANNEL, GPIO, 100, 50)

The above code will generate a pulse with two high levels, for each level,
the width is 50*10us, the subcycle should looks like:
--------__,

what if I want change the pulse to --? I don't think we can
use PWM.add_channel_pulse(CHANNEL, GPIO, 50, 50), because I feel that will
create: ------
_, Am I right? how to change the pulse width
smoothly?


Reply to this email directly or view it on GitHub
#60.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants