Which cpp converts actuator_controls to pwm value?

Hello, when I read the att_control.cpp file, I found that it publishs actuator_controls. But I want to know where the pwm value(900-2100 ? ) generates, so which file converts actuator_controls to pwm value ?

px4io.cpp and px4fmu.cpp seems to do this work, but I cannt find which function do it specifically. Any suggestions will be appreciate!

Have a nice day!

It’s really in px4fmu.cpp and px4io.cpp,the function named pwm_output_set.
It’s call the function named up_pwm_servo_set.

Is this px4io.cpp? https://github.com/PX4/Firmware/blob/master/src/drivers/px4io/px4io.cpp But I cannt find a function named pwm_output_set ?

you can find it in px4fmu.cpp.
main pwm output is in px4iofirmware.

So what work does the above link px4io.cpp do?
And I once read that px4io.cpp is for main out and fmu.cpp is for aux out, is it true?

px4io.cpp in driver is a driver of io board.
It’s regarded as a device of fmu board.
If you want understand how Io board to output pwm,you should read the code in src/modules/px4iofirmware.

So mixer.cpp receives actuator_controls_ and convert it to pwm_value between 900-2100 ?

But a new question, what is the relationship among px4iofirmware(modules), px4io(drivers) and px4fmu(drivers) ?

px4iofirmware if a firmware of io board.
pxio(driver) and px4fmu(driver) is code of fmu board.

Thank you, now I am reading the mixer.cpp in px4iofirmware, but still puzzling, I cannt find where the map function is…

i am considering about this problem. I can not find any link between them. Now, i have actuator control and we need get pwm though mixer. Could you told to us the diagram that it shows how to understand this problem?

Try here:

How can the px4io link to the mixer code? It is very clearly with px4fmu.

That is px4io firmware. It runs on the failsafe processor so it doesn’t get linked to fmu at all. It is built as an image and uploaded to the failsafe.

Fmu has its own output scaling:

This isn’t particularly tidy since you get different behavior depending on the driver. One of my goals is to pull this function into a library instead of having it spread over the drivers.

This implementation also limits the maximum servo output range which sucks if you need more servo travel.

hang on. I might be wrong about that function…

So I was wrong. pwm_limit_calc does all of the scaling to whatever you want.

px4iofirmware also uses this as well as using the fixed scaling. The fixed scaling appears to be only for failsafe mode.

1 Like

Thanks Crashmatt. Now it is clearly with me. I have another question. What is meaning of /drivers/px4io? It seems running as a thread after rcS is performed.