After this bit o' code, left and right should have the deadband taken out, with (in this case) the mid-point of left/right being at 112, and the forward/reverse midpoint is also at 112.Code:lrinput var byte : frinput var byte : lroutput var byte : froutput var byte loutput var byte : routput var byte : lrdeadband var byte : frdeadband var byte lrdeadband = 32 : frdeadband = 32 lrmid var byte : lrmid = 128 - ( lrdeadband / 2 ) frmid var byte : frmid = 128 - ( frdeadband / 2 ) ;adcin x ;adcin y if ( lrinput > ( 128 + ( lrdeadband / 2 ) ) ) or ( lrinput < ( 128 - ( lrdeadband / 2 ) ) ) then lroutput = lrmid 'set output to middle value else if lrinput > ( 128 + ( lrdeadband / 2 ) ) then lroutput = lrinput - lrdeadband endif endif if ( frinput > ( 128 + ( frdeadband / 2 ) ) ) or ( frinput < ( 128 - ( frdeadband / 2 ) ) ) then froutput = frmid 'set output to middle value else if frinput > ( 128 + ( frdeadband / 2 ) ) then froutput = frinput - frdeadband endif endif
Now you have to drive the H-bridge...
What do you have setup for that? Or do you have a separate controller for it or what?
Then you have to add in some code to find and/or remember the minimum and maximum values ever read for the pot's, sort of like a calibration routine for joysticks on a PC...blah blah blah...but I suppose you can keep adding tricks to the code until it gets unbearable...
Bookmarks