Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Servo support #1340

Merged
merged 16 commits into from
Jan 31, 2024
Merged

Servo support #1340

merged 16 commits into from
Jan 31, 2024

Conversation

matejkarasek
Copy link
Contributor

This PR adds support for a single extra servo (on top of the existing 4 motors/actuators used in the power distribution).
Its position is controlled via parameter "servo.servoAngle".
It is implemented as a deck, which can be forced in the defconfig as:

CONFIG_DECK_FORCE="bcServo"
CONFIG_DECK_SERVO=y

The servo is meant to be powered from VCOM on the Crazyflie/Crazyflie Bolt (mind the current limitations) or by an external 5V supply, e.g. from an ESC when using the CrazyflieBigQuad deck.

The default signal pin is TX2, but can also be configured to RX2, IO1, IO2, IO3 or MOSI via following config:

CONFIG_DECK_SERVO_USE_RX2=y

The servo signal wire can be connected directly, or via the BigQuad deck (where servo compatible connectors are already available)

@matejkarasek
Copy link
Contributor Author

matejkarasek commented Jan 10, 2024

Builds on top of what was shared in this discussion: https://github.com/orgs/bitcraze/discussions/1005

@knmcguire
Copy link
Member

Hi! That's a great feature! We will need to find some time to review this and the coming weeks are a bit busy for us. Hopefully we will get to it soon!

Copy link
Member

@tobbeanton tobbeanton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks and very good contribution. I like that it has the same structure as the motor driver and that it is separated.

src/deck/drivers/src/servo.c Outdated Show resolved Hide resolved
@knmcguire
Copy link
Member

hi @matejkarasek, we'd like to test this out before merging so we need to find a bit of time somewhere, hopefully in the next few weeks

@matejkarasek
Copy link
Contributor Author

Thanks, yes, that makes sense!

Copy link
Member

@knmcguire knmcguire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested it with a servo with a crazyflie+breakout deck). I'm not sure if it is going correctly, since when I set an angle higher or lower than idle, it seem to not set to go to that position but keeps rotating. It is supposed to do that, or was it supposed to just go to an angle and stay there? Probably I'll need to adjust the other parameters but it is difficult to get the meaning of them.

src/deck/drivers/src/servo.c Show resolved Hide resolved
src/deck/drivers/src/Kconfig Show resolved Hide resolved
@matejkarasek
Copy link
Contributor Author

I've tested it with a servo with a crazyflie+breakout deck). I'm not sure if it is going correctly, since when I set an angle higher or lower than idle, it seem to not set to go to that position but keeps rotating. It is supposed to do that, or was it supposed to just go to an angle and stay there? Probably I'll need to adjust the other parameters but it is difficult to get the meaning of them.

The servo is supposed to go to the angle that you specify. How did you connect it? I now have a CF2.1 with a prototyping deck, and connected + to VCOM, - to GND and signal to PA2/TX2 and this works fine. My cf2_defconfig is:

CONFIG_PLATFORM_CF2=y

CONFIG_DECK_FORCE="bcServo"
CONFIG_DECK_SERVO=y

The default settings should work for most standard servos, I will add the description for the params, sorry, forgot to do that...

@knmcguire
Copy link
Member

I know what went wrong. I had a servo that was configured for rate control, so that is why it didn't work as expected. I now tried a different one and it worked like a charm!

So if you could add the doc to the parameters and change the initialization parameter to the deck group then it would be ready to merge

@matejkarasek
Copy link
Contributor Author

Ah ok, well this assumes servo in position mode :)

All the requested changes should be in the latest commit

@knmcguire
Copy link
Member

It includes all the important changes so I'll go ahead and merge it. Thanks @matejkarasek !

@knmcguire knmcguire merged commit aefa1d6 into bitcraze:master Jan 31, 2024
24 checks passed
@knmcguire
Copy link
Member

If you'd like, you can make a small mention in the show&tell in discussion to notify people on this feature :) https://github.com/orgs/bitcraze/discussions/categories/show-and-tell

@matejkarasek
Copy link
Contributor Author

Awesome, thanks! Will post it there

@matejkarasek
Copy link
Contributor Author

The functionality is described here: https://github.com/orgs/bitcraze/discussions/1208

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants