Need help. I DON't know what is going on
Ravenkallen
Posts: 1,057
Hey, guys. I got another problem. Every time i try to add another method/ Object to my program the whole thing acts really strange. AS soon as i erase the method everything goes back to normal. It doesn't matter what method it is, it does it to all of them. I checked the memory and i still got like 6_000 longs left. Is there a limit to the number of methods/ Objects·a program can have? Most of the objects i use, use only one cog. This problem is so weird i don't know what to do. I can add additonal code to a existing method, but once i declare a new one, POOF, it acts retarded......Maybe you guys know something i don't. I can try posting my code if you guys need.....Thanks in advance....
Comments
-Phil
Dan := thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"She may not be very pretty now, but she was somebody's baby once." Bugs Bunny
What helps me is to isolate the problem. Try adding a different method and see if that also causes a similar problem. Try running that troublesome method by itself or along with other entirely different code.
(Is it the particular method which is the problem or adding any additional method/object which is the problem.)
Then if I track the problem down to a particular method/object, THEN I can use fullduplexserial or whatever to display variable values at different points in the program to see what values are or if the program is even getting to that point.
And if it is not getting to·a certain point like it should, if I can see what the·variables are or if a loop is looping like it should, then I can further track down the problem.
FYI - I spent a whole day tracking down such a problem the other day. I was reading pulse values. The pulse reading object worked fine by itself, but not when included with my main program. It turned out the pulse reading object was looking for a long pause in the pulses before it would display any values. And my main program did not provide as long of a break in the pulses.
So the solution was to reduce the wait time for a break in the pulses, then it displayed the pulse values just fine. (Or to add a longer delay between pulses in my program.)
But it took a *lot* of time and testing to find that problem. I have cogs running all over the place, all sorts of different objects and methods. So my first thought was where do I begin!
I have another problem now. And I am wondering if all my cogs are running or not. So I think today I will have each cog turn on a separate LED when it runs. Then I will be able to "see" that at least the cogs started.
·
con
·_xinfreq = 5_000_000
·_clkmode = xtal1 + pll16X
obj
Serio: "parallax serial terminal"
i2crw : "i2c"
kb: "keyboard"
decstr: "strtodec"
var
byte erase[noparse][[/noparse]2], nextline[noparse][[/noparse]3], chardata
byte counter,space, counter2, chardata2, txbyte, databyte
byte tempd, i2csys, i2cdata, Programdata[noparse][[/noparse]4000], datapoint
long address, addresspointer
pub systemstart
erase := string(254, 81)
nextline := string(254, 69, 60)
serio.startrxtx(3,4,0,2400)
kb.start(22, 23)
·····················
serio.str(erase)
waitcnt(clkfreq + cnt)
repeat 10
·tempd := lookupz(counter: "Welcome to")
·serio.char(tempd)
·counter++
counter := 0
serio.str(nextline)
repeat 15
·tempd := lookupz(counter: "StarRider V 3.0")
·serio.char(tempd)
·counter++
counter := 0
waitcnt(clkfreq * 2 + cnt)
checki2c··
menu·······
pub menu
counter := 0
serio.str(erase)
·
waitcnt(clkfreq/100 + cnt)
repeat 17
·tempd := lookupz(counter: "P= Program······ ")
·serio.char(tempd)
·counter++
counter := 0
serio.str(nextline)
repeat 20
·tempd := lookupz(counter: "O= options M= More······ ")
·serio.char(tempd)
·counter++
counter := 0
waitcnt(clkfreq + cnt)
repeat
· chardata := 0
·
·· readkb
··
·· if chardata == "p"
··· serio.str(erase)
··· waitcnt(clkfreq/100 + cnt)
··· repeat 20
···· tempd := lookupz(counter: "Program device······ ")
···· serio.char(tempd)
···· counter++
··· counter := 0
··· waitcnt(clkfreq + cnt)
··· serio.str(erase)
··· waitcnt(clkfreq/100 + cnt)
··· repeat 20
···· tempd := lookupz(counter: "O= Open N= new······· ")
···· serio.char(tempd)
···· counter++
··· counter := 0
··· serio.str(nextline)
···· repeat 7
····· tempd := lookupz(counter: "B= Back")
····· serio.char(tempd)
····· counter++
···
··· repeat
···· chardata := 0
···· readkb
······ if chardata == "b"
········ menu
······ if chardata == "o"
······· serio.str(erase)
······· counter := 0
······
········
·········
········· repeat 20
·········· tempd := lookupz(counter: "Type in file number")
·········· serio.char(tempd)
·········· counter++
··········
········· counter := 0·
······· repeat
··········
········· chardata := 0
········· readkb
·········· if chardata == "1"
··········· datapoint := 1
··········· editor
·········· if chardata == "2"
··········· datapoint := 2
··········· editor
·······
·········· if chardata == "3"
············ datapoint := 3
············ editor
·······
·······
······
······
······
·······
······
·····
····· if chardata == "n"
···
···
··
·
··
··
··
· if chardata == "o"
··· serio.str(erase)
··· waitcnt(clkfreq/100 + cnt)
···· repeat 7
····· tempd := lookupz(counter: "Options····· ")·
····· serio.char(tempd)
····· counter++
··· counter := 0
··· waitcnt(clkfreq + cnt)
··
··· serio.str(erase)
··· waitcnt(clkfreq/100 + cnt)
···· repeat 20
····· tempd := lookupz(counter: "E= Erase Mem b= Back")
····· serio.char(tempd)
····· counter++
··· counter := 0
··· waitcnt(clkfreq/2 + cnt)
···· repeat
····· chardata := 0
····· readkb
······ if chardata == "b"
······· menu
····· if chardata == "e"
······ address := 0
······ repeat
······· i2crw.write(%10100000, address, 0, 16)
······· waitcnt(clkfreq/700 + cnt)
······· i2cdata := 0
········ if addresspointer == 200
········· serio.str(erase)
········· addresspointer := 0
········· i2cdata := i2crw.read(%10100000, address, 16, 8)
········· serio.dec(i2cdata)
········· serio.dec(address)
······· addresspointer++
······· address++
········ if address > 10_000
········· menu
··
··
··
· if chardata == "m"
·· more
········
·waitcnt(clkfreq/100 + cnt)
pri checki2c
counter := 0
address := 32_000
i2crw.init(20,21,0)
serio.str(erase)
i2crw.write(%10100000, address, "A", 16)
waitcnt(clkfreq/100 + cnt)
i2cdata := i2crw.read(%10100000, address, 16, 8)
waitcnt(clkfreq/100 + cnt)
if i2cdata == "A"
·repeat 20
· tempd := lookupz(counter: "Memory device found······ ")
· serio.char(tempd)
· counter++
else
·repeat 20
· tempd := lookupz(counter: "EEPROM not found··· ")
· serio.char(tempd)
· counter++
waitcnt(clkfreq * 2 + cnt)
counter := 0
serio.str(erase)·
pub readkb
if kb.gotKey
·chardata := kb.getKey
pub More
counter := 0
serio.str(erase)
·
waitcnt(clkfreq/100 + cnt)
repeat 17
·tempd := lookupz(counter: "T= Tools B= Back····· ")
·serio.char(tempd)
·counter++
counter := 0
repeat
· chardata := 0
·
·· readkb
··
· if chardata == "t"
··· serio.str(erase)
··· waitcnt(clkfreq/100 + cnt)
···· repeat 12
····· tempd := lookupz(counter: "Tools······ ")
····· serio.char(tempd)
····· counter++
···· counter := 0
·· waitcnt(clkfreq + cnt)
·· more·········
··
··
· if chardata == "b"
·· menu
·waitcnt(clkfreq/100 + cnt)·
pub editor
serio.str(erase)
waitcnt(clkfreq + cnt)
serio.dec(datapoint)
waitcnt(clkfreq + cnt)
menu
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
THANK you timmoore. You are referring to the strings that i have up toward the top. SO they return the long address of where the string is in memory? I acctually had problems with those to. Every time i tried to add another string the whole thing went nuts. So if i took them out would that eliminate the problem. Maybe that is the problem. Do you know of another way to put info into Strings?
A string in spin is a null terminated byte array.
So the following would work, note I have increased the size of the arrays by 1 for the null(0) terminator
dat
erase byte 254, 81, 0
nextline byte 254, 69, 60, 0
welcome byte "Welcome to", 0
starrider byte "StarRider V 3.0", 0
...
serio.str(@erase)
serio.str(@Welcome)
serio.str(@nextline)
serio.str(@starrider)
Or you could use the string·directive to do it inline.
serio.str(string(254, 81))
serio.str(string("Welcom to"))
serio.str(string(254, 69, 60))
serio.str(string("StarRider V 3.0"))
The string directive automatically adds the zero at the end, and it stores the string data within the program instead of in a DAT section.· However, it will create multiple identical strings if you use it with the same string of characters in multiple places in your program.· In that case, it may be better to define the string once in a DAT section.
Dave
·