How to control the PWM signal of the motor directly?

Discussions and questions about the Crazyflie Nano Quadcopter
Post Reply
DarkKnight
Member
Posts: 30
Joined: Tue Jun 15, 2021 10:19 pm

How to control the PWM signal of the motor directly?

Post by DarkKnight »

Hello, I am trying to find a more accurate relation between PWM and thrust, so I build a thrust stand to implement that. Right now I want to collect the datasets about different desired pwms and corresponding thrust data so that I can use polynomial fitting to find the relation, but the problem is that

Q1: how should I generate the desired pwm signals?

Q2: Is there a python interface function so that I can send the desired pwm command on the high-level computer? or I have to write the corresponding code in STM32 in low-level computer?

Q3: Another way I want to try is I want use a arduino(as micro controller) and a motor driver to generate the PWM command and drive the motor, but I don't know what kind of motor driver that I need to use?(I used the L298N a lothttps://www.amazon.com/Qunqi-Controller ... 8191&psc=1, but the drive voltage should be around 5V-35V, which is higher than rated voltage of motor in crazyflie), could you tell me what kind of motor driver that is used on crazyflie 2.1?
tobias
Bitcraze
Posts: 2248
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: How to control the PWM signal of the motor directly?

Post by tobias »

Q1:
You could use parameters to set these and they are called motorPowerSet.

Q2:
You can do this from python. Use the system-id branch as inspiration and this script. The dev-systemId branch has changed the code though so that if motorPowerSet.enable == 2 then motorPowerSet.m1 is set for all motors which might be desirable to have them all change value at the same time. See this file.

Q3:
You don't need to do this, it would just become messy.
Post Reply