new program editor and possible bugs

beny1949

Senior Member
other than the bug relating to the let pins=, does anyone know of any bugs with the new 5.1.3 version of program editor?

i have a program which works fine, until a part which does not even get called is extended. then the servos dont work properly any more, as in one of them will, but the other wont. the code worked fine before the code was made longer. I am running a 40x1 at 16mhz. I have throughly debugged the code which is running when the problem occurs, but the added part does not even get called because the servos do not opperate correctly.

I have reason to beleve there is something going a bit wrong with the compiler.

I am not using the table command and the program size is about 3500 bytes out of 4096bytes.

I am at my wits end with it now, the competition is tomorrow.. and as it stands im stuffed!!!

Any info would be much appreciated,

Ben
 

MiB1986

Member
Hello,

can you post your code? is there any chance you can try an older version of programming editor?

best wishes
 

beny1949

Senior Member
i do not have acess to an older version of programming editor at this moment, and my code is about 1000 lines long.

<code><pre><font size=2 face='Courier'>
;Lcd definitions
SYMBOL RS = 2 ; 0 = Command 1 = Data
SYMBOL EN = 3 ; 0 = Idle 1 = Active
SYMBOL DB4 = 4 ; LCD Data Line 4
SYMBOL DB5 = 5 ; LCD Data Line 5
SYMBOL DB6 = 6 ; LCD Data Line 6
SYMBOL DB7 = 7 ; LCD Data Line 7

SYMBOL RSCMDmask = %00000000 ; Select Command register
SYMBOL RSDATmask = %00000100 ; Select Data register

; Map and movement constants
SYMBOL NMap = 0
SYMBOL NMap2 = 255
SYMBOL WE = 1
SYMBOL NS = 16
SYMBOL Still = 151

SYMBOL N = %00001000
SYMBOL E = %00000100
SYMBOL S = %00000010
SYMBOL W = %00000001

Symbol calibrate = b2
Symbol LDR1 = b3
SYMBOL NOGOMap = w1
Symbol LDR2 = b4
symbol LDR3 = b5
SYMBOL CellAdd = w2
symbol Queue = w2
symbol LDR4 = b6
Symbol LDR5 = b7
symbol Path = w4
Symbol LDR6 = b8
Symbol LDR7 = b9
SYMBOL LeftServe = b10
SYMBOL RightServe = b11
SYMBOL Facing = b12
SYMBOL Cell = b13
SYMBOL TrackDest = b14
SYMBOL TrackPos = b15
SYMBOL Map1 = b16
SYMBOL Map2 = b17
SYMBOL TopSpeed = b19
Symbol Flood = b20
SYMBOL BackUpPtr = b21
SYMBOL NextCell = b22
SYMBOL pos = b24
SYMBOL getting = b25
SYMBOL bit = b26
SYMBOL rsbit = b27

SYMBOL North = 1
SYMBOL East = 2
SYMBOL South = 3
SYMBOL West = 4

'LCD subs use the first 5 bytes
EEPROM 6,(&quot;set sensitivity&quot;)
EEPROM 21, (&quot;Ready&quot;)
EEPROM 26, (&quot;Facing undefined&quot;)
EEPROM 43,(&quot;Cell:&quot;)
EEPROM 48,(&quot;Going:&quot;)
EEPROM 54,(&quot;Creating Maps&quot;)
EEPROM 68,(&quot;Sucess!&quot;)
EEPROM 75,(&quot;Running to&quot;)
EEPROM 85,(&quot;Start &quot;)
EEPROM 91,(&quot;Center&quot;)
EEPROM 97,(&quot;Running at 16mhz&quot;)



'*** PART 1 ***

