rizacelik / STM32F411CEU6_INAV_Firmware

STM32F411CEU6 Board Firmware
122 stars 32 forks source link

Help to build Weact H743 firmware. #49

Open Lynklee321 opened 2 months ago

Lynklee321 commented 2 months ago

I am getting acquainted with inav on the H743 circuit board from weact, and am having problems receiving gyro (BMI160). I tried with the servo on motor 1 with the default settings and the servo vibrates and gets hot but can still rotate. So I think I have a problem with the HSE. I researched and corrected this section in the Cmakelist.txt file but it did not fix the problem (target_stm32h743xi(H743 HSE_MHZ 25).

rizacelik commented 2 months ago

Let's compress the configuration files and put them here. You need to look at the file.

Lynklee321 commented 2 months ago

For the configuration, I used FOXEERH743 as a reference.

Lynklee321 commented 2 months ago

target.txt

rizacelik commented 2 months ago

https://github.com/WeActStudio/MiniSTM32H7xx/blob/master/HDK/STM32H7xx%20SchDoc%20V11.pdf There is a board diagram at this address. Check if the pins comply with the diagram in the configuration file you are using by looking at this diagram. If there are pins used, remove them from the configuration file. If there is a pin used in the schematic and you used it for another function in the configuration file, your compilation will be problematic. Since I don't have much time, I can't review them one by one, but you can do it.

rizacelik commented 2 months ago

You can use LCD and Camera pins in this diagram. Problems will occur with other pins used for other purposes in the schematic. Examine and configure the pins in your file accordingly. Too many pins on this board are used for other purposes. Frankly, there are very few pins left.

Lynklee321 commented 2 months ago

I checked the pins for duplicates, basically I just used spi1 or 4 to check the gyro to see if they work or not.

rizacelik commented 2 months ago

Use these pins for SPI1 image

Lynklee321 commented 2 months ago

Does it have a problem with the flash on the circuit?

Lynklee321 commented 2 months ago

image

rizacelik commented 2 months ago

The top part of the target.h file should look like this.

#pragma once

#define TARGET_BOARD_IDENTIFIER "F743"
#define USBD_PRODUCT_STRING "FOXEERH743"

#define USE_TARGET_CONFIG

#define LED0 PE3

// #define BEEPER PD2
// #define BEEPER_INVERTED

// *************** SPI1 IMU0 MPU6000 ****************
#define USE_SPI
#define USE_SPI_DEVICE_1
#define SPI1_SCK_PIN            PB3
#define SPI1_MISO_PIN           PB4
#define SPI1_MOSI_PIN           PD7

#define USE_IMU_MPU6000
#define IMU_MPU6000_ALIGN CW180_DEG
#define MPU6000_SPI_BUS BUS_SPI1
#define MPU6000_CS_PIN PD6

#define USE_IMU_BMI270
#define IMU_BMI270_ALIGN CW180_DEG
#define BMI270_SPI_BUS BUS_SPI1
#define BMI270_CS_PIN PD6

Your target.c file should be like this

#include <stdint.h>

#include "platform.h"

#include "drivers/bus.h"
#include "drivers/io.h"
#include "drivers/pwm_mapping.h"
#include "drivers/timer.h"
#include "drivers/pinio.h"
#include "drivers/sensor.h"

timerHardware_t timerHardware[] = {

    DEF_TIM(TIM3, CH2, PB5,     TIM_USE_OUTPUT_AUTO, 0, 1),   // S1
    DEF_TIM(TIM3, CH3, PB0,     TIM_USE_OUTPUT_AUTO, 0, 2),   // S2
    DEF_TIM(TIM3, CH4, PB1,     TIM_USE_OUTPUT_AUTO, 0, 3),   // S3

    DEF_TIM(TIM15, CH1, PE5,    TIM_USE_OUTPUT_AUTO, 0, 0),   // S4

    DEF_TIM(TIM1,  CH1, PA8,  TIM_USE_LED, 0, 9),    // LED_2812
};

const int timerHardwareCount = sizeof(timerHardware) / sizeof(timerHardware[0]);

The pins of the IMU sensor have changed. Some of the motor pins were removed. Test it by compiling it and see the result.

rizacelik commented 2 months ago

Delete the config.c file, do not use it.

rizacelik commented 2 months ago

pin references here. The schema you sent is the hardware schema.

image

Lynklee321 commented 2 months ago

It still doesn't solve the problem, I think it is necessary to find out the reason why the servo vibrates when not controlled, perhaps the signal is disturbed causing the mcu to not be able to detect the gyro.

rizacelik commented 2 months ago

My advice to you is that if you have modules such as MPU9250 or MPU6000, MPU6500, you should test it with one of them. If there is a problem with these modules, then we can say that there is a hardware problem with the MCU. That's the only way to find out.

Also change your servo. It may also be caused by the servo. If you are using ESC, it may also be related to ESC. These are my assumptions.

SyberMafia commented 2 months ago

Hi Lynklee321, The internal crystal of your card is 48MHZ. In this way, the signal is distorted. Remove the target_stm32h743xi(H743 HSE_MHZ 25) "HSE_MHZ 25" section from here. correct -> target_stm32h743xi(H743) - replace and recompile. The STM32F411 cards we use are available in 2 types. 8Mhz and 25MHZ crystal. Since our current cards are 25MHZ, we set it this way. There is no need for such a setting for the card you are using. If your problem persists, you need to test your servo with another card or try another servo.

Lynklee321 commented 2 months ago

My advice to you is that if you have modules such as MPU9250 or MPU6000, MPU6500, you should test it with one of them. If there is a problem with these modules, then we can say that there is a hardware problem with the MCU. That's the only way to find out.

Also change your servo. It may also be caused by the servo. If you are using ESC, it may also be related to ESC. These are my assumptions.

i also tried with mpu 6500

Lynklee321 commented 2 months ago

Hi Lynklee321, The internal crystal of your card is 48MHZ. In this way, the signal is distorted. Remove the target_stm32h743xi(H743 HSE_MHZ 25) "HSE_MHZ 25" section from here. correct -> target_stm32h743xi(H743) - replace and recompile. The STM32F411 cards we use are available in 2 types. 8Mhz and 25MHZ crystal. Since our current cards are 25MHZ, we set it this way. There is no need for such a setting for the card you are using. If your problem persists, you need to test your servo with another card or try another servo.

When I install with 25mhz, in the status tab it shows that the mcu is running at 500Mhz, so is there an error or not? in the circuit diagram and when looking at the actual circuit I see that there is an external 25mhz crystal.

SyberMafia commented 2 months ago

When I install with 25mhz, in the status tab it shows that the mcu is running at 500Mhz, so is there an error or not? in the circuit diagram and when looking at the actual circuit I see that there is an external 25mhz crystal.

You are right, there is a 25 MHZ crystal available externally. Operating Frequency appears to be Max 480 MHZ. I looked at all the settings files created with the STM32H743. I have not come across a configuration file that uses 25mhz other than F4 serial cards. You cannot plug a servo into a channel configured for ESC. Since it is configured according to Dshot, its operating frequencies are different. While the servo is driven with 50hz PWM, Dshot gives an output between 300 - 600 Hz for ESC. Ekran görüntüsü 2024-04-14 090056 Could you try adjusting the esc and servo outputs like this to test them? I can't think of anything else right now.

Lynklee321 commented 2 months ago

When I install with 25mhz, in the status tab it shows that the mcu is running at 500Mhz, so is there an error or not? in the circuit diagram and when looking at the actual circuit I see that there is an external 25mhz crystal.

You are right, there is a 25 MHZ crystal available externally. Operating Frequency appears to be Max 480 MHZ. I looked at all the settings files created with the STM32H743. I have not come across a configuration file that uses 25mhz other than F4 serial cards. You cannot plug a servo into a channel configured for ESC. Since it is configured according to Dshot, its operating frequencies are different. While the servo is driven with 50hz PWM, Dshot gives an output between 300 - 600 Hz for ESC. Ekran görüntüsü 2024-04-14 090056 Could you try adjusting the esc and servo outputs like this to test them? I can't think of anything else right now.

I know that, I also tried switching to plane mode to test sevor but there was no difference

rizacelik commented 2 months ago

What's the screenshot of your Plane configuration's Mixer settings? There is more than one servos in the plane. Is this one of the servos? Or in all of them? have the same problem.

Lynklee321 commented 2 months ago

Haahah my bad, I tried everything from changing the 8mhz quartz oscillator, removing the qspi flash. Ultimately my servo failed. As for the motor, it has been resolved. As for the gyro, nothing has changed yet. If you don't mind, can you build the fw for me with a frequency of 8mhz (defaut) with the taget file as above. Thanks for your help.

rizacelik commented 2 months ago

There is a 25mhz crystal on the board. Are you saying you changed it to 8MHZ? image

Lynklee321 commented 2 months ago

There is a 25mhz crystal on the board. Are you saying you changed it to 8MHZ? image

yes, Heat torch it out and replace it with 8mhz

rizacelik commented 2 months ago

Didn't you make the previous compilations? You can compile this yourself.