WebTruck Moving out
Guest

-- set these const to deactivate components

const bit nopwm = 0 -- no pwm out
const bit noad = 0 -- no ad conversion
const bit nosound = 0 -- no pwm sound out
const byte dopoint = 1

const bit noserial = 0 -- no serial connection
-- this takes time!!

const bit driveallthetime = 0 -- reset tacho when driving forward

const bit brakeon = 1
const bit showlook = 1
const bit nosteer = 0 -- do not steer
const bit nopsp = 0 -- do not pulse servo
const bit testcny = 1 -- cny70 evaluation
const bit nopolaroid = 0
const bit dopolpulse = 1
const bit doshowvalues = 1
const bit nogp2d12 = 0
const bit fulldebug = 0
const bit debugcheckset = 0 -- show what checkset did
const bit alldebug = 0 -- show all important values
const bit valdebug = 0 -- show values
-- valdebug out of order - stack depth...
const bit maindebug = 0 -- show values
const bit debugstuck = 0
const bit debugsteer = 0
const bit debuggp2d12 = 0
const bit debugspeed = 0
const bit debugirrev = 0
const bit debugirfront = 0
const bit debug6500 = 0
const bit debugpol = 0
const bit debugsound = 0 -- debug info beeps
const bit debuglight = 0
const bit debugsenval = 0
const bit debugenv65 = 0
const bit debugsetf = 0


const byte battvolts = 12
const byte normbatt = 6
const byte battdiff = battvolts - normbatt

const byte gloopconst = 15

-- drive constants
-- directions
const byte forward = 1
const byte reverse = 2
const byte stop = 0

-- servo gp2d12,
-- servo polaroid 6500
const byte posr = 90
const byte posl = 210
const byte poffset = 0
const byte posm = (posl + posr) / 2
const byte posstep = 2
const byte poshr = ( posm + posr ) / 2
const byte poshl = ( posm + posl ) / 2
const byte posconst = 2
const byte pforward = ( posl - posr ) / 2 - 17

-- steering servo
-- carefully tuned values :-)
const byte sright = 123
const byte sleft = 167
const byte smiddle = 144
const byte shright = sright + (smiddle - sright ) / 3
const byte shleft = sleft - (sleft - smiddle ) / 3
const byte steerstep = 2
const byte steerconst = 25 -- how long to keep a steering


-- steering

-- how many times to steer until we go straight again
const byte maxstraight = 150
const byte minstraight = maxstraight / 2


-- how much to in-/decrease speed for each loop
const byte speedstep = 1

-- speeds
-- const byte minspeed = 100 - battdiff * 4
-- new: calculate
const byte maxspeed = 255 - battdiff * 3
-- const byte midspeed = minspeed + ( maxspeed - minspeed ) / 3

-- how many tacho counts for a normal move
const byte driveconst = 30
-- tacho counts for reverse
const reverseconst = 25
const stuckconst = 70
const stuckcountermax = 3
const stuckblock = 100
const stuckinit = 1
const stuckpolaroid = 2
const stuckbumperl = 3
const stuckbumperr = 4
const stuckrev = 5
const stucktacho = 6
const stuckgp2d12 = 1
const stuckcommand = 7


-- distances
const byte gp2d12channel = 1
const byte dtrigger = 40 -- max distance to evaluate
const byte dmax = 100
const byte dstop = dtrigger + ( dmax - dtrigger) / 2
-- when driving, at which distance to stop
const byte cny70max = 1
-- pol distances in decimeter aprox.
const byte ptrigger = 65
const byte pmax = 254
const byte pstop = 100
const byte pgo = 205

-- photoresistors
const byte photolchannel = 2
const byte photorchannel = 3
const byte lightconst = 3
const byte ltara = 10


const byte dmodefree = 1
const byte dmodecontrolled = 2
const byte mainwait = 3 -- * 5ms wait in main loop