Input and forward STM32 generated MAVlink messages in ArduCopter?

Hi everyone. I’m a newbie for this field.
I have a question that I hope everyone can help me.

Now I am working with T-moto, Esc alpha and pixhawk.
Our goal is to control 8 BLDCs by using alpha ESC through pixhawk. Because we have no clue how to get feedback signals from 8 alpha ESCs directly into pixhawk and pixhawk does not have enough ports for this.
Therefore, we are using microcontroller (stm32f407) to get those feedback signal and send them back to pixhawk by UART in mavlink format. (image is below)
I use Mission Planner to read that data that we send from stm32 and it is OK but it seems that pixhawk doesn’t understand what these data use to control for
.
Should I config some commands in Mission Planner or is it useless to send that data by mavlink? Could you give me some ideas to solve that problem or any alternative method to do that?
Big thanks to you.!
Have a good day!
image

Sorry, you will need to explain why you want to do that and what are you trying to do.

Arducopter will fully understand mavlink with no issues. But you need to provide more details

I have edited the post. I hope that you could understand our problem.

Some people have been talking about converting T-Motor telemetry into something useful for years, and so far no solid outcome. It would be useful if you can do it.
The Alpha ESCs only accept PWM, you use a STM32 to collect data from the ESCs - would it be possible for you to replicate the BLHELI ESC telemetry so the data will be logged normally by ardupilot?
The BLHELI ESC Telem data is transmitted over 1 wire to a UART.

Or convert it to fettec one wire protocol it is simpler than dshot and fully supported in ardupilot

1 Like

I have already tried to use BLHELI ESC telemetry but I haven’t succeeded that in many times, ardupilot didn’t received any messages. I follow data frame as the picture below

Now that I read your updated post above, it might be easier to just tell ArduPilot to forward those specific mavlink messages to the GCS.

Are you generating ESC_TELEMETRY_1_TO_4 and ESC_TELEMETRY_5_TO_8 messages?

Which COMPONENT_ID and SYSTEM_ID are you using in the generated MAVLink messages?
Can you test setting the COMPONENT_ID to MAV_COMP_ID_PERIPHERAL and SYSTEM_ID to the SYSID_THISMAV parameter of your vehicle.

Can you make your existing stm32f407 code public?

Take a look at the code in ardupilot/GCS_Common.cpp at d2693e427648b2af875d15be478c3502cb4e86ff · ArduPilot/ardupilot · GitHub

And especially:

MAVLink_routing

There is documentation on top of that function

And you get some run time debug messages if you activate ROUTING_DEBUG and recompile the code

I went ahead and did the routing code changes on Decode and use ESC_TELEMETRY_X_TO_Y mavlink packets as an AP_ESC_Telem_Backend by amilcarlucas · Pull Request #19668 · ArduPilot/ardupilot · GitHub can you test it?

Here is stm32 code: Tmotor_ESC_8_in_1/main.c at main · TrHVinh/Tmotor_ESC_8_in_1 · GitHub

And the result when we use MissionPlanner to view Mavlink:

I think a better and probably more elegant solution is to wrap your STM32 node into a DroneCAN (UAVCAN) adaptor.

Thanks, for your code.
Can you please answer all my questions, one by one?

yes

COMPONENT_ID: 0 and SYSTEM_ID: 1

SYSTEM_ID in my vehicle is 1 so I change my code SYSTEM_ID: 1 and COMPONENT_ID: 158. In mavlink inspector show us 2 mavlink packet like the image below.

status
In my opinion, if CUBE understand 2 mavlink packet i send, it will show in tab Status. What do you think? @amilcarlucas

No, AFAIK the values displayed in tab status are hardcoded, it will not display new values if they appear.

The test you made show that mavlink packet routing and forwarding is working fine. You get both ArduCopter telemetry and ESC telemetry inside mission Planner at the same time.

Now can you test github PR #19668 to see if the autopilot starts understanding those values?
If it does you can use the RPM values to control the dynamic notch filter!!!

Hi @amilcarlucas, I just have made the test github #19668, and this is the result:


sth_new_1

looks to me like it is working.