STM32F407 Disco with IMU
« on: December 26, 2016, 08:26:43 pm »
Hi all

I'm trying since day's to bring an STM32F407 Disco board up and running with Librepilot, but withou success :-[.

I took the Sparky 2 Board as wiring example and different senors via SPI ports. I loaded the Sparky 2 firmware in the librepilot library on the STM32F407 and flashed the bu_sparky2.opfw via the rescue function in GC.

Last IMU i was trying was an MPU6000 connected via SPI std pins including CS and INT.

There is no progress, doesn't matter wich Gyro I'm  takeing.

Is there a chance to get this working?


Mateusz

  • *
  • 808
Re: STM32F407 Disco with IMU
« Reply #1 on: December 26, 2016, 09:02:16 pm »
Boards Sparky2, Revolution use STM32F405. The STM32F407 has different pin-out, is different micro-controller, might have different peripherals, memory etc.., so firmware for Sparky2/Revolution will not run on it out the box. Should be possible to port though.

mr_w

  • *
  • 207
    • LibrePilot
Re: STM32F407 Disco with IMU
« Reply #2 on: December 26, 2016, 09:24:03 pm »
Hi siegesa1,

you should use discoveryf4bare target, and work your way from there. I don't think it has any of sensors enabled by default, but since you have MPU with SPI connection, enabling it should be very easy.
Another sensor that is needed in order to not have STAB/ATTI alarms is barometer, although one is not really required for flight itself. You can choose to either attach one of the supported types (like MS5611) over i2c, or work on firmware side to disable dependency on it.

Re: STM32F407 Disco with IMU
« Reply #3 on: December 26, 2016, 09:35:05 pm »
Hi,
nice to see someone fiddling with other kind of hardwares!
I think mr_w suggestion is wise.
another thing to check is whether your board has a prerelase device (marked with "A") which has a problem with the "ART Accelerator" that causes very weird random issues nad faults.
there is a workaround for this. let me know if this is the case and i'll point you to the right changes to do.

Alessio

Re: STM32F407 Disco with IMU
« Reply #4 on: December 27, 2016, 11:13:22 am »
Hi all

Thx for your fast Response..
I went down the road with the discoveryf4bare as suggested by MR-W. :D

Board is dected as Revo and automaticaly connected by the GC.
Where I'm lost is, how to connect the MPU6000?
I would connect it via SPI1 as defined by the Proc STM32F407, but what about the Int and the SC?
What I didn't get was, how do I have to activate it (in the code or GC settings) ???

Would you recommand to use en other IMU?
I have a 10DoF Board GY-801 or GY-91 and GY-88, which one would you recommand?

GY-88 seams to suits best, but just over I2C, isn't it:
HMC5883/43 (compass)
ITG3200 (gyro), MPU6050 (gyro+accel)
BMP085 (baro)
MS5611


cheers an thx

mr_w

  • *
  • 207
    • LibrePilot
Re: STM32F407 Disco with IMU
« Reply #5 on: December 27, 2016, 03:17:53 pm »
I would suggest to go with SPI as that is fastest and easiest way.

Take a look at flight/target/boards/discoveryf4bare/board_hw_defs.c around line 238, there is pios_spi_gyro_cfg data which describes SPI connection for gyro. You will see all the details about physical connection.

SCLK: PA5
MISO: PA6
MOSI: PA7
CS: PA4

And then, you can try enabling it in flight/targets/boards/discoveryf4bare/firmware/inc/pios_config.h by uncommenting lines with
PIOS_INCLUDE_MPU6000
and PIOS_MPU6000_ACCEL

There is also change required in discoveryf4bare/firmware/pios_board.c
after PIOS_MPU6000_CONFIG_Configure()
there is missing call to
PIOS_MPU6000_Register()

Hmm, that should be enough for you to get started :) I hope.


Re: STM32F407 Disco with IMU
« Reply #6 on: December 27, 2016, 03:46:18 pm »
Hi mr_w

Great, thx for that detailed instruction.
I found the part with the GPIO's already, but you confirmt I was onthe right track ;).

The part with the config was new to me, so I will have try.


Thx again, your help is really appreciated

Re: STM32F407 Disco with IMU
« Reply #7 on: December 27, 2016, 07:27:23 pm »
Hi mr_w

INT = PC4, right?
Somehow it it will not be regocnized...

Not sure but do i need an addional sensor in this configuration?

cheers

mr_w

  • *
  • 207
    • LibrePilot
Re: STM32F407 Disco with IMU
« Reply #8 on: December 27, 2016, 10:22:27 pm »
If it works, you will have fast blinking led while (detected) gyro calibrates, but you will still have ATTI and STAB alarms in GCS without barometer. That is next thing to fix :) But first lets get gyro&acc working.

Yes, you are right about PC4.

Can you push your current changes back to your bitbucket or github repository?

Re: STM32F407 Disco with IMU
« Reply #9 on: December 28, 2016, 08:41:42 pm »
Hi all

A brief status update:
I've changed the entries in the two recommanded files and compiled those.

pios_config.h uncommended
PIOS_INCLUDE_MPU6000
PIOS_MPU6000_ACCEL

pios_board.c
after PIOS_MPU6000_CONFIG_Configure();
i've added a new line with PIOS_MPU6000_Register();

I've connected the MPU6000 over the following PINs
SCLK: PA5
MISO: PA6
MOSI: PA7
CS: PA4
INT: PC4

and  the  HMC5883(compass address:0x1E) over IIC
SCL: PB8
SDA: PB9

USB via STM32-USB Slave PA11:USB_DM / PA12:USB_DP and via PA10: RXD1 / PA09: TXD1.
The STM32F4 Discovery board will be detected, but no IMU's and no Status detection.

Is there a way to connect a consol to see some alerts or Messages or test commands?

Please excauses me if I answer with some delay, since I'm away for the next day's .

mr_w

  • *
  • 207
    • LibrePilot
Re: STM32F407 Disco with IMU
« Reply #10 on: December 29, 2016, 12:49:09 am »
Regarding the USB connection - discovery board has two usb connectors, one for stlink and another for F407 itself. I keep both cables connected with my computer all the time. The stlink connector (i think this is usb mini) provides interface for openocd & gdb for debugging, and other usb (micro) is connection which is used by GCS.

How are the LEDs blinking?