Consider this section of your code:
PBP only supports unsigned integers, meaning negative numbers are not supported. There can be no "-10"Code:'create a +/- value centered at 512 left1 = abs(analogleft-512) right1 = abs(analogright-512) 'scale value and create centered deadband of +/-10 'value should fall between -10 and 256 for duty cycle dutycycleleft = ((left1 * 52)/100)-10 dutycycleright = ((right1 *52)/100)-10
For example, you have a word variable "dutycycleleft". As a word, it can hold a value from 0 to 65555. If the current value is 5 and you subtract 10 then the variable will underflow by 5 and become 65531 instead of -5. This will cause the PWM to go full on.
A quick and dirty way to fix the code is to take this from your code:
And change it to:Code:if dutycycleleft < 1 then 'if dutycycle is between -10 and 1 dutycycleleft = 0 'then it equals zero endif
Code:if dutycycle left > 300 then dutycycleleft = 0 endif
Do the same for dutycycleright
Try this and let me know how it works out




Bookmarks