PWM inputs

I realized, that RasPi is not a ideal platform for reading PWM inputs. I wanted to start to play somehow with my RasPi with Navio shield. So I was looking for some project to have some motivation

Currently I am using Quadcopter with APM2.6 and I have also RasPi with RaspiCam on board. RasPi has its own WiFi dongle, so I am able to connect to it during the flight. I have created some scripts that allows me to “push trigger”, take a photo with RaspiCam, send it to my GCS laptop and show it on screen (Or alternative script, that starts Video streaming from RaspiCam to laptop). I can controll the quad via MAVlink, or directly with RC.

What I am missing that if I am flying by FPV I don’t have enough hands to controll the RC transmitter and laptop at the same time. I want to have ability to trigger “take photo” action with RC Tx with some spare channel. I thought that this would be a simple task, just connect some spare channel from Rx to RasPi and look for some code examples how to read PWM (there are a lot of examples for arduino on the internet). But I didn’t find any direct solution, but there are some hints to use some additional chip with precise timing, to be able to read PWM.

So finaly here is the question for this forum. Has the Navio shield some additional functionality that allows me to read PWM inputs?

Juraj,


You can use any GPIO to read PWM – there are GPIO’s in SPI and UART ports, PPM input port in also a GPIO.


There’s a library for Raspberry Pi called pigpio – it can sample GPIOs with the resolution of 1 microsecond. You can use it to read PWM. Check our example for reading PPM on our Github


With PWM it should be even simpler, just catch rising and falling edges and measure the time between them using pigpio functions.