constant declaration
StampNut2
Posts: 224
Please can someone on this forum advise me if this text is correct to insert on each program for constant declarations for each of the stamp chips. Is it inserted at the beginning of each program?
Thanks
#SELECT $STAMP
#CASE BS2, BS2E
CycAdj CON $100 ' x 1.0, adjustment (for ms)
#CASE BS2SX
CycAdj CON $280 ' x 2.5
#CASE BS2P
CycAdj CON $188 ' x 1.53
#CASE BS2PE
CycAdj CON $09E ' x 0.62
#ENDSELECT
RampTm CON 15 ' 15 ms per level
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never give up when things go wrong.
Thanks
#SELECT $STAMP
#CASE BS2, BS2E
CycAdj CON $100 ' x 1.0, adjustment (for ms)
#CASE BS2SX
CycAdj CON $280 ' x 2.5
#CASE BS2P
CycAdj CON $188 ' x 1.53
#CASE BS2PE
CycAdj CON $09E ' x 0.62
#ENDSELECT
RampTm CON 15 ' 15 ms per level
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never give up when things go wrong.
Comments
This is the code that I use as a template in nearly all of my BSxx programs. I don't use the BS2e, but this should help you verify your code (this all works).
I do this because I tend to run the same code on several Stamp platforms with different chips and this way I don't have to worry about making code changes. I just got into·the habit of always using·scaling when I write the code, i.e. PULSOUT 13,·Dur */ PScale. I also use the baud rates section by defining·a variable (could also be another constant if space is a concern)·and setting it equal to the constant derived by the conditional code.· i.e.· BRate··VAR· Word·and then BRate = T9600.· Then in my code I just use BRate·like this:· SEROUT TxPin. Brate, [noparse][[/noparse]"C", 63, 63, 20, $F8, $00] allowing me to change baud rates by changing a single variable (BRate from T9600 to T19K2) without having to find and change every occurrence.
Steve
Post Edited (Duffer) : 8/20/2007 9:22:47 PM GMT
These are the constants for a specific program and for multiple BASIC Stamp Models. Not every program need start like this. Reading the, “What’s a Microcontroller?” manual might give you some more simple examples of how to format your code. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never give up when things go wrong.