
Originally Posted by
Macgman2000
I have only 8bit payload per pot. Actually its like flapperons,I am steering a tank. so to go right it mixes left and right motors in proportions, to steer from large arc to tight arc. To go straight it moves the left and right motor in tandum, same with reverse.
Ok, tank-tread-erons... 
I'll cook it over in the brain for awhile...
So then, values run from 0 to 255, 128 in the middle, say +/-16 for slop? 112-144 = no movement? Something along those lines?
EDIT: done cooking...
Without some better math (i.e. more bits at the input side), you'll lose some range at the output side of things (i.e. 0-223 vs. 0-255)...
Code:
inputvalue var byte
outputvalue var byte
deadband var byte
deadband = 32
if ( input > ( 128 + ( deadband / 2 ) ) ) or ( input < ( 128 - ( deadband / 2 ) ) ) then
output = 128 'set output to middle value
else
if input > ( 128 + ( deadband / 2 ) ) then
input = input - deadband
endif
endif
The total range is reduced to the max byte value (255) minus the total deadband (32 in this case) which equals 223, so 0=minimum, 223=maximum.
But that's just one way to do it...
Bookmarks