Hi all, I need some help,
Can someone write me a simple script to control a servo according to the motor arming status?
What I need is to set the servo number 10 to minimum, lets say 1100us when disarmed and to 1900us when armed.
I know it is a simple code that can be written in a few seconds but I have zero knowledge about coding Lua
Thank you in advance
Kind regards
A great opportunity to learn something new It is not hard to do.
Here is lua scripting documentation , you can debug lua scripts and there are many examples available.
You will need to use the latest firmware or press Ctrl-Q in MissionPlanner
I spent way too much time trying already and thats why I am asking for help on the comunity so, if it is that much easy for you why donât you help me?
Programming is not for me.
Nuno, nĂ€o tenho tempo nem para me coÄar (nĂ€o tenho um teclado portugĂȘs)
Bom dia, muito sinceramente e nĂŁo querendo ser rude, nĂŁo entendi a sua intervenção ao estilo âeu sei mas nĂŁo digo, descobre por tiâ ainda mais num grupo OpenSource como Ă© este onde o objectivo Ă© entre-ajudaâŠ
EnfimâŠ
Obrigado Ă mesma.
P.S. eu também não tenho teclado portugues, não entendi.
Ă uma comunidate OpenSource onde as pessoas se ajudam mutuamente, sim.
Desculpa lĂĄ se te ofendi.
P.S. NĂŁo tenho teclado protuguĂȘs e como tal nĂŁo consigo escrever c de cedilha.
You can also just set SERVO10_FUNCTION to 29 (LandingGear)
@giantpt, we spoke briefly today in the comments of my YouTube video where you mentioned this post. I gave you the following example as a reply:
function update()
if not arming:is_armed() then
SRV_Channels:set_output_pwm(94, 1100)
end
if arming:is_armed() then
SRV_Channels:set_output_pwm(94, 1900)
end
return update, 100
end
return update()
You said it worked well for you, but Iâll offer this slightly more advanced version that uses pseudo-constant variables instead of âmagic numbersâ and doesnât continuously reset the servo value:
local SERVO_FN = 94
local DISARMED_PWM = 1100
local ARMED_PWM = 1900
local FREQUENCY = 100
function do_disarmed()
if arming:is_armed() then
SRV_Channels:set_output_pwm(SERVO_FN, ARMED_PWM)
return do_armed, FREQUENCY
end
return do_disarmed, FREQUENCY
end
function do_armed()
if not arming:is_armed() then
SRV_Channels:set_output_pwm(SERVO_FN, DISARMED_PWM)
return do_disarmed, FREQUENCY
end
return do_armed, FREQUENCY
end
return do_armed()
(I edited this post a few times with some slight updates to the example script that made it more efficient)
Hi Yuri,
Thank you once again for your time and patience with me on this issue in particular.
You had an exemplar attitude, thats exactly what I consider these forums are forâŠ
Canât thank you enough
Take care & Stay safe