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

Relay: add relay output invert function #26568

Merged
merged 1 commit into from
Apr 5, 2024

Conversation

LaneaLucy
Copy link
Contributor

added a option for every relay to invert the output signal.
If enabled, Relay on would be Pin output off and Relay off would be Pin output on.

Copy link
Member

@IamPete1 IamPete1 left a comment

Choose a reason for hiding this comment

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

Can also remove this comment:

// this will need revisiting when we support inversion

It might also be worth adding a sentence to the DEFAULT parameter description to note that the default is also inverted if invert is set. Or I guess we could make the default ignore inversion.

libraries/AP_Relay/AP_Relay.cpp Outdated Show resolved Hide resolved
libraries/AP_Relay/AP_Relay.cpp Outdated Show resolved Hide resolved
@LaneaLucy
Copy link
Contributor Author

It might also be worth adding a sentence to the DEFAULT parameter description to note that the default is also inverted if invert is set.

Isn't it self understanding that invert option inverts the pin output, not the relay state and default option is the relay default state?

@Hwurzburg Hwurzburg added the WikiNeeded needs wiki update label Mar 20, 2024
@@ -65,6 +65,13 @@ const AP_Param::GroupInfo AP_Relay_Params::var_info[] = {
// @User: Standard
AP_GROUPINFO("DEFAULT", 3, AP_Relay_Params, default_state, (float)DefaultState::OFF),

// @Param: INVERT
// @DisplayName: Invert output signal
Copy link
Contributor

Choose a reason for hiding this comment

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

For the display name it's good to have the subsystem appear first. So perhaps start with "Relay"

We should consider naming this parameter "REVERSED" or "REVERSE" to be consistent with the RC_Channel library with a similar function. It's no big deal but one of the keys to naming stuff is not to introduce new words when we have an existing word that will do.

@rmackay9
Copy link
Contributor

Thanks for the contribution!

Could you change the commits to start with "Relay:"? We always try to start commit titles with the subsystem prefixed because it makes it instantly obvious from looking at a commit what part of the system it affects. This makes backporting much easier. .. and just to be clear, I mean the commit title, not the PR title.

@rmackay9 rmackay9 changed the title added relay output invert function Relay: add relay output invert function Mar 21, 2024
Copy link
Contributor

@tridge tridge left a comment

Choose a reason for hiding this comment

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

it would be good to add a comment for the default state param whether this is impacted by the invert flag

@LaneaLucy
Copy link
Contributor Author

LaneaLucy commented Mar 21, 2024

Could you change the commits to start with "Relay:"?

i have no idea how to do it. if i try to do it in gitkraken, it makes a new commit in master...

EDIT: i hope this is right now

@LaneaLucy LaneaLucy force-pushed the relay_output_invert branch from 8b0d99a to 1c0913c Compare March 21, 2024 12:02
@LaneaLucy
Copy link
Contributor Author

btw, someone other could now update the wiki about brushed with relay, because for the L298N Motor Driver there is now no lua script needed anymore. this is also the reason, why i made this PR, because why should i use a lua script for the inversion of the relay outputs, when adding a inversion function to the code only need little change and then you are even free to use every relay output you want without changing lua code...

@tridge tridge force-pushed the relay_output_invert branch from 1c0913c to 2cd684f Compare March 21, 2024 20:37
@tridge
Copy link
Contributor

tridge commented Mar 21, 2024

i've squashed it down to one commit and force pushed

@LaneaLucy
Copy link
Contributor Author

i've squashed it down to one commit and force pushed

I have no idea what this means but does this mean everything is ok now?

@tridge tridge force-pushed the relay_output_invert branch from 2cd684f to b060267 Compare March 21, 2024 21:10
@tridge
Copy link
Contributor

tridge commented Mar 21, 2024

@rmackay9 would you prefer "INVERT" or "INVERTED" to "REVERSED" ?

@rmackay9
Copy link
Contributor

@tridge,

I'd actually prefer we make it REVERSED to be consistent with RC_Channel and SRV_Channel libraries. If we could wind back time, I'd probably make RC_Channel and SRV_Channels use "REVERSE" instread of "REVERSED" but that ship has sailed so let's go with REVERSED for this PR.

@rmackay9
Copy link
Contributor

@LaneaLucy,

Great to hear that AP rover could use the L298N motors without a Lua script. I'd really like to get a wiring diagram and setup instructions into our wiki. I see we have some instructions linked from our wiki here https://ardupilot.org/rover/docs/common-brushed-motors.html but maybe we could replace those with a new page. I could help put that page together I think but I'll need some help from you to confirm it's correct.

@LaneaLucy
Copy link
Contributor Author

@rmackay9 should we discuss this on discord or should I write down it here?

@rmackay9
Copy link
Contributor

@LaneaLucy,

Either place is fine with me. Perhaps discord is a little better because other users may add their comments there as well.

@rmackay9
Copy link
Contributor

Hi @LaneaLucy,

We discussed on the dev call and decided to go with _INVERTED. Sorry for creating the extra work for you.

@tridge
Copy link
Contributor

tridge commented Mar 25, 2024

discussed on the dev call, decided INVERTED is better, I will rework the PR and force push for INVERTED, then mark for merge

@tridge
Copy link
Contributor

tridge commented Mar 26, 2024

updated and marked for merge

@peterbarker peterbarker merged commit 01b0e0c into ArduPilot:master Apr 5, 2024
91 checks passed
@peterbarker
Copy link
Contributor

Merged, thanks!

@LaneaLucy
Copy link
Contributor Author

Nice

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

Successfully merging this pull request may close these issues.

7 participants