I’m making an experimental aircraft using the stock PX4 multicopter code. However, the ESCs I’m using are reversible, i.e. PWM 1500µs is stopped, 2000µs is full up and 1000µs is full reverse. In order to make this work, I’ve made a custom airframe and mixer; I’ve pasted the first motor output mixer below. PWM_DISARMED is set to 1500, and my throttle stick is sprung to centre. I’m not using any auto functions - only stabilise mode.
Now, my problem is, that about 60% of the time, when I arm, the motor output shoots to 1000µs for half a second or so, then back to 1500µs, where my stick is. This causes the motors to spin in full reverse momentarily upon arming. Very scary!
The logs didn’t show anything on OUT0_Out0, but I did discover that if I activate the kill switch, then arm, the motor waits until I deactivate the kill switch, then they spin up momentarily. and allows it to be captured by the logs.
Does anybody have any idea what’s going on? Any help would be much appreciated!
O: 10000 10000 0 -10000 10000
S: 3 0 10000 10000 0 -10000 10000
S: 0 3 -20000 -20000 10000 -10000 10000
I’m curious what ESC you are using? I’ve been looking for a reversible ESC for a while and they are surprisingly few of them (other than the car ones with the extra wire). Sorry I’m not much help on the PWM glitches…
3D ESCs are surprisingly few, until we realised something… read on…
We started out using HobbyWing Xrotor Pro 4A 3D ESCs. The worked pretty well, however they have an annoying “soft start” if you leave the throttle at neutral for a few seconds, so now we use Cobra S-class 80A HV ESCs with BLHeli installed.
Any ESC that supports BLHeli can be programmed to be reversible, even if it doesn’t say it in the description. Make sure you get the appropriate USB programmer, then load up BLHeli Suite, and set the direction to bi-directional. Boom, you have a reversible ESC
What you see is most likely the PWM ramp up logic, which is here: https://github.com/PX4/Firmware/blob/master/src/modules/systemlib/pwm_limit/pwm_limit.c#L136.
The code has not beed designed for your use-case, but I’m generally interested in adding support to PX4 for reversible ESCs.
You can test skipping the ramp up by setting
PWM_LIMIT_STATE_ON in https://github.com/PX4/Firmware/blob/master/src/modules/systemlib/pwm_limit/pwm_limit.c#L82.
Thank you so much @bkueng, that seems to have fixed it!
Good! Do you want to open an upstream issue (https://github.com/PX4/Firmware/issues), so we can discuss a general solution?
Do you require other changes?
I’m not sure but it can be related to a bug I’ve found Throttle spike on arming (is it a bug?) . In my case autopilot sent bigger PWM to ESCs a second after arming and then returned values to expected ones.
I’ve opened an issue. The aircraft is working beautifully, I don’t believe any other changes are required.
Cool - do you have a video?
I have heaps of videos None that I’m allowed to show, unfortunately. Intellectual property. Sorry!
Just a suggestion of maybe point you to how it’s handled in a different application… Checkout Vertical Technologies’ DeltaQuad airframe setup. Reverse thrust is setup in a different PWM port.
That’s really interesting… how do they reverse the motor using a different port?
I don’t know but I’m sure it’s in the code. You may want to try to get with @sanderux who’s the maintainer of that airframe.