Hello,
I am trying to implement the optical flow based control on mindracer. The flow sensor I would like to use is OMW3091. Most of this kind sensor are using SPI. I see that only J7 has the SPI interface. I am wondering what is the type of J7 connector? Could you give me a link for this connector? And do you have any experience with the PMW3901 flow sensor interface on J7? Is it possible? If it doesn't work, I even won't try. Thanks!
mindrace J7 connector type and using PMW3901 optical flow on it
- Edited
I assume 'OMW3091' is a typo of "PMW3901"?
Which flight stack are you using, PX4 or ArduPilot?
J7 SPI bus is intended only for external IMU connection, not for optical flow. Instead, you should find 'U1' on board for all needed SPI pins exposed as pads. You can solder cables directly on them.
The pin definition can be found in Mindracer schematic:
- Edited
rolandash
Hi, Thanks for your quick reply. Yes, it should be PMW3901. I soldered them together as shown in the figure(Hope my connection is correct referring to https://docs.px4.io/master/en/sensor/pmw3901.html). And changed the px4 firmware EKF2_AID_MASK = 2 (optical flow). But there is no optical flow sensor detected in MavLink Inspector in QGC. I did this on a pixhawk 4 and it could show the detection of PMW3901.
Another difference I found between pixhawk 4 and mindracer is that there are two optical flow options in the parameters "px4flow" and "PMW3901" in pixhawk 4 while there is only "px4flow" in mindracer, both with the lastest 1.10.1 firmware.
OK so you are running PX4.
In PX4 PMW3901's driver is not complete to support all flight controllers. You need to add few lines in 3901's driver source code to configure the correct SPI bus. Do you know how to do that? I can provide you some guide if you can compile and upload px4 firmware.
rolandash
Hi, I don't have any experience building px4. But I assume everything is detailed https://dev.px4.io/v1.8.2/en/setup/building_px4.html
So basically using a ubuntu machine to modify the code and do make, plug in the mindracer, and upload at the end (I assume it can detect the mindracer automatically).
Could you teach me how to edit the 3901 driver to make it work? Thanks.
rolandash
Or I guess I can only modify the code and upload the firmware in QGC using the "custom firmware file" option?
Yes, it is automatic, and both way should work.
I need to find some time to test it on my side first and then show you the steps, hopefully in next 3~4 days. Will let you know when done.
rolandash
Thank you very much!
rolandash
Hello, I have one more question. Will the mindracer work with TFmini rangerfinder?
Yes. Just find a free UART port for it.
- Edited
OK here are the steps to enable PMW3901 on MindPX/Mindracer, pretty simple actually.
Assume you have cloned PX4 master source code into your local.
Step 1
Locate file "boards/airmind/mindpx-v2/src/board_config.h", use any text editor to find the line:
#define PX4_SPI_BUS_BARO PX4_SPI_BUS_SENSORS
and add the below line right under it:
#define PX4_SPI_BUS_EXTERNAL PX4_SPI_BUS_EXT
then find the line:
#define PX4_SPIDEV_EXT0 PX4_MK_SPI_SEL(PX4_SPI_BUS_EXT, 1)
and add this line right under it:
#define PX4_SPIDEV_EXTERNAL PX4_SPIDEV_EXT0
Step 2
Locate file "boards/airmind/mindpx-v2/default.cmake", find the line:
optical_flow/px4flow
comment out this line by add '#' at the beginning of it:
#optical_flow/px4flow
then find the line before:
#optical_flow
enable this line by remove the '#' at the beginning:
optical_flow
Step 3
Compile and upload the new firmware:
make airmind_mindpx-v2_default upload
Connect pmw3901 and connect the mindracer to QGC.
Enable EKF2_AID_MASK, and SENS_EN_PMW3901 parameter in QGC and reboot.
If everything are executed correctly, You should be able to see optical flow in MAVLink inspector now.
rolandash Hello, I didn't find the two lines about SPI configuration in board_config.h Are you able to double check it for me? Thanks.
- Edited
which px4 version have you downloaded ? 1.10.1?
rolandash I found it. Just used a wrong version firmware.
OK.
Will be even simpler if you are using latest master source. you will only need to start from step 2.
rolandash It is working. Thanks!
- Edited
rolandash Hello,
Unfortunately I got the mindracer broken. The soldering pad on spi_CS was taken off. At first it cannot detect the PMW3901, then I tried to checked if the wires are contacting each other or not. Then I took the soldering pad off. Is there a way I can get this fixed? Otherwise, the mindracer is useless for me just for this small pad.
Thanks
- Edited
Well there is another way but really testing your soldering skill: you can jump wire directly from CPU pin 88 (PD7), however quite few people can make it.
We do not have this kind of service in US for now so I am afraid you have to on your own risk. Would be simpler to just get a replacement.
rolandash Thanks for your reply. Fortunately, I saw the wire, very thin. And solder them together. And glued that part. Hope they can stand for at least 1 month.
I do not have much experience about 3901. I use px4flow before and that was quite sometime ago so I try to recall some details.
To auto take off the drone needs to get sort of position lock first, either from a GPS or optitrack, or from a flow device. So if you can not take off that usually means the position lock is not available yet at that moment. That can be of many different reasons. But most commonly a flow device need to meet some external conditions to lock so if one of them fail it will just not working.
Regarding px4flow one of the common reasons is not enough flow quality. Usually when on the ground the flow can not reach enough quality to lock due to it requires some distance to the ground to get focused images, and when on ground the lens of flow is just too close to the floor. So the solution is to mount longer landing legs to the drone so the flow have proper distance to the floor as it needs.
Not sure it is the same reason on 3901 but I guess could be something similar like this. Check the locking conditions of 3901 and distance sensors and make sure they working properly before issuing the takeoff command.