Need More Memory or smaller program
Cline
Posts: 36
Hello everyone,
I have working on a tracking system using camera,Ir and thermal, using a bs2 and matrix lcd with keypad.
I written the code for the basic program and Chris Savage helped me get the lcd working, All is well except that all the serout's to the lcd take up all the memory, I use the camera on app mod and wired the ir and thermal,
so its all together just not enough room for programing all of them. I have another board of education and was wondering if i should move some systems to it or could i just wire two pins together and use the memory from the other, I just need some direction, What is the best way,,,
can i buy a memory mod?
thanks guys,girls
Cline
C.E.O.
Integrated Security Services
I have working on a tracking system using camera,Ir and thermal, using a bs2 and matrix lcd with keypad.
I written the code for the basic program and Chris Savage helped me get the lcd working, All is well except that all the serout's to the lcd take up all the memory, I use the camera on app mod and wired the ir and thermal,
so its all together just not enough room for programing all of them. I have another board of education and was wondering if i should move some systems to it or could i just wire two pins together and use the memory from the other, I just need some direction, What is the best way,,,
can i buy a memory mod?
thanks guys,girls
Cline
C.E.O.
Integrated Security Services
Comments
Sure would be nice if i understood how the stamp uses its memory,, im going to read up on it,
IF you would like to see the code let me know, ill post it,,
Thanks Again
Cline
C.E.O.
Integrated Security Services
Go ahead and post your program anyway.
http://www.parallax.com/detail.asp?product_id=BS2PE
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Andreae
Tech Support
dandreae@parallax.com
Http://www.parallax.com
Post Edited (Dave Andreae (Parallax)) : 6/28/2006 10:16:45 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
This code holds enough DATA to generate my whole touchscreen menu system I'm working on,... if i could only get the %$^& subroutines to work right with the program!!
And I thought the BS2 had 32K of E2 memory ....
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Definetly a E3 (Electronics Engineer Extrodinare!)
"I laugh in the face of imposible,... not because i know it all, ... but because I don't know well enough!"
· Thanks for all the help. Here is the code i have written so far, I would like help on condensing it. I omitted the main routine,but i would like to change how i enter the password to enter the program. I have to type the pasword into the debug terminal, i would like to have it on the keypad and it show up on the lcd,· Iv tried all i know, just cant get it together,
thanks guys, after this i will get the memory and hopefully this project will start taking shape,,
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG"Micro Board System " , CR
'
[noparse][[/noparse] Declarations ]
'LCD
'Interface
tx················· PIN······· 0······ 'Transmit pin to LCD
Rx················· PIN······· 1······ 'Receive pin from LCD
Baud··············· CON······· 84····· 'Equals baud rate of 9.6k
Int················ CON······· 254···· 'place befor each instruction
'Commands
Auto_Wrap_On······· CON······· 67·····
Auto_Wrap_Off······ CON······· 68·····
Auto_Scroll_On····· CON······· 81·····
Auto_Scroll_Off···· CON······· 82·····
Cursor_pos········· CON······· 71····· 'Needs Column and row
Cur_home··········· CON······· 72·····
Under_Line_On······ CON······· 74·····
Under_Line_Off····· CON······· 75·····
Blinking_On········ CON······· 83·····
Blinking_Off······· CON······· 84·····
Cursor_Left········ CON······· 76·····
Cursor_Right······· CON······· 77·····
Clear_screen······· CON······· 88·····
Contrast··········· CON······· 80····· 'Needs level $00 to $FF
Backlight_On······· CON······· 66····· 'SET $00 = on, minute max $FF
Backlight_Off······ CON······· 70····· ''See LCD manual for more detail
GP_pin_off········· CON······· 86····· 'NEEds $01 to $06 for pin #
GP_pin_on·········· CON······· 87····· 'NEEds $01 to $06 for pin #
'Key pad
Auto_repeat_on····· CON······· 126···· '$00 = resend $01 = key up/down
Auto_repeat_off···· CON······· 96·····
Auto_Trans_On······ CON······· 65····· 'Sends key press data immediately
Auto_Trans_Off····· CON······· 79····· 'STORE 10 key presses until polled
Clear_buffer······· CON······· 69····· 'See LCD manual for more detail
Poll_keypad········ CON······· 38····· 'Polls LCD for last key press
Debounce_time······ CON······· 85····· 'Set in 6.554ms units default 52mS
'Bar graphs
Wide_vert_bar······ CON······· 118···· 'Initialize wide vertical bar
Naro_vert_bar······ CON······· 115···· 'Initialize narrow vertical bar
Draw_vert_bar······ CON······· 61·····
Horz_bar··········· CON······· 104···· 'Initialize horizontal bar
Draw_horz_bar······ CON······· 124
Cusstom_char······· CON······· 78·····
Large_dig·········· CON······· 110
Place_lrg_dig······ CON······· 35····· 'Column $01/$12 digit $00/$09
'data directives
Password··········· DATA··· "33722"
'variable declarations
index······· VAR·· Nib
userentry··· VAR·· Byte(5)
·temp··············· VAR······· Byte··· 'Working variable
Key················ VAR······· Byte··· 'key storage variable
io_pin············· VAR······· Byte··· 'GP I/O variable
'initialization routine
GOSUB check_password
'main routine
DEBUG CR, "complete"
END
'subroutine
check password
check_password:
·DO
· DEBUG CR,"Enter Password"
· DEBUGIN STR userentry \5
· FOR index=0 TO 4
· READ password + index, temp
· IF temp <> userentry(index) THEN EXIT
· NEXT
· IF index <> 5 THEN
· DEBUG CR, "password incorrect"
· ENDIF
· LOOP UNTIL index=5
· DEBUG CR, "accessed"
'display
·SEROUT 0, 84, [noparse][[/noparse]Int,Clear_screen]······· 'Command Prefix
SEROUT 0, 84, [noparse][[/noparse]"· Mainframe Online "]
PAUSE 2000
·SEROUT 0, 84, [noparse][[/noparse]Int,Clear_screen]
·SEROUT 0, 84, [noparse][[/noparse]"····· A.W.O.T. "]
·SEROUT 0, 84, [noparse][[/noparse]"·········· SYSTEMS· "]
·PAUSE 2000
· SEROUT 0, 84, [noparse][[/noparse]Int,Clear_screen]
· SEROUT Tx,Baud,[noparse][[/noparse]"DESIGNED BY ",Int,Cursor_pos,1,2,
·············· "Charles Cline", Int,Cursor_pos,1,4,"Starting Sub-Program"]
· '
[noparse][[/noparse] Initialization ]
PAUSE 4000····························· 'Waits for 250ms
Initialize:··························· 'label
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]····· 'Clears screen
SEROUT Tx,Baud,[noparse][[/noparse]Int,Auto_trans_off]··· 'Turns off buffer for key pad
'Sets up text on LCD
SEROUT Tx,Baud,[noparse][[/noparse]"Press 0-9 or A to",Int,Cursor_pos,1,2,
·············· "POWER on all systems",
·············· Int,Cursor_pos,1,3,"B to turn them all",
·············· Int,Cursor_pos,1,4,"off.C to Exit,D=MP"]
'
[noparse][[/noparse] Main Routine ]
In_Put:······························· 'Label
GOSUB key_pad························· 'Jumps to key pad polling routine
· IF key = "#" THEN I_O_On············ 'coMPares key and jumps if true
· IF key = "*" THEN I_O_Off··········· 'coMPares key and jumps if true
GOTO In_Put··························· 'Jumps to listed label
'
[noparse][[/noparse] Subroutines ]
I_O_Off:······························ 'Label
'Sends text to LCD
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen,"I/O pin ",DEC io_pin,Int,Cursor_pos,1,2,
·············· "Is now turned off. "]
SEROUT Tx,Baud,[noparse][[/noparse]Int,GP_Pin_Off,io_pin] 'SetS I/O pin to off
PAUSE 2000···························· 'PAUse for 2000ms
GOTO Initialize······················· 'JUmps to listed label
I_O_On:······························· 'Label
'Sends text to LCD
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen,"I/O pin ",DEC io_pin,Int,Cursor_pos,1,2,
·············· "Is now turned on. "]
SEROUT Tx,Baud,[noparse][[/noparse]Int,GP_Pin_On,io_pin]· 'listed I/O pin to on
PAUSE 2000···························· 'Pause for 2000ms
GOTO Initialize······················· 'Jumps to listed label
key_pad:······························ 'Label
SEROUT Tx,Baud,[noparse][[/noparse]Int,Poll_keypad]······ 'Request last key press from LCD
SERIN Rx,Baud,[noparse][[/noparse]temp]·················· 'Store key press in temp
· IF temp = 0 THEN key_pad············ 'coMPares key and jumps if true
·· GOSUB Convert······················ 'JumP to listed label
· IF temp = "A" THEN All_On··········· 'coMPares key and jumps if true
· IF temp = "B" THEN All_Off·········· 'coMPares key and jumps if true
·IF temp = "C" THEN Exit_p
·IF temp = "D" THEN Main_P
·IF temp= "1" THEN One_p
·IF temp= "2" THEN Two_p
· IF temp= "3" THEN Three_p
IF temp= "4" THEN Four_p
· IF temp= "5" THEN Five_p
· IF temp= "6" THEN Six_p
· IF temp= "7" THEN Seven_p
· IF temp= "8" THEN Eight_p
· IF temp= "9" THEN Nine_p
· IF temp= "0" THEN zero_p
· IF temp > 54 OR temp < 49 THEN Error 'coMPares key and jumps if true
'Displays in ASCll
io_pin = temp - 48···················· 'Converts ASCll to decimal
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen,"Please press an * to",Int,Cursor_pos,1,2,
·············· "turn off Pin ",DEC io_pin," or #",Int,Cursor_pos,1,3,
·············· "to turn it on."]
Wait_For_key:························· 'Label
'Displays character typed in ASCll
SEROUT Tx,Baud,[noparse][[/noparse]Int,Poll_keypad]······ 'Request last key press from LCD
SERIN Rx,Baud,[noparse][[/noparse]temp]·················· 'Store key press in temp
IF temp = 0 THEN Wait_For_key········· 'If no key Press jump to label
· GOSUB Convert······················· 'Jump to listed label
· key = temp·························· 'StorES temp in to key variable
RETURN································ 'Jump to next line UNDER last gosub
Convert:······························ 'Label
'Table to convert variable
LOOKDOWN· temp,[noparse][[/noparse]66,67,68,69,71,72,73,74,76,77,78,79,81,82,83,84],temp
'Table to convert variable
LOOKUP··· temp,[noparse][[/noparse]"D","#","0","*","C","9","8","7","B","6","5","4","A","3",
·············· "2","1"],temp
RETURN································ 'Jump to next line UNDER last gosub
All_On:
·SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]······························ 'Label
SEROUT Tx,Baud,[noparse][[/noparse]"All on"]············· 'Displays text
FOR io_pin = 1 TO 6··················· 'CyCLEs io_pin variable fro 1 to 6
·SEROUT Tx,Baud,[noparse][[/noparse]Int,GP_Pin_On,io_pin] 'SETs listed I/O pin to on
NEXT·································· 'cycles until io_pin = 6
PAUSE 1000···························· 'Pauses for 1000 ms or 1 second
GOTO Initialize······················· 'Jumps to listed label
All_Off:
·SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]····························· 'Label·· INCOmPlETE
SEROUT Tx,Baud,[noparse][[/noparse]"All Off"]············ 'Displays text
FOR io_pin = 1 TO 6··················· 'CYCles io_pin variable fro 1 to 6
·SEROUT Tx,Baud,[noparse][[/noparse]Int,GP_Pin_Off,io_pin]'Sets listed I/O pin to off
NEXT·································· 'cycles until io_pin = 6
PAUSE 1000···························· 'Pauses for 1000 ms or 1 second
GOTO Initialize······················· 'Jumps to listed label
Error:································ 'Label
·SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]···· 'Clears screen
'Displays text
·SEROUT Tx,Baud,[noparse][[/noparse]"······· ERROR··············· "]
·PAUSE 1000··························· 'Pauses for 1000 ms or 1 second
GOTO Initialize······················· 'Jumps to listed label
·· ' dont know where these go
Exit_p:
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
··· SEROUT Tx,Baud,[noparse][[/noparse]"··· ..WARNING..",Int,Cursor_pos,1,2,
·············· "*All SYSTEMS LOCKED*" ]
·············· PAUSE 500
·· GOTO check_password
·· Main_p:
··· SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Main· Program "]
·· PAUSE 500
···· GOTO Initialize
··· One_p:
· SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"Camera· Program "]
·· PAUSE 1000
·· GOTO Initialize
·Two_p:
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"I.R.Tracking Program "]
·· PAUSE 1000
· GOTO Initialize
·Three_p:
·SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"Thermal· Program "]
·· PAUSE 1000
·· GOTO Initialize
Four_p:
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"Bluetooth Program "]
·· PAUSE 1000
·· GOTO Initialize
Five_p:
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Five· Program "]
·· PAUSE 500
·· GOTO Initialize
Six_p :
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Six· Program "]
·· PAUSE 500
·· GOTO Initialize
Seven_p:
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Seven· Program "]
·· PAUSE 500
·· GOTO Initialize
Eight_p:
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Eight Program "]
·· PAUSE 500
·· GOTO Initialize
Nine_p :
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Nine Program "]
·· PAUSE 500
·· GOTO Initialize
· zero_p :
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Zero Program "]
·· PAUSE 500
·· GOTO Initialize
You should be able to take the following part of your program and change it as shown:
IF temp= "0" THEN zero_p
IF temp= "1" THEN One_p
IF temp= "2" THEN Two_p
IF temp= "3" THEN Three_p
IF temp= "4" THEN Four_p
IF temp= "5" THEN Five_p
IF temp= "6" THEN Six_p
IF temp= "7" THEN Seven_p
IF temp= "8" THEN Eight_p
IF temp= "9" THEN Nine_p
Change to:
On temp GoTo (zero_p, One_p, Two_p, Three_p, Four_p, Five_p, Six_p, Seven_p, Eight_p, Nne_p)
I suspect the variable "io_pin" can also be changed to a NIB sized variable.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Post Edited (Bruce Bates) : 7/1/2006 9:19:27 PM GMT
' On temp goto........... just like you wrote it?
·
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]·····
Make a sub-routine:
clr_scrn:
·SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·RETURN
Then, Wherever you currently have SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen] -- replace it with GOSUB clr_scrn
I think that alone will recover about Hex200 in program space.
Also, you might consider some abbreviations, eliminating 'dots', etc.
table Data "a",10,"choice 000",
Data 0
Each entry starts with a byte containing the menu choice character
The next byte contains the total size of the string that follows
Next is the text to be sent to the display
The next table entry follows this one and the last entry is followed by a zero byte (for the menu choice character)
ptr = table
gosub doit
...
doit: read ptr,menu
ptr = ptr + 1
if menu = 0 then notthere
if menu = theChar then gotit
read ptr,menu
ptr = ptr + menu
goto doit
gotit: serout tx,baud,[noparse][[/noparse]int,clearscreen]
read ptr,count
domore:
ptr = ptr + 1
read ptr,temp
serout tx,baud,[noparse][[/noparse]temp]
count = count - 1
if count > 0 then domore
return
notthere:
?????
return
SEROUT Tx,Baud,[noparse][[/noparse]"Bluetooth Program "]
where the display text is part of a serout or debug command consumes gobs of program space. It is much more efficient to store the text in DATA statements and use a display routine to read them out:
oops -- I editied the program to increment daPointer
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Post Edited (Tracy Allen) : 7/1/2006 5:52:24 PM GMT