Controlling a servo/Outputting a PWM signal on the CF2

Firmware/software/electronics/mechanics
Post Reply
Ace_Archer
Beginner
Posts: 1
Joined: Fri Nov 21, 2014 7:51 pm

Controlling a servo/Outputting a PWM signal on the CF2

Post by Ace_Archer » Tue Apr 21, 2015 6:44 am

Hi all!

Long story short, I'm trying to control a servo (standard 9g) with the crazyflie, specifically moving it into certain positions once it reaches a specified altitude, and I'm wondering how I'd go about outputting the PWM signal from the crazyflie? I know the basic theory behind PWM signals and how they're suppose to work, but my googling hasn't yielded much about how to output the signal using python (or how to on a crazyflie for that matter!).

Thanks, I appreciate any help! :D



tobias
Bitcraze
Posts: 2013
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Controlling a servo/Outputting a PWM signal on the CF2

Post by tobias » Tue Apr 21, 2015 8:49 am

Hi and welcome!

Things aren't as neat as it should yet but you can have a look at the buzzer example and code. It outputs PWM signal on the expansion part for the sound. Should be to hard to use as a base for a servo output.

Veerachart
Member
Posts: 45
Joined: Mon Jan 13, 2014 4:12 am

Re: Controlling a servo/Outputting a PWM signal on the CF2

Post by Veerachart » Mon Feb 08, 2016 8:22 am

Hi,

I would like to know if you have any progress.

I tried adding another motor to the set of motors, using TX2, but the servo does not move so much. Seems the frequency of the PWM that is used to control the thrust uses different frequency (328 kHz) as the normal servo (50 Hz, I guess).

vivekrk44
Beginner
Posts: 7
Joined: Sun Nov 23, 2014 6:17 pm

Re: Controlling a servo/Outputting a PWM signal on the CF2

Post by vivekrk44 » Thu Feb 11, 2016 9:14 am

I would recommend using this tutorial for your code

http://stm32f4-discovery.com/2014/05/st ... -tutorial/

It shows you how to use the timers and set up the PWM signal at a specific frequency and send out a signal of required pulse width

Regards
Vivek

Veerachart
Member
Posts: 45
Joined: Mon Jan 13, 2014 4:12 am

Re: Controlling a servo/Outputting a PWM signal on the CF2

Post by Veerachart » Tue Feb 23, 2016 3:00 am

I finally figured it out that the BRUSHLESS mode works the same as the signal for servo motor, so I just created another motor in BRUSHLESS mode and use this to control the servo.

Post Reply