Differential Steering Control: How to Actuate Electronic Gearshift Solenoids on Diesel Engine

I am trying to use Ardupilot to implement basic stationkeeping on a 53’ Hatteras with twin Diesel engines.

I’ve successfully built a small ardupilot catamaran with differential steering using typical ESCs and brushless motors. When oriented stern to weather, the same control method would work with the big boat for stationkeeping purposes.

My question is how can I adapt the forward-reverse PWM control output to control the shifters on the diesel transmissions?

Basically, I need ardupilot to command forward or reverse for each engine by applying 5v to one pin for forward and another pin for reverse.

(Each diesel engine is shifted into gear using a pair of 24v solenoid valves, one for forward and one for reverse. If neither solenoid is activated, the transmission defaults to neutral. The throttles will not be controlled by ardupilot in this application. They will remain at idle always.)

I’m using a Navio2, so it would be possible to write a helper script that monitors the PWM outputs from ardupilot and applies voltage on GPIO pins accordingly to control relays for each transmission solenoid.

Is there a way to do that natively within ardupilot?

On a flightcontroller supporting lua scripts you could switch the relay outputs depending on the PWM range. Lower than 1500us, reverse valve is active, higher than 1500us, forward valve is active. A deadzone around 1500us keeps both valves off.
Keep in mind that ardupilot is for unmanned vehicles:

https://ardupilot.org/dev/docs/developer-code-of-conduct.html

1 Like

That is perfect. Lua scripting is exactly what I need. The necessary functions are all already available through the prebuilt libraries.

get_pwm()
toggle(relay_num)

https://ardupilot.org/dev/docs/common-lua-scripts.html

I did not know this existed. Thank you.

You might also try the “brushed with relay” motor driver options, I think there is a mode where the direction is set on one digital pin and the throttle is set with a separate pin. It might save the hassle of writing your own script.

https://ardupilot.org/rover/docs/rover-motor-and-servo-configuration.html

There are some kind of confusing limitations on which pins you can use so I’d verify with an oscilloscope:

https://ardupilot.org/rover/docs/common-brushed-motors.html#common-brushed-motors