Hi everyone, first off I just want to say that Ardupilot and the community around it is super impressive, and I’m extremely grateful to everyone here actively answering questions. I’m new to Ardupilot but I’ve been able to learn and accomplish so much in just a few months.
Unfortunately, I’ve run into the first roadblock I haven’t been able to resolve on my own. I’m flying a Mateksys H743 Slim V3 and I’m trying to control a power switchboard (from Amazon) via a three position switch on my RC.
To do this I’ve set S7, 8 and 9 as GPIOs, and I’ve written a Lua script to toggle between them (pin_switch.lua (967 Bytes)). Now this detects and reads the PWM signal from the RC channel correctly, I can see the values changing in Messages as I flip the switch, but the pins aren’t actually getting toggled. They each read 0V no matter the position. For whatever reason, the only way I can get these to work is by enabling and assigning a relay for each. I’ve set RELAY2/3/4_FUNCTION to Relay (1), and then for RELAY2/3/4_PIN I set the respective GPIO pin numbers (56/57/58). I don’t actually have the relays controlled by anything and I’m not triggering them in any way, but by doing this suddenly I’m getting my 3.3V as I toggle between the pins.
So my question is: why is this the case? Is this intended behaviour, and is there a way to accomplish the same thing without associating relay pins? This would be fine if there were more relays, but there’s only the six as far as I can tell and that won’t be enough for everything else I want to do.
Would really appreciate some help on this one! Thanks.
I did try that and was getting 0.33V high and 0.17V low, that explains it! So is GPIO generally not used then? This whole thing with the relays still seems weird to me, hoping someone can figure out what’s going on there.
I see, well thanks so much for the clarification! How do I adjust the PWM duty cycle like you mentioned? Can’t find any documentation or parameters for that.
You are conflating RC protocol with traditional duty cycle PWM. In Copter firmware, I’m not sure we have any options to output duty cycle based PWM. I’ll have to do a little digging to confirm that suspicion.
Well the thing is I’m not trying to actuate a servo which is why I was trying to use GPIO in the first place. I’m going to be replacing the switchboard I mentioned in my post with a custom MOSFET switch and I’m not sure if it’ll work with RC/PWM, but I suppose the only way to know for sure is by trying!
HI Yuri, sorry to resurrect the thread but I’m still trying to solve this on my end. If there is no way to change the RC PWM pulse width on copter, then is there a way to use GPIO on servo pins without associating a relay? If there were more than six relays I could make do, but that quantity seems like a hard limitation based on my research.
Thank you so much for the fast reply , you have no idea how much that means after struggling with this for so long. Couple questions:
2 - By GPIO bindings do you mean GPIO:write()? That was what I was using originally, and it didn’t work without assigning relays to the servo pins I was using
3 - I thought Yuri was saying you couldn’t set PWM values other than 1000 and 2000us for copter? If this works this is huge! Will try this later today
I don’t think you need to assign relay outputs, -1 (GPIO) should work too.
PWM Motors are treated differently as all get the same range unless you select appropriate special output mode that tells the FC to use SERVOxx_MIN/MAX.
I’m just a little baby don’t yell at me….
Using SRV_Channels:set_output_pwm_chan() to 20000/0us for high/low respectively did the trick!! I can’t thank you guys enough, officially solved! Strangely I was able to get GPIO to work partially as well, but I think there are some timer group caveats that prevent all the pins I need from toggling correctly. Thank you again, hope both sides of your pillows are cold tonight