Hi Monie,
I am not sure how your hardware is designed.
But assuming you have two motors, one on the left and one on the right, and that you want your mower to go forwards, backwards and turn.
I which case I would suggest that you use the MIAC outputs in full bridge mode.
That is, connect the left motor to outputs A and B, connect the right motor to outputs C and D.
Set PWM1 channel 1 to output on PORTF.0 and that will control the
power to the left motor.
Set PWM2 channel 2 to output on PORTF.1 and that will control the
power to the right motor.
Each motor
direction is then controlled by the OutputON() OutputOFF() macros, for example:
Left motor stop
Left motor forward
Left motor backwards
The right motor is controlled in the same way, just use 3 and 4 as parameters in place of 1 and 2.
I would then suggest that you use the variables, that you have got from the pulses,
Turn_Forward_Back and
Turn_Right_Left.
From
Turn_Forward_Back you can get the
power variable to set for the
duty_cycle of both PWM channels.
From
Turn_Forward_Back you can also get the
forwards true or false.
From
Turn_Right_Left you can get
straight,
left or
right.
From this information you can determine if each motor should be stop, forwards or backwards.
Hope that helps, sorry I don't have the time to write that as a program for you.
But if you need any more help let me know.
Leigh