Servo.py is not working

Hello,

I am very new to drone programming but here`s what I was trying to do

![IMG_0403|240x320](upload://nLoWQpyLdOg7lzm2Ha0w0QiOJmZ.JPG)![IMG_0406|320x240](upload://dDO2vBIlTv4iRp5vnl4qziSVo9u.JPG)![IMG_0404|240x320](upload://rdLHO2uE1qMNYHI63DNDULsxXoG.JPG) 
  • Connected Battery to Power Distribution board which connect to all 4 servo rails
  • Connected Raspberry PI to power ( seperate source )
  • Navio2 is powered through Raspberry Pi

So “sudo python LED.py” works fine
The GPS ones also work fine once I connect the GPS thing on top

however “sudo python Servo.py” does not work. I am expecting that “Servo.py” will make one of the motor ( connected to pin 1 or pin 2 on Navio2) will start rotating .

Can somebody please help me ?

IMG_0406IMG_0403IMG_0404

uploading images

Any help please ?

This example is supposed to control micro servo motor.

If you want make it work with your ESC + Motor pairs, you should change the code as following:

import sys
import time

import navio.pwm
import navio.util

navio.util.check_apm()

PWM_OUTPUT = 0
SERVO_MIN = 1.250 #ms
ESC_INIT =  1.100 #ms

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

    # initialize ESC: set initial duty_cicle for 3 sec
    for i in range(30):
        pwm.set_duty_cycle(ESC_INIT)
        time.sleep(0.1)

    while (True):
        pwm.set_duty_cycle(SERVO_MIN)
        time.sleep(0.1)

1 Like

Thank you very much for reply. Now since you are here can I ask another question. When I do fresh install of Raspberry pi with Stretch (https://docs.emlid.com/navio2/common/ardupilot/configuring-raspberry-pi/) after that the first thing I try to do is following :
sudo raspi-config --expand-rootfs

However the process exit with error “Device is mounted” etc. It seems like some process (navio) is running in background because I did not initiate any process.

I google this issue and try to partition manually as well (using fdisk) however same error. Do you know by any chance what could be causing it ?

Thanks in advance

the error seems weird.
But it is a RaspberryPi problem most likely. Cant imagine running processes in the background to be a problem.
But if you think that is the problem: in the navio documentation it is stated that you can start and stop ardupilot with systemctl. sudo systemctl stop arducopter.service for example. You should take a look into the docs.

Well I didn`t even started any service yet but ya its weird I am only one experiencing. Thanks for replying anyways.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.