PDA

View Full Version : Hardware and memory questions



thikyela
02-24-2010, 01:20 AM
Howdy. I am using a BS2 Homework board for a school project. My program has exceeded the max eeprom space (2K), and I need to upgrade.

There are "Board of Education" Rev B. boards available at my school. They have removable IC chips (they are BS2-ICs, same memory as the one I own). Can I use any of these modules, like the BS2e, in these boards? This one in particular..

http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/CategoryID/9/List/0/SortField/0/Level/a/ProductID/2/Default.aspx

Also, I understand that there is actually, in this particular example, 8 X 2K program 'slots'. Since I use several sub-programs to make up the overall program, can I just move a few into another 'slot', or is it not that simple?

When I load my program into the Basic Stamp Editor, how does it 'know' that eeprom is exceeded? Is it the directive? Because even if i change that, I am still going over some kind of limit. Or is this another instance of the 2K 'slot' being exceeded?

Any help would be greatly appreciated. I can't seem to find specific answers on the parallax site.

Thank you
Scott

Mike Green
02-24-2010, 01:39 AM
1) The Board of Education can be used with any of the Stamp modules including the BS2e that you mentioned.

2) Each program slot is 2K and should be thought of as an "overlay" area. The way to execute code in another slot is to use the RUN statement which is like a GOTO in that there's no way to return to the place where the RUN was executed.

3) All programs must fit in 2K. That's the limit that the Stamp Editor is checking.

There's a good discussion of multi-slot programming in one of the Nuts and Volts Columns (#87).

www.parallax.com/Resources/NutsVoltsColumns/NutsVoltsVolume3/tabid/445/Default.aspx (http://www.parallax.com/Resources/NutsVoltsColumns/NutsVoltsVolume3/tabid/445/Default.aspx)

thikyela
02-24-2010, 07:04 AM
Thanks Mike. I see, so I would be able to goto another slot, but only to the beginning, not where I came from, like gosub and return allows. That might work.

I could also try and tidy up my exceptionally large piece of code. I know it's possible, I'm just not that good at programming.

For example...

FOR P = 1 TO 4

DO

IF keyready = 1 THEN 'checks if a key is pressed
GOSUB getkey 'retrieves the new key
IF Key = PassD(P) THEN ' checks key value against stored password digit (1-4)
D(P)OK = 1 'sets flag for this iteration's digit (if correct)
ENDIF
ENDIF
LOOP UNTIL Key <> 100 'key needs to be pressed to proceed to next for
SEROUT LCDpin, baudlcd, ["*",9] 'shifts a * to the right on LCD to show a key was pressed
PAUSE 400
key=100 'changes key back to impossible number
NEXT P
IF (D1Ok=1 AND D2ok=1 AND D3ok=1 AND D4ok=1) THEN 'if all numbers match the stored password...

PULSOUT TimerRESET, 10 'resets timer
PAUSE 10
PULSOUT Trigger, 10
PAUSE 10
D1ok=0:D2ok=0:D3ok=0:D4Ok=0 'resets digit flags
RETURN

ELSE
GOSUB clearLCD
SEROUT lcdpin, baudlcd, ["Incorrect",149, "Password"]
PAUSE 2000
D1ok=0:D2ok=0:D3ok=0:D4Ok=0
GOSUB EnterPass
ENDIF

Right now I have a working password checker consisting of a bunch of if thens. I know from other BASIC types of programming you can use a for next loop, which I would like to do. I'm not sure how to get this to work with my program, though. All this basically does is goes and checks PassD1 through PassD4 against the key pressed. It would make my day if I can use the 'P' variable in place of the number (PasssD(P)), and not use 4 separate do loops. Or something to this effect. If anyone with more brains than I can offer a suggestion, I sure could use one.

Thank you
Scott