Setfreq em16
GOSUB InitialiseLcd
ptr = 0
b2 = 50
PowerOnReset: 'get and display the values of the sensors, whilst getting an average: can be removed if code is to big.
pause 1000
gosub sense
pos = $80
getting = LDR1
gosub Dis
pos = $84
getting = LDR2
gosub Dis
pos = $88
getting = LDR3
gosub Dis
pos = $C0
getting = LDR4
gosub Dis
pos = $C4
getting = LDR5
gosub Dis
pos = $C8
getting = LDR6
gosub Dis
pos = $CC
getting = LDR7
gosub Dis
@ptr =LDR1
inc ptr
@ptr =LDR2
inc ptr
@ptr =LDR3
inc ptr
@ptr =LDR4
inc ptr
@ptr =LDR5
inc ptr
@ptr =LDR6
inc ptr
@ptr =LDR7
inc ptr

if ptr != 28 then PowerOnReset

gosub InitialiseLcd

FOR getting = 6 TO 20
READ getting,bit
GOSUB SendDataByte
NEXT
gosub Sensitivity
ptr = 0
gosub Average
ptr = 1
gosub Average
ptr = 2
gosub Average
ptr = 3
gosub Average
ptr = 4
gosub Average
ptr = 5
gosub average
ptr = 6
gosub average
ptr = 28
goto init

Average:
w0 = 0
for getting = 1 to 4
w0 = w0 + @ptr
ptr = ptr +7
Next
@ptr = w0 / 4
@ptr = @ptr + calibrate
return
Dis:
bit = pos
Gosub SendCmdByte
BINTOASCII getting,b23,b22,b21
bit = b23
gosub SendDataByte
bit = b22
gosub SendDataByte
bit = b21
gosub SendDataByte
Return

Sensitivity:
pos = $C0
getting = calibrate
gosub Dis
if pin1 = 1 then inc calibrate
if calibrate = 45 then let calibrate = 55
endif
endif
getting = calibrate
gosub Dis
if pin2 = 1 then return
endif

release:
if pin1 = 0 then Sensitivity
goto release

'*** PART2 ***


init:

Facing = North
Cell = 0
TopSpeed = 15
ptr = 0
hi2csetup i2cmaster, %10100010, i2cslow, i2cword
GOSUB InitialiseLcd
FOR getting = 54 TO 66
READ getting,bit
GOSUB SendDataByte
NEXT
for w0 = 0 to 255 Step 8 'set the first 256 bytes to be the map data... all zeroed
hi2cout w0,(NMap,NMap,NMap,NMap,NMap,NMap,NMap,NMap)
pause 20
Next w0
bit = $2E
gosub SendDataByte
for w0 = 256 to 511 step 8 'set the second 256 bytes to be the NO GO regester! all 255, set to zero when mouse enters the cell
hi2cout w0,(NMap2,NMap2,NMap2,NMap2,NMap2,NMap2,NMap2,NMap2)
pause 20
Next w0
bit = $2E
gosub SendDataByte
for w0 = 512 to 767 step 8 'set the last 256 to be the flood fill map.
hi2cout w0,(NMap2,NMap2,NMap2,NMap2,NMap2,NMap2,NMap2,NMap2)
pause 20
Next w0
bit = $2E
gosub SendDataByte
gosub InitialiseLcd
FOR getting = 68 TO 74
READ getting,bit
GOSUB SendDataByte
NEXT
pause 1000
bit = 0
let bit = bit + %00000010 'make sure that the wall behind the mouse is set
gosub sense2
if bit7 = 1 then let bit = bit + %00001000
endif
if bit2 = 1 then let bit = bit + %00000001
endif
if bit5 = 1 then let bit = bit + %00000100
endif
GOSUB InitialiseLcd
FOR getting = 21 TO 25
READ getting,bit
GOSUB SendDataByte
NEXT
bit = $C0
gosub SendCmdByte
FOR getting = 97 TO 113
READ getting,bit
GOSUB SendDataByte
NEXT
' wait for the user to flick the switch before starting
Ready:
if pin2 = 1 then Ready
GOSUB InitialiseLcd
FOR getting = 43 TO 47
READ getting,bit
GOSUB SendDataByte
NEXT


'b20 = 0

