radio control set to operate model boat propellers 08M2


This post shows the final but not exactly as I wanted program to control the speed of a 12v 12 pole motor connected to a model tug boats propeller using a 2.4Ghz transmitter and receiver. I thought someone may have come up with a better program than mine.

I wanted to move the joystick upwards from the mid position to max that would give zero to max forward speed. The receiver pulse would be from 1.5mS to 2mS.
Also downwards from the mid position to min that would give zero to max reverse speed. The receiver pulse would be from 1.5mS to 1.0mS.

The forward speed program wasn't a problem to write but I tried all sorts of ideas for the reverse. In the end I ended up with this program attached.
I used a switch on the transmitter that the 08M2 would monitor (w2) to switch a relay to make the motor rotate clockwise or anticlockwise. The joystick moves from the bottom of its mechanical stroke to the top.
It works but most model boats have a centre off mid position.

The trouble I had of using 1.5mS to 1.0mS was in reversing ( not inverting ) the signal. My first program had every w1 number i.e. 147,146,145...102, 101...had to be reduced or increased accordingly then to be multiplied by a number to give a longer 12V motor pulse to power the motor (with the 7-8kg boat in the water, possibly towing another vessel). I even tried lookup read table to minimise the memory size and time delay but to no avail. Whatever I tried slowed up the motors one way or another.
Having spent far too much time on that I will settle for the attached program.
I know that pics are used in ESC's so it can be done without the switch. Welcome comments or ideas.