MotorDrive (Pseudo code)
Always have PWM polarities high
Stop
Set direction pins low
SetDuty 0 on both motors
RotateCCW
Takes int angle, int exact (angle is how much to turn, exact is whether to try to go exactly to the angle or not) (exact = 0 which is inexact is for when we turn, check the angle from FAC, and turn again. This is decreased so we don’t overshoot and we approach the desired angle instead of one fast turn)
Set Motor1 direction pin high
Set Motor2 direction pin low
If exact is 0, set Timer 1 to angle*7 (Numbers from calibration)
Else if exact is 1, set Timer 1 to angle*9
Ensure the timer was set to atleast 1 (nonzero)
SetDuty to 60 for motor 1, 40 for motor 2
RotateCW
Takes int angle, int exact (angle is how much to turn, exact is whether to try to go exactly to the angle or not) (exact = 0 which is inexact is for when we turn, check the angle from FAC, and turn again. This is decreased so we don’t overshoot and we approach the desired angle instead of one fast turn)
Set Motor2 direction pin high
Set Motor1 direction pin low
If exact is 0, set Timer 1 to angle*7
Else if exact is 1, set Timer 1 to angle*9
Ensure the timer was set to atleast 1 (nonzero)
SetDuty to 60 for motor 2, 40 for motor 1
RotateCWInf
Set Motor1 direction pin low
Set Motor2 direction pin high
SetDuty to 60 for motor 2, 40 for motor 1
DriveForward
Set direction pins to low
SetDuty 60 for both motors
DriveReverse
Set direction pins to high
SetDuty 60 for both motors
SetDuty
Takes double DC and char channel
Put in safeguards so that the PWM never rises above 70% (due to PWM from 14-16V)
Set PWMDTY of channel to 250*DC/100 typecasted to an int
Stop
Set direction pins low
SetDuty 0 on both motors
RotateCCW
Takes int angle, int exact (angle is how much to turn, exact is whether to try to go exactly to the angle or not) (exact = 0 which is inexact is for when we turn, check the angle from FAC, and turn again. This is decreased so we don’t overshoot and we approach the desired angle instead of one fast turn)
Set Motor1 direction pin high
Set Motor2 direction pin low
If exact is 0, set Timer 1 to angle*7 (Numbers from calibration)
Else if exact is 1, set Timer 1 to angle*9
Ensure the timer was set to atleast 1 (nonzero)
SetDuty to 60 for motor 1, 40 for motor 2
RotateCW
Takes int angle, int exact (angle is how much to turn, exact is whether to try to go exactly to the angle or not) (exact = 0 which is inexact is for when we turn, check the angle from FAC, and turn again. This is decreased so we don’t overshoot and we approach the desired angle instead of one fast turn)
Set Motor2 direction pin high
Set Motor1 direction pin low
If exact is 0, set Timer 1 to angle*7
Else if exact is 1, set Timer 1 to angle*9
Ensure the timer was set to atleast 1 (nonzero)
SetDuty to 60 for motor 2, 40 for motor 1
RotateCWInf
Set Motor1 direction pin low
Set Motor2 direction pin high
SetDuty to 60 for motor 2, 40 for motor 1
DriveForward
Set direction pins to low
SetDuty 60 for both motors
DriveReverse
Set direction pins to high
SetDuty 60 for both motors
SetDuty
Takes double DC and char channel
Put in safeguards so that the PWM never rises above 70% (due to PWM from 14-16V)
Set PWMDTY of channel to 250*DC/100 typecasted to an int