Servers by jDrones

SPI for Optical flow on OmnibusF4 or pixracer

optical-flow
omnubus-f4
spi

(Boom_Boom) #1

Hi, I would like to make a small arducopter quad with optical flow + laser altitude.
I’ve flown with a px4flow and a benewake mini lidar, but that’s to big and heavy.

I saw this topic, Survey for new tiny optical flow manufacturing
and I can’t find the topic where holybro announced working on a CAN-Flow module.
But i cant’t buy these yet and i don’t mind that i’s not entirely plug and play.

I like this board: https://store.bitcraze.io/products/flow-breakout
Cheap and likely to be able to work with minimal effort.

same flow sensor with serial connection. I think this would be more work to get it to run. But i do have spare uarts.

The VL53 in the bitcraze flow-deck should be plug and play, i2c and there is a driver.

I’ve not yet used a external spi connection on a pixhawk.
From what i’ve read the flow sensor on SPI can be auto-detected (with the apm board).
Is this true?

There is normally no external spi-out port on a pixracer, but is there a way around that?
Like using the SD-Card slot, although i would like to keep the SD, or this: Configuring wi-fi port as SPI port in a Pixracer board.

This omnibus-F4 has a external SPI: https://store.myairbot.com/omnibusf4v6.html
Would that be available when flashing it with the pre-compiled firmware for omnibusf4 (3.6.* - chibios)?

A pixhawk4 has SPI-out, and weighs 16g with all the casing gone, but i would like something smaller (and cheaper is nice to)
But would this work, simply connecting the bitcraze board to the pixhawk4 with spi ? (And i2c for the VL53 sensor)
Or do i need to change the config and compile my own firmware?


(James Pattison) #2

The omnibus external SPI isn’t defined in ArduPilot. It might be easy to add though. Perhaps have a look at the hwdef.dat in GitHub and see if you can add it?
Re PH4 (or even original Pixhawk), the exposed SPI should work just fine.


(Boom_Boom) #3

Just received a omnibusf4 and a omnibus nano V6, and got them to run arducopter.
The bitcraze flow breakout board is on its way.

I think going to start with the nano, it would be ideal if i can use the spi for the osd.
I’m not using the this osd anyway so i can cut it off and re-use the pins.

in fmuv3 (old amp) i see a line for the pixart optical flow sensor
418 SPIDEV pixartPC15 SPI4 DEVID13 ACCEL_EXT_CS MODE3 2MHZ 2MHZ

For the nanoV6 hwdef.dat the spi is defined for osd, https://github.com/ArduPilot/ardupilot/blob/27ded1c12b4effa9a8da354783b01d795dd8280b/libraries/AP_HAL_ChibiOS/hwdef/OmnibusNanoV6/hwdef.dat
85 # SPI Device table
88 SPIDEV osd SPI3 DEVID4 OSD_CS MODE0 10MHZ 10MHZ

Is a extra line here the only firmware modification needed to get the pixart sensor of the bitcraze-flow to work on the nanov6?

PS: the Pixhawk4 (FMUv5) also does not have the "SPIDEV pixartPC15 SPI4 " line so i would think it would also not work without changing the firmware…


(Boom_Boom) #4

I’m a step further, although not yet flying with the bitcraze optical flow breakout working.

I connected the VL53 laser from the bitcraze board to a omnibusF4 V5.1 and flew with it keeping altitude on the laser distance measurement. That works great without having to modify anything (just set the params correctly.
Next i hooked it up to a PH4, to the I2C-A port. It did not work :frowning: . Then to the I2C that’s at the GPS port, and that did work. Probably needs a change in hwdef.dat to get it working on the external “I2C A” (should be in master imho)

I first want to get the optical flow Bitcraze Breakout board working with whatever is the easiest, and unfortunatly i don’t have the old apm flightcomputer but the Pixhawk 4 has an external SPI so i thought this should work. (on the omnubusf4 or omnibusNanoV6 or Pixracer it would take more modifications i think so that would be the next step if this works.

It took me a while before i was able to compile the firmware, but now i’m able to on a linux-laptop.
I first did what i said before, but i got an error right-away. It was missing a CS pin.
There are two externally, with the one external SPI port (connector), but none in the hwdef.dat!
This seems like an error to me (or a very odd choice), the SPI port is defined just # disabled to save DMA channels (whatever DMA channels are, i’ll look it up if necessary)
If you do that with the SPI port, why would you not do the same with the CS pins…

But i found a way to configure the cs pin (i think) in the PX4-firmware (they are named here: https://github.com/PX4/Firmware/blob/525531f2fc6057528d1ab2315c1d9bae49c4efab/src/drivers/boards/px4fmu-v5/board_config.h#L166
(although there they have 3 CS pins somehow…)
So i set it up with “PI4” hoping it is named the same in the px4 firmware as in the ardupilot firmware, but i think this might be wrong…

But after compiling, no errors, but it also doesn’t seem to work (i get the bad optical flow message, but that does not mean everything).

Then i started to look around in the optical flow code, and saw some interesting stuff.
In OpticalFlow.cpp the AP_FEATURE_BOARD_DETECT has to work, and the ony chibios one is the “HAL_BOARD_SUBTYPE_CHIBIOS_SKYVIPER_F412”. So i switched it out with “HAL_BOARD_SUBTYPE_CHIBIOS_FMUV5”.
And looking at the hwdef.bat from the skyviper_f412 it did not use “pixartPC15” with “ACCEL_EXT_CS” but “pixartflow” with “FLOW_CS”

So i changed to those in the fmuv5 hwdef.bat
And still it does not look like it’s working. :frowning: But i don’t have a way to check it for sure…

My Question:
Does anyone know what to call the SPI5 - CS pin? (sorry if the question does not use the right words…)

In skyviper-f412/hwdef.dat
'# SPI2 is optical flow
PB15 SPI2_MOSI SPI2
PB14 SPI2_MISO SPI2
PB13 SPI2_SCK SPI2
PB12 FLOW_CS CS

I would like to know what 3 digits i should put there (in the fmuv5 hwdev.dat) to get to the physical pin that’s at the PH4, SPI port connector pin5, CS1

Second Question,
If i were to get everything working, whats the best way to check it? Is there the same OF.flowX message as with the PX4Flow?


(drew) #5

Hello Nando,

Did you get Flow breakout board of bitcraze works on omnibus F4?? What firmware did you use on the omnibus? Also, could you tell me how did you make the connections? I’m not sure if you connected just the i2c.

I’m trying to do something similar to this and it would be very helpful if you could tell me your results!


(Boom_Boom) #6

I did not spend time on this sins the last post.

You definitely need more than just I2C, I2C is for the VL53 laser only. If you hook it up en set the parameters right it will work on it’s own. I have and it works.

For the Optical flow you need the SPI connection, not possible on any of the hardware without modification. On the Omnibus i would need to desolder the OSD en use it’s SPI port. And change the firmware.
On the PH4 it would only be a firmware modification. But i did not get it to work yet.


(Constantine) #7

@dreww @Nando
Hi,
Today I’ve played a little with bitcraze flow-deck connected to my Omnibus F4 Pro.
I may say that it seems to work without any issue.
What you need is:

  1. Connect you hardware. SPI of the flow-deck to the SPI connector of the Omnibus. I2C of the flow-deck to the I2C of the Omnibus. Connect your magnetometer (I’ve used hmc5883l) to the same I2C bus. Connect the the pins VCOM and VCC on the flow-deck. Connect the power and ground pins of the Omnibus SPI connector to the correspondent pins of the flow-deck

  2. Edit the \libraries\AP_HAL_ChibiOS\hwdef\omnibusf4pro\hwdef.dat file to add the optical flow SPI:
    a) Find the CS pins definitions (line #67) and add a line
    PD2 FLOW_CS CS
    b) Find the SPI Device table and comment the OSD SPI (SPI3 DEVID4). Instead the OSD add the optical flow device:
    SPIDEV pixartflow SPI3 DEVID4 FLOW_CS MODE3 2MHZ 2MHZ
    env DEFINES HAL_HAVE_PIXARTFLOW_SPI
    c) Comment out the OSD defines (line #135)
    #define OSD_ENABLED ENABLED
    #define HAL_OSD_TYPE_DEFAULT 1

  3. Configure and build the copter firmware. Flash it to your Omnibus

  4. Adjust ardupilot parameters:
    EK2_ALT_SOURCE = 1
    EK2_GPS_TYPE = 3
    FLOW_ENABLE = 1
    RNGFND_TYPE = 16
    RNGFND_MAX_CM = 140

That is it.

FYI there is a much friendly to connect optical flow sensor (and smaller) Cheerson CX-OF, it is already supported by ardupilot. The only drawback IMHO is a need of external ToF/lidar distance sensor

Regards and good luck


(Boom_Boom) #8

Thank you!

As soon as i haver time for this I’ll do what you suggested.
Looking forward to it.

I saw the Cheerson CX-OF sensor.

I thought it was not supported, but now I even see a wiki entree, http://ardupilot.org/copter/docs/common-cheerson-cxof.html (this was not there a few months ago).
I ordered one, just in case this SPI way doesn’t work. And with everything i have connected now i woud need a different fc to have a uart to use for this.