QuadCopter using Raspberry Zero W

Today I have mounted my Raspberry Zero W on my QuadCopter
If it works it will lighten the total weight of the Quadcopter because the Zero weighs only 9 grams!
On the other hand, Raspberry Zero is much less powerful than my Raspberry 2 ...

The big problem was ServoBlaster
Like RPIO, this library did not want to run on a Raspberry Zero!?!

So, I tested pigpio and miracle, it works!

Then, I see the pigiod daemon consumes a little too much cpu ...
Consumption 7.1% .... Gloups .... I thought it was hardware.
I'll analyze that later



Here is my python code :

import time
import pigpio

SERVO = 4

pi = pigpio.pi() # Connect to local Pi.

print("start")
pi.set_PWM_frequency(SERVO,50)
pi.set_servo_pulsewidth(SERVO, 1000) # Minimum throttle.
print (pi.get_PWM_frequency(17))
raw_input("Press Enter to 1100...")

pi.set_servo_pulsewidth(SERVO, 1200) # Minimum throttle.
raw_input("Press Enter to end...")

pi.set_servo_pulsewidth(SERVO, 2000) # Minimum throttle.
raw_input("Press Enter to end...")

pi.set_servo_pulsewidth(SERVO, 0) # Stop servo pulses.

pi.stop() # Disconnect from local Raspberry Pi.

print("end")


Some explanations

  • The ESC is connected to the GPIO4: SERVO = 4
  • By default the PWM frequency was 100Hz
  • The PWM frequency must be changed to 50Hz: pi.set_PWM_frequency (SERVO, 50)

I also reconnected the MPU6020 gyroscope / accelerometer to the I2C bus

After to do this, you need to edit the file /boot/config.txt and add the line below and reboot

dtparam=i2c_arm_baudrate=400000



Raspberry Zero W on my QuadCopter



Et voila ;-)

Commentaires

Posts les plus consultés de ce blog

Attiny13A sleep mode

Esp-01 deep sleep mode

Install and configure OpenVPN on OSMC