How to obtain thrust from PWM

Firmware/software/electronics/mechanics
Post Reply
Max_Kemmeren
Beginner
Posts: 17
Joined: Wed Jan 20, 2021 4:03 pm

How to obtain thrust from PWM

Post by Max_Kemmeren »

Dear all,

I am developing a controller based of the INDI such that the crazyflie will be able to fly close to the ceiling or other flight boundaries (For my MsC thesis). For this I now need an estimate of the thrust that will be produced under a certain PWM signal.

What I now got is a logging script logging the following: Accelerometer data (acc.z), motor data (motor.m1) and motor pwm data (pwm.m1_PWM). But i do not understand all of this data.

For the accelerometer the value equals 1 during hover, this seems logical as it only feels the gravitational acceleration which is 1g, if the coordinate frame has z pointing downwards, is this correct?

Then for both the motor and pwm data the values range between 0 and 65536. What I get from the firmware code (motors.c) is that the pwm.m1_pwm data is the pwm signal but compensated for the battery voltage, am I correct? And my guess is that the motor.m1 data is the pwm signal not compensated for battery voltage, correct?

Lastly is there an estimated formula to change the 0-65536 range to thrust in newton? I found this page (https://www.bitcraze.io/2015/02/measuri ... pm-part-3/) but the graph with PWM to thrust uses different values for the PWM.

Thanks in advance for helping.

Greetings
Max Kemmeren
whoenig
Expert
Posts: 377
Joined: Mon Oct 27, 2014 2:55 am

Re: How to obtain thrust from PWM

Post by whoenig »

All your guesses are correct!

For the last one (battery voltage compensation), this is just an approximation and not necessarily up-to-date with the current hardware. You can find a better mapping in Table 1, https://arxiv.org/pdf/2012.05457.pdf, which was obtained from a force stand. We are planning to integrate this in the official firmware, such that a controller could just output force and torque in SI units, and the rest is handled automatically in the power distribution. Would that be useful for your use-case?
Max_Kemmeren
Beginner
Posts: 17
Joined: Wed Jan 20, 2021 4:03 pm

Re: How to obtain thrust from PWM

Post by Max_Kemmeren »

Thanks for the answer.

What I need for my controller is the ratio between command applied (thrust command) and the actual measured thrust. For now I wanted to do this in the following manner. Using the accelerometer data (z-axis), and then using the simple relationship f=m*a to gather measured thrust. One thing what is the axis system in which the acceleration measurements are logged? Is it body frame with z-axis pointing down?

To get the commanded thrust I was looking into the command send to the motors and convert that to the thrust that is expected from that command. So it would be helpful if I either got a relationship for that or what you say a thrust command can be given to the drone instead of method which is implemented now.

If you are going to implement it what is the planning for it?

Greetings
Max Kemmeren
whoenig
Expert
Posts: 377
Joined: Mon Oct 27, 2014 2:55 am

Re: How to obtain thrust from PWM

Post by whoenig »

The accelerometer is in the body frame using a right-handed coordinate system with z-axis pointing up. You can also test this pretty easily if you use the CFClient and log the "acc.{x,y,z}" variables and visualize them in the Plotter tab. This signal tends to be pretty noisy and you will have much better data if you use a CF 2.1 over a CF 2.0.

For the second part (obtaining commanded thrust), you can simply use psi_1 in the paper that I listed earlier ("small" quadrotor). You will need as input the normalized PWM (i.e., PWM / 65536) and normalized battery voltage (i.e., voltage / 4.2). This equation will output the force of a single motor in grams, so you'll need to convert it to N or any other unit you use. To obtain the total thrust, repeat the procedure for each motor.

I have a prototype for the SI-unit based power distribution, but no concrete timeline on when this will be clean enough to be in the official master branch. From your description, it sounds like you might not need it for your purpose, though?
Max_Kemmeren
Beginner
Posts: 17
Joined: Wed Jan 20, 2021 4:03 pm

Re: How to obtain thrust from PWM

Post by Max_Kemmeren »

Thanks!!!

Yes I have the crazyflie 2.1.

Ah I see the explanation of the formula is few pages later (read past it, so was not sure what the formula meant).

No if this works I will not be needing it.

Thanks a lot for the quick answers it really helped me!

Greetings
Max
Max_Kemmeren
Beginner
Posts: 17
Joined: Wed Jan 20, 2021 4:03 pm

Re: How to obtain thrust from PWM

Post by Max_Kemmeren »

Hi

I have a question. I have calculated the thrust via the formula provided in the paper and the signal logging of pwm.m1_pwm (the motor pwm compensated for battery voltage). This is the blue line seen in the graph. The orange line is using the accelerometer data from the body z-axis and uses f=m*a to calculate the thrust.

What can be noticed is that there is an offset between the lines, this offset seems somewhat constant. What could cause this? As during hover I expect the engines to produce the thrust equal to 1g of acceleration. (and thus the lines needing to be almost equal).

The graph shows force in Newton on the y-axis and time on the x-axis. The hover flight starts around 4 seconds and lasts 5 seconds.
Attachments
Screenshot from 2021-04-01 13-55-57.png
whoenig
Expert
Posts: 377
Joined: Mon Oct 27, 2014 2:55 am

Re: How to obtain thrust from PWM

Post by whoenig »

I can think of multiple reasons:

1. Unbalanced rotors, i.e., during hover your PWM is actually not the same for all motors. You can look at m1-m4 and apply the transformation to each of them.
2. Numerical issues. The paper only shows 2 digits. Here are the full parameters:

Code: Select all

C_00 = 11.093358483549203
C_10 = -39.08104165843915
C_01 = -9.525647087583181
C_20 = 20.573302305476638
C_11 = 38.42885066644033
3. Worn out motors/propellers. I haven't really seen this in practice, but the data provided in the paper was only checked with 3 different Crazyflies (& different batteries). I think the only way to address this, would be to build a force stand. We are in the process of building one at Bitcraze, which is an improved version of the one that I built for the paper cited earlier. You can find some preliminary documentation and analysis scripts at https://github.com/bitcraze/crazyflie-f ... /README.md.
Post Reply