SearchLoop:
'inc b20
'if b20 = 10 or b20 = 1 then
'for NOGOMap = 0 to 768 step 8
' ptr = 0
' hi2cin NOGOMap,(@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptr)
' ptr = 0
' sertxd (#@ptrinc,9,#@ptrinc,9,#@ptrinc,9,#@ptrinc,9,#@ptrinc,9,#@ptrinc,9,#@ptrinc,9,#@ptrinc,13)
' pause 10
'Next NOGOMap

'endif
pause 1000

'this is the main searching loop that will be called when ever the mouse enters a new cell.
bit = 0

Gosub sense2

if Facing = North then ' do checks to see what walls are open and fill out the map sheet accordingly.
' Bit format = %____NESW 1 for a wall present
if bit7 = 1 then:bit = bit + N:endif ' this block takes the sensor readings and put the data into the correct format
if bit2 = 1 then:bit = bit + W:endif ' for the maze map, no matter what way it is facing. it does not need to deal with
if bit5 = 1 then:bit = bit + E:endif ' the data for the previous cell because that will have already been added when it
Gosub MapW ' was there.
elseif Facing = East then
if bit7 = 1 then:bit = bit + E:endif
if bit2 = 1 then:bit = bit + N:endif
if bit5 = 1 then:bit = bit + S:endif
Gosub MapW
elseif Facing = South then
if bit7 = 1 then:bit = bit + S:endif
if bit2 = 1 then:bit = bit + E:endif
if bit5 = 1 then:bit = bit + W:endif
Gosub MapW
elseif Facing = West then
if bit7 = 1 then:bit = bit + W:endif
if bit2 = 1 then:bit = bit + S:endif
if bit5 = 1 then:bit = bit + N:endif
Gosub MapW
else
'display an error screen
bit = $01
gosub SendCmdByte
'string eepromed at the top of the file, because it cannot be done within an IF block.
FOR getting = 26 TO 42
READ getting,bit
GOSUB SendDataByte
NEXT
endif
let NOGOMap = Cell + NMap2 ' point to the same position in the nogo map.
gosub NGWL

Direction: ; depending on the direction the mouse is facing select the best cell to move into.
; Must also increment the cell. NEED TO ADD PRIORITY TO UNSEEN CELLS
bit8 = 0
If Facing = North then 'NORTH FACING
NOGOMap = NOGOMap + NS
gosub NGR
if bit7 = 0 and @ptr = NMap2 then
gosub Foward
Cell = Cell + NS
bit8 = 1
gosub NGWL
endif
if bit8 = 1 then FinishDirection
NOGOMap = NOGOMap - NS
NOGOMap = NOGOMap - WE
gosub NGR
if bit2 = 0 and @ptr = NMap2 then
gosub Left
Facing = West
gosub Foward
Cell = Cell - WE
bit8 = 1
gosub NGWL
endif
if bit8 = 1 then FinishDirection
NOGOMap = NOGOMap + WE + WE
gosub NGR
if bit5 = 0 and @ptr = NMap2 then
gosub Right
Facing = East
gosub Foward
Cell = Cell + WE
bit8 = 1
gosub NGWL
endif
if bit8 = 1 then FinishDirection

if bit7 = 0 then
gosub Foward
Cell = Cell + NS
elseif bit2 = 0 then
gosub Left
Facing = West
gosub Foward
Cell = Cell - WE
elseif bit5 = 0 then
gosub Right
Facing = East
gosub Foward
Cell = Cell + WE
elseif Bit7 = 1 and bit2 = 1 and bit5 = 1 then
gosub Right
gosub Right
Facing = South
gosub Foward
Cell = Cell - NS
endif
'END OF NORTH FACING

elseif Facing = East then ' EAST FACING

NOGOMap = NOGOMap + WE
gosub NGR
if bit7 = 0 and @ptr = NMap2 then
gosub Foward
Cell = Cell + WE
bit8 = 1
gosub NGWL
endif
if bit8 = 1 then FinishDirection
NOGOMap = NOGOMap - WE
NOGOMap = NOGOMap + NS
gosub NGR
if bit2 = 0 and @ptr = NMap2 then
gosub Left
Facing = North
gosub Foward
Cell = Cell + NS
bit8 = 1
gosub NGWL
endif
if bit8 = 1 then FinishDirection
NOGOMap = NOGOMap - NS
NOGOMap = NOGOMap - NS
gosub NGR
if bit5 = 0 and @ptr = NMap2 then
gosub Right
Facing = South
gosub foward
Cell = Cell - NS
bit8 = 1
gosub NGWL
endif
if bit8 = 1 then FinishDirection
if bit7 = 0 then
gosub Foward
Cell = Cell + WE
elseif bit2 = 0 then
gosub Left
Facing = North
gosub Foward
Cell = Cell + NS
elseif bit5 = 0 then
gosub Right
Facing = South
gosub foward
Cell = Cell - N
elseif Bit7 = 1 and bit2 = 1 and bit5 = 1 then
gosub Right
gosub Right
Facing = West
gosub Foward
Cell = Cell - WE
endif


elseif Facing = South then
NOGOMap = NOGOMAp - NS
gosub NGR
if bit7 = 0 and @ptr = NMap2 then
gosub Foward
Cell = Cell - NS
bit8 = 1
gosub NGWL
endif
if bit8 = 1 then FinishDirection
NOGOMap = NOGOMap + NS
NOGOMap = NOGOMap + WE
gosub NGR
if bit2 = 0 and @ptr = NMap2 then
Gosub Left
Facing = East
gosub Foward
Cell = Cell + WE
bit8 = 1
gosub NGWL
endif
if bit8 = 1 then FinishDirection
NOGOMap = NOGOMap - WE
NOGOMap = NOGOMap - WE
gosub NGR
if bit5 = 0 and @ptr = NMap2 then
gosub Right
Facing = West
gosub Foward
Cell = Cell - WE
bit8 = 1
gosub NGWL
endif
if bit8 = 1 then FinishDirection

if bit7 = 0 then
gosub Foward
Cell = Cell - NS
elseif bit2 = 0 then
Gosub Left
Facing = East
gosub Foward
Cell = Cell + WE
elseif bit5 = 0 then
gosub Right
Facing = West
gosub Foward
Cell = Cell - WE
elseif Bit7 = 1 and bit2 = 1 and bit5 = 1 then
gosub Right
gosub Right
Facing = North
gosub Foward
Cell = Cell + NS
endif

elseif Facing = West then
NOGOMap = NOGOMap - WE
gosub NGR
if bit7 = 0 and @ptr = NMap2 then
gosub Foward
Cell = Cell - WE
bit8 = 1
gosub NGWL
endif
NOGOMap = NOGOMap + WE
NOGOMap = NOGOMap - NS
gosub NGR
if bit2 = 0 and @ptr = 0 then
gosub Left
Facing = South
gosub Foward
Cell = Cell - NS
bit8 = 1
gosub NGWL
endif
if bit8 = 1 then FinishDirection
NOGOMap = NOGOMap + NS + NS
gosub NGR
if bit5 = 0 and @ptr = 0 then
gosub Right
Facing = North
gosub Foward
Cell = Cell + NS
bit8 = 1
gosub NGWL
endif
if bit8 = 1 then FinishDirection

if bit7 = 0 then
gosub Foward
Cell = Cell - WE
elseif bit2 = 0 then
gosub Left
Facing = South
gosub Foward
Cell = Cell - NS
elseif bit5 = 0 then
gosub Right
Facing = North
gosub Foward
Cell = Cell + NS
elseif Bit7 = 1 and bit2 = 1 and bit5 = 1 then
gosub Right
gosub Right
Facing = East
gosub Foward
Cell = Cell + WE
endif

endif
FinishDirection:
NOGOMap = Cell + NMap2
if Cell = 119 or Cell = 120 or Cell = 135 or Cell = 136 then FFill

getting = Cell
pos = $89
gosub Dis


'pause 1000 For debug purposes
goto SearchLoop


FFill:
'create and initialise a queue with 256 elements sequencial after the 768
'create a routing map as an array of 256 bytes ...Tick
'fill the array with the value 255 ...Tick
'fill the target cells(s) with the value 0 ...Tick
'add the target cell locations to the queue
'while there are items in the queue
' get a location from the tail of the queue
'if the cell does not contains the value 255 then
' for each accessible, unfilled neighbour
' put in it a value one more than the current cell
' add it to the queue
' end for
'end if
'end while
for ptr = 127 to 36
@ptr = 255
next ptr
hi2cout 631,(0,0)'set the middle of the flood fill map ready for after the mapping sesh
pause 5
hi2cout 647,(0,0)
pause 5
@ptr = Cell
Flood = 0
BackUpPtr = 36

FFP2:
do while @ptr != 0
w2 = @ptr
hi2cin w2,(bit)
w3 = @ptr + 512
hi2cin w3 ,(Flood) 'import the Cells Flood Value in order to have a reference for the next cells that will be checked
Flood = Flood + 1
ptr = Map2
let Map1 = bit &amp; %00000001 'check the Cell west of the current one
if Map1 = 0 then
w2 = w2 - WE
hi2cin w2,(Map2)
if Map2 = NMap2 then
inc ptr
@ptr = w2
hi2cout w2,(Flood)
pause 20
endif
w2 = w2 + WE
endif
let Map1 = bit &amp; %00000010 'check the Cell South of the current one
if Map1 = 0 then
w2 = w2 - NS
hi2cin w2,(Map2)
if Map2 = NMap2 then
inc ptr
@ptr = w2
hi2cout w2,(Flood)
pause 20
endif
w2 = w2 + NS
endif
let Map1 = bit &amp; %00000100 'check the Cell East of the current one
if Map1 = 0 then
w2 = w2 + WE
hi2cin w2,(Map2)
if Map2 = NMap2 then
inc ptr
@ptr = w2
hi2cout w2,(Flood)
pause 20
endif
w2 = w2 - WE
endif
let Map1 = bit &amp; %00001000 'check the Cell North of the current one
if Map1 = 0 then
w2 = w2 + NS
hi2cin w2,(Map2)
if Map2 = NMap2 then
inc ptr
@ptr = w2
hi2cout w2,(Flood)
pause 20
endif
w2 = w2 - NS
endif
Map2 = ptr
inc BackUpPtr
ptr = BackUpPtr
loop
' Create a route which the mouse can follow foward and reverse
ptr = 36
w3 = 512
w2 = 0
Path = 768
do
bit0 = 0
inc @ptr
hi2cin w2,(bit)
hi2cin w3,(Map2)
let Map1 = bit &amp; %00000001 'check the Cell west of the current one
if Map1 = 0 then
w2 = w2 - WE
hi2cin w2,(Map1)
if Map1 &lt; Map2 then
b8 = w2
hi2cout Path,(b8)
pause 20
bit0 = 1
endif
endif
if bit0 = 1 then FFP3
w2 = w2 + WE
let Map1 = bit &amp; %00000010 'check the Cell South of the current one
if Map1 = 0 then
w2 = w2 - NS
hi2cin w2,(Map1)
if Map1 &lt; Map2 then
b8 = w2
hi2cout Path,(b8)
pause 20
bit0 = 1
endif
endif
if bit0 = 1 then FFP3
w2 = w2 + NS
let Map1 = bit &amp; %00000100 'check the Cell East of the current one
if Map1 = 0 then
w2 = w2 + WE
hi2cin w2,(Map1)
if Map1 &lt; Map2 then
b8 = w2
hi2cout Path,(b8)
pause 20
bit0 = 1
endif
endif
if bit0 = 1 then FFP3
w2 = w2 - WE
let Map1 = bit &amp; %00001000 'check the Cell North of the current one
if Map1 = 0 then
w2 = w2 + NS
hi2cin w2,(Map1)
if Map1 &lt; Map2 then
b8 = w2
hi2cout Path,(b8)
pause 20
endif
w2 = w2 - NS
endif

FFP3:
if b8 = 119 or Cell = b8 or Cell = b8 or Cell = b8 then exit
inc Path
loop
BackUpPtr = @ptr
b16 = path
gosub InitialiseLcd

FOR getting = 75 TO 84
READ getting,bit
GOSUB SendDataByte
NEXT
RunTS:
gosub InitialiseLcd

FOR getting = 85 TO 90
READ getting,bit
GOSUB SendDataByte
NEXT
Cell = 0
for b23 = b16 to 0
dec Path
hi2cin Path,(NextCell)
gosub PathFinder
next b23
pause 1000 ' for debugging purposes

RunTC:
gosub InitialiseLcd

FOR getting = 91 TO 96
READ getting,bit
GOSUB SendDataByte
NEXT
for b23 = 0 to b16
inc Path
hi2cin Path,(NextCell)
gosub PathFinder
next b23
pause 1000 ' for debugging purposes
goto RunTS


PathFinder:
b8 = NextCell - Cell
if Facing = North then
if b8 = 1 then
gosub Right
Facing = East
gosub Foward
elseif b8 = 16 then
gosub Foward
elseif b8 = 255 then
gosub Left
Facing = West
gosub Foward
elseif b8 = 240 then
gosub Right
gosub Right
Facing = South
gosub Foward
endif
elseif Facing = East then
if b8 = 1 then
gosub Foward
elseif b8 = 16 then
gosub Left
Facing = North
gosub Foward
elseif b8 = 255 then
gosub Right
gosub Right
Facing = West
gosub Foward
elseif b8 = 240 then
gosub Right
Facing = South
gosub Foward
endif
elseif Facing = South then
if b8 = 1 then
gosub Left
Facing = East
gosub Foward
elseif b8 = 16 then
gosub Right
gosub Right
Facing = North
gosub Foward
elseif b8 = 255 then
gosub Right
Facing = West
gosub Foward
elseif b8 = 240 then
gosub Foward
endif
elseif Facing = West then
if b8 = 1 then
gosub Right
gosub Right
Facing = East
gosub Foward
elseif b8 = 16 then
gosub Right
Facing = North
gosub Foward
elseif b8 = 255 then
gosub Foward
elseif b8 = 240 then
gosub Left
Facing = South
gosub Foward
endif
else
FOR getting = 26 TO 42
READ getting,bit
GOSUB SendDataByte
NEXT
endif
Cell = NextCell
return

'*** Tracking ***
Foward: ' go foward one cell (18cm)
TrackDest = 41
ptr = 0
for TrackPos = 0 to TrackDest
gosub sense2
let bit = b0 &amp; $80
if bit = $80 then
if TrackPos =&gt; 13 then Exit
if TrackPos &lt; 13 then 'if the mouse didnt make up the full distance, then compensated now, so continue
if Facing = North then: Cell = Cell - NS
elseif Facing = South then: Cell = Cell + NS
elseif Facing = East then: Cell = Cell - WE
elseif Facing = West then: Cell = Cell + WE
endif
Exit
endif
endif


;movement correction.
let bit = b0 &amp; $7E


if bit = %01101100 or bit = %01100000 or bit = %00001100 or bit = %01001000 or bit = %01101000 or bit = %01001100 or bit = %01000000 or bit = %00001000 then'Tis vearing to the right hand side!!!!!!!! sort it out!
RightServe = Still - 5
LeftServe = Still + TopSpeed
elseif bit = %00110110 or bit = %00110000 or bit = %00000110 or bit = %00010010 or bit = %00110010 or bit = %00010110 or bit = %00000010 or bit = %00010000 then
LeftServe = Still + 5
RightServe = Still - TopSpeed
'elseif TrackPos &gt; 13 then
'if bit = %00100110 or bit = %01100100 or bit = %01110110 or bit = %01101110 then Exit
'
'LDR4 = @ptrdec &amp; %00100100
'LDR3 = @ptrinc &amp; %00100100
'if LDR4 != LDR3 then Exit ' leave the loop if the mouse goes accross a wall boundry.
else
LeftServe = Still + TopSpeed
RightServe = Still - TopSpeed
endif

Gosub Speed
After:
pause 80
Next TrackPos

LeftServe = Still
RightServe = Still
gosub Speed
return


Left: ' turn 90deg CCW

TrackDest = 21
LeftServe = Still - TopSpeed
RightServe = Still - TopSpeed
gosub Speed
for TrackPos = 0 to TrackDest
gosub sense2
if TrackPos &gt; 18 then
let bit = b0 &amp; %00100100
if bit != 0 then
pause 80
Exit
endif
endif
pause 80
next Trackpos
LeftServe = Still
RightServe = Still
gosub Speed
return

Right: ' turn 90deg CW
TrackDest = 21
LeftServe = Still + TopSpeed
RightServe = Still + TopSpeed
gosub Speed
for TrackPos = 0 to TrackDest
gosub sense2
if TrackPos &gt; 18 then
let bit = b0 &amp; %00100100
if bit != 0 then
pause 80
Exit
endif
endif
pause 80
next Trackpos
LeftServe = Still
RightServe = Still
gosub Speed
return

Speed:
servo 0,LeftServe
servo 1,RightServe
return


'*** MAP CONTROL ***

MapW: ;Bit format = %____NESW 1 for a wall present
ptr = 0
CellAdd = Cell
gosub MapR
sertxd (#bit,9)
bit = bit | @ptr
hi2cout CellAdd, (bit) ' output the current wall configuration
sertxd (#Cell,9,#bit,9,#@ptr,10)
pos = $C2
getting = bit
gosub Dis


NorthCell: ' Update the surrounding cells so that some data has already been collected when the mouse enters a
Map2 = bit &amp; %00001000 ' cell. This will not set the other cells as ok to enter though. (NOGO = 0)
if Map2 = %00001000 then
CellAdd = Cell + N/S
gosub MapR
Map1 = @ptr | Map2
hi2cout CellAdd,(Map1)
pause 20
endif
EastCell:
Map2 = bit &amp; %00000100
if Map2 = %00000100 then
CellAdd = Cell + W/E
gosub MapR
Map1 = @ptr | Map2
hi2cout CellAdd,(Map1)
pause 20
endif
SouthCell:
Map2 = bit &amp; %00000010
if Map2 = %00000010 then
CellAdd = Cell - N/S
gosub MapR
Map1 = @ptr | Map2
hi2cout CellAdd,(Map1)
pause 20
endif
WestCell:
Map2 = bit &amp; %00000001
if Map2 = %00000001 then
CellAdd = Cell - W/E
gosub MapR
Map1 = @ptr | bit
hi2cout CellAdd,(Map1)
pause 20
endif
Return

MapR:
hi2cin CellAdd, (@ptr)
return


NGR: ' read the status from the no go register
hi2cin NOGOMap,(@ptr)
return

NGWL:
hi2cout NOGOMap,(0) ' write the no go stautus low for the current cell (ok to enter)
pause 20
return

NGWH:
hi2cout NOGOMap,(NMap2) 'write the no go status high (not ok to go into)
return


'*** SENSOR CONTROL ***
sense2:
gosub sense
ptr = 28
if LDR1 &gt; @ptrinc then: bit1 = 1
else bit1 = 0
endif
if LDR2 &gt; @ptrinc then: bit2 = 1
else bit2 = 0
endif
if LDR3 &gt; @ptrinc then: bit3 = 1
else bit3 = 0
endif

if LDR4 &gt; @ptrinc then: bit4 = 1
else bit4 = 0
endif
if LDR5 &gt; @ptrinc then: bit5= 1
else bit5 = 0
endif
if LDR6 &gt; @ptrinc then: bit6 = 1
else bit6 = 0
endif
if LDR7 &gt; @ptrinc then: bit7 = 1
else bit7 = 0
endif
return
sense:
readadc 0,LDR1
readadc 1,LDR2
readadc 2,LDR3
readadc 3,LDR4
readadc 5,LDR5
readadc 6,LDR6
readadc 7,LDR7
return



'******LCD SUBS*********'
InitialiseLcd:

FOR getting = 0 TO 5
READ getting,bit
GOSUB SendInitCmdByte
NEXT

' Nibble commands - To initialise 4-bit mode

EEPROM 0,( $33 ) ; %0011---- %0011---- 8-bit / 8-bit
EEPROM 1,( $32 ) ; %0011---- %0010---- 8-bit / 4-bit

' Byte commands - To configure the LCD

EEPROM 2,( $28 ) ; %00101000 %001LNF00 Display Format
EEPROM 3,( $0C ) ; %00001100 %00001DCB Display On
EEPROM 4,( $06 ) ; %00000110 %000001IS Cursor Move

; L : 0 = 4-bit Mode 1 = 8-bit Mode
; N : 0 = 1 Line 1 = 2 Lines
; F : 0 = 5x7 Pixels 1 = N/A
; D : 0 = Display Off 1 = Display On
; C : 0 = Cursor Off 1 = Cursor On
; B : 0 = Cursor Steady 1 = Cursor Flash
; I : 0 = Dec Cursor 1 = Inc Cursor
; S : 0 = Cursor Move 1 = Display Shift
EEPROM 5,( $01 ) ; Clear Screen

RETURN

SendInitCmdByte:

PAUSE 15 ; Delay 15mS

SendCmdByte:

rsbit = RSCMDmask ; Send to Command register

SendDataByte:

outpins = bit &amp; %11110000 | rsbit ^ $80; Put MSB out first
high EN
pause 1
low EN ; Give a 10uS pulse on E
outpins = bit * %00010000 | rsbit ^ $80; Put LSB out second
high EN
pause 1
low EN ; Give a 10uS pulse on E

rsbit = RSDATmask ; Send to Data register next

RETURN

'******* END OF LCD SUBS********'










</font></pre></code>

I cannot see anything wrong with it, and we have already had several problems with the program editor....

Here now at the competition, have a few hours before the deadline!!!

i pray to hippy...
 

hippy

Technical Support
Staff member
Unfortunately I have to go out and don't have the time to look at the code let alone go through it, and will not be in a thinking state until tomorrow afternoon ( UK time ) at the earliest.

That you've hit the problem around 3500 bytes, about 512 short of maximum capacity could be significant. I'd expect any TABLE related issues to kick in with 256 bytes to go, but who knows.

Unfortunately, it's not going to be easy to fix without knowing what's going wrong, and that could be difficult to identify.

Although it's not what you want to hear; I'd suggest getting the software into a state where it does something so you can go into the maze and perform even if it's a 'lost cause'. Make sure that's backed-up as your fall-back position before trying any debugging, code re-ordering and so on.

I think the reality is, that unless you are lucky you won't be able to fix the problem in time ( previous compilers may have the same problem and it may be a Firmware bug which there is not a known fix for ) and you have to be prepared for that. The best I can suggest is to get your code down below a size it does work, and live within that, do whatever you can.

Ironically that's why I'm so tied up at present; helping organise a fairly large 60-band festival which the local authority refused to grant a licence for at the eleventh hour. Frantically trying to get bands into licensed venues and let the people know why the park meant to be used is sitting empty and resolve any frustrations should they arise. Looks like we're both 'up against the wall' at present, but I bet you haven't got blisters from the leg work :)

Good luck anyway - The moral is something is better than nothing.
 

beny1949

Senior Member
thabnks alot hippy.

gave it a run with little sucess so, i guess i will have to wait untill next year.

the code was not fixable, and there was another bug that i found just before the run, which the program editor problems would not let me solve it!

Ben
 
Top