Servers by jDrones

Turning light On/Off with MP and a PixRacer

Hello! I have the following AutoPilot build:
PixRacer (6 Servo pins) with a Mauch Power Module. Servo 1 and 3 are used for controlling to motors (differential Steering).
I would like to turn a 12V light On/Off via Missionplaner. For this I have a Mosfet Relay which can be triggered with a PWM signal. https://www.aliexpress.com/item/32785122281.html?spm=a2g0s.9042311.0.0.27424c4dZgC01z

The idea is to hook it up to Servo 4 and send a PWM signal when I want to turn it on (the Mosfet Relay then lets the 12V through to the light).
Here is my question:
What Parameters do I need to set on ArduRover 3.5.2 in order to make this happen and how do I actually control it via MP? I also use a Logitech Joystick, so I would like to able to configure one of the buttons to turn it off on.
Thank you for your help!

you can set PWM outputs 5 - 14 directly from MP’s servo / relay tab, just make sure you don’t have the respective output assigned to any other function (check respective SERVOn_FUNCTION = 0) when using rover 3.5.2. on rover 4.x the DO_SET_SERVO command will work no matter what function as well if FUNCTION 1 (= RCPassThru) is assigned to the respective servo (thanks @hwurzburg for pointing this out). this likely is the easiest way to switch the light and requires zero additional setup:

to use your joystick for switching, you might opt to assign one of its physical buttons or switches to an RC input channel and set the respective servo output to that RCIN. this example shows the joystick’s Slider 2 assigned to RC7:

then assign your SERVOn output of choice to RCIN7. this example uses SERVO5_FUNCTION set to 57:

a third option is to assign a joystick button to trigger a DO_SET_SERVO command. honestly i’m not 100% familiar with this feature, but afaik by its nature this sets the output to a respective PWM value just once if the button is pushed. it will not go back to the initial value if the button is released unless another DO_SET_SERVO command is triggered to set it back. so you’ll likely need two buttons here, one to set the PWM high, another to set it low again. this example defines the joystick’s push button 1 to set SERVO5 PWM to 1900. button 2 is used to set it back to 1100:

Thank you Four-Fifty for the quick answer! will try it tonight!

@vierfuffzig the wiki PR you saw is not confirmed as to working on all function assignments by me…we need Randy to comment…I had assumed it does when I created the PR for 4.0, since 4.0 made a point to allow it to work on outputs that had a rc passthru assigned,and these did not work before but do now… hence the assumption that everything was working…

if its a PR, its not gospel yet :wink:

but its easy to verify in SITL or bench

@hwurzburg i did test and confirmed on actual hardware running rover 3.5.2 vs 4.x that it only works with SERVOn_FUNCTION set to passthrough. when set to other functions, the DO_SET_SERVO command will return “ServoRelayEvent: Channel n is already in use”.
actually, i didn‘t expect the DO_SET_SERVO command to only work in previous versions with no SERVO_FUNCTION assigned.
maybe randy will look into this too if time permits.

EDIT: the more i read the code and think about possible uses, the more i think i understand why the command is restricted to unused or passthrough functions…

Hi basti @vierfuffzig,
I am testing for some hours now but I can not get this to work as you described.
I am running Rover 3.5.2 and have the servo5_function set to 1 -> passthrough. However, I only get an error message when I try to run the do_set_servo command. channel already in use. However if I disable the Servo5 i can set it perfectly.
Is there something else I missed? I need to be able to controll the servo via the rc as well as the onboard computer in guided mode.

The AP_ServoRelayEvents.cpp code confirms your statement but the reality does not. Could it be that 3.5.2 does have a different codebase than this: https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_ServoRelayEvents/AP_ServoRelayEvents.cpp

Thanks for the help!
Danke

@Robert_Driller sorry, maybe editing my above post was somewhat confusing, but the behaviour you see is what i tried to describe:

  • in pre 4.0 versions (3.5.x) you‘ll need to set the respective SERVOn_FUNCTION to 0 for using the do_set_servo command on that output

  • rover 4.x introduces support of the do_set_ command on outputs that use passthrough too.

if you need both rc passthrough and do_set_servo, you‘ll need to use rover 4.x

Got it, I will try the beta then.
Thanks!

Servers by jDrones