Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navio2 Python - pwm cleanup problem #28

Closed
drobban opened this issue Dec 17, 2017 · 0 comments
Closed

Navio2 Python - pwm cleanup problem #28

drobban opened this issue Dec 17, 2017 · 0 comments

Comments

@drobban
Copy link
Contributor

drobban commented Dec 17, 2017

Hello.
Tested the Servo.py example and possibly found a problem.
emlidtool info:

Vendor: Emlid Limited
Product: Navio 2
Issue: Emlid 2017-09-22 94b6586ea415c117b57d0d9eed9fc2df0bf1bcfd
Kernel: 4.9.45-94f47ec-emlid-v7+

Tested scenario:
setting PWM_OUTPUT to 0
there is OUTPUT on PIN 1.
Just as expected.

Then setting PWM_OUTPUT to 1
there is OUTPUT on PIN 1 & PIN 2.
Did not expect that to happen.

I have tested a couple of scenarios and the pattern is, all previous used OUTPUTS will get activated.
OUTPUTS that has not yet been used is not outputting any signal.

I suspect a cleanup problem, so I extended the example to do something like this:

import sys
import time
import navio2 as navio
import navio2.pwm
import navio2.util

navio.util.check_apm()

PWM_OUTPUT = 2
SERVO_MIN = 1.250 #ms
SERVO_MAX = 1.750 #ms

#cleanup before work
for x in range(4):
    with navio.pwm.PWM(x) as pwm:
        pwm.set_period(1)

with navio.pwm.PWM(PWM_OUTPUT) as pwm2:
    pwm2.set_period(400)
    pwm2.enable()

    for _ in range(20):
        pwm2.set_duty_cycle(SERVO_MIN)
        time.sleep(1)
        pwm2.set_duty_cycle(SERVO_MAX)
        time.sleep(1)

This seems to set the first 4 pins into a disabled state. Leaving all other pins in a low state while working with the selected PWM_OUTPUT.

Not sure if my observations are correct or where the actual problem is located.
If my observations are correct, I would suggest some cleanup routines in method deinitialize() in navio2/pwm.py

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

No branches or pull requests

1 participant