Servers by jDrones

Integration of Pixracer with Optical Flow PMW 3901


(Ryan Ho) #1

Hi, we are a group of students trying to integrate Optical Flow PMW 3901 designed by Pesky Products with the Pixracer using the Arducopter ver 3.6 firmware .

Here’s the link: https://www.tindie.com/products/onehorse/pmw3901-optical-flow-sensor/#specs

So far the limited resources we have found pointed us to towards configuring the WIFI port, initially for the ESP 8266 Wifi Module. However, we are confused by how to configure it as well. Please help us (or save us) if you have any idea on how to do the above by responding below. Thank you!!!

You can reach me via email at: ryannho.rh@gmail.com


Pixracer unable to Connect to Mission planner after Flashing customised Firmware
(rmackay9) #2

Hi Ryan,

We actually have a driver for this optical flow sensor. It’s the same one that appears on one of the 2018/2019 SkyRocket drones.

I think you’ll hit at least two issues:

For anyone else interested in trying out these small optical flow sensors. There are three vendors that I’m aware of:


(Ryan Ho) #3

Thank you so much rmackay9. I truly appreciate your help. I will research on your links given.

But if anyone knows how to configure an SPI port on the Pixracer, please comment below… THANKS!!!


(Ryan Ho) #4

Hi rmackay9, i wanted to clarify if driver that you stated above is for the pixracer board, or the PMW3901. I am new to this, so excuse me if this is a ignorant question. I have to download arduino for this right?


(Rick) #5

He means that ArduCopter can be compiled differently to be compatible with different hardware. In this case, the driver that you need is only included in the firmware when compiling it for the SkyViper, so you will need to modify the firmware before compiling so that it includes this driver for your hardware.


(rmackay9) #6

What @Anubis says is all correct.

Despite the name, ArduPilot is not arduino. Many years ago it was built on arduino (… and Arduino is mostly just C++ with some helpful libraries together with an easy to use compile and upload environment) but these days ArduPilot is all C++. Instructions for building AP are here.

I’m happy to build it for you though of course once you’ve got the hardware ready. It’s a very easy change, we just need to move the “backend = AP_OpticalFlow_Pixart::detect(“pixartflow”, *this);” line down a couple of lines so it’s after the #endif


(Ryan Ho) #7

Ok so, I kinda really need to use the Pixracer Board hardware. According to various sources, the Wifi port can be converted into an SPI port for the optic flow as seen in this link: Configuring wi-fi port as SPI port in a Pixracer board

I’m thankful for your offer if you are still interested in helping us.

Sidenote: So sorry for the multiple threads. This is our first time using this platform, so we are kinda ignorant about the etiquette.


(Joe Breznai) #8

Just wondering if any of the newly supported FC boards, like the Omnibus f4 could be easily modified to work as well. I believe they use SPI buss to communicate with the OSD chip. If there was a way to tap into that bus, perhaps one could have a very affordable FC with a inexpensive Flow sensor. I know nothing about how any of this hardware works, but it would be great ( and inexpensive) for a small quad.


(James Pattison) #9

G’day Joe,
it’s feasible: the device should work with any board that has an exposed SPI, although the change Randy pointed out above would be needed. For a long time no-one used external SPI sensors (for good technical reason - it’s meant to be a PCB protocol, not for external peripherals), but with short cable lengths it should work.


(James Pattison) #10

It might actually be easier to reassign those pins now than when your linked post was written.
Have a look at the stm32f427 tab data, and the pixracer hardware definition file: https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_HAL_ChibiOS/hwdef/fmuv4/hwdef.dat which should point you in the right direction.


(rmackay9) #11

Yup, I totally agree with what @james_pattison is saying - we should make the changes under ChibiOS because NuttX is on the way out… and it’s probably easier to do on ChibiOS.


(Joe Breznai) #12

Thanks. @james_pattison, I may take a stab at this as a winter project.


(Sergey) #13

I’ve also looked at Pixracer’s wi-fi port to a SPI conversion for external OSD connection.
It sounds pretty simple to do with ChibiOs, but my knowledge in hardware was not enough unfortunately.


(Andrea Belloni) #14

Hi Randy
the Cheerson optical flow sensor from banggood you linked above has a serial interface, there is no driver for OF on serial port, it could be written seeing the one from inav project (https://github.com/iNavFlight/inav/blob/master/src/main/io/opflow_cxof.c)


(James Pattison) #15

@tridge actually has one of the cheerson serial flow sensors on his desk. I’m not sure how far down his priority list it is though.


(James Pattison) #16

Someone will need to test, and this doesn’t do the hwdef changes to enable external SPI on boards that could but don’t, but will otherwise allow all the ChibiOS builds to use the sensor: https://github.com/auturgy/ardupilot/tree/auturgy-pwm3901-chibios?files=1


(rmackay9) #17

@anbello, thanks for that info. A serial interface is pretty easy to write actually.

@Ryan_Ho, if you’re interested in writing a serial driver for the cheerson optical flow we have this on the wiki which gives some advice on how to write new drivers.


(ppoirier) #18

@rmackay9 I am ready to test, as I have one sitting on my shelves since a couple of months…:wink:

The issue was not really with the driver but with the implementation of the EKF and how to make it as efficient as the PX4FLOW

Btw @anbello I am reading a signal data structure different than this one https://github.com/iNavFlight/inav/blob/master/src/main/io/opflow_cxof.c#L50


(James Pattison) #19

my little plan to sneak that into the build didn’t work unfortunately, so no point testing. It will need to be a compile time option, with a big caveat: this flow sensor needs to be the only device on the SPI bus (so if your FC has one SPI bus with multiple chip selects for the IMU and external, don’t use it as you’ll probably crash).
I’ll work on putting a hook into OpticalFlow.cpp so that if PIXARTFLOW_SPI is defined, it will build for it. I’ll need to add instructions to the wiki as well.


(ppoirier) #20

James, if you map a new SPI device with the hardware definition file on the PixRacer this would be ok then?