constant declaration
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).
'**************** 'Constants '**************** #SELECT $STAMP 'PULSOUT/PULSIN Scaling #CASE BS2 PScale CON $0100 #CASE BS2P, BS2PX PScale CON $0280 #ENDSELECT #SELECT $STAMP 'FREQOUT Duration Scaling #CASE BS2 FODScale CON $0100 #CASE BS2P, BS2PX FODScale CON $03C6 #ENDSELECT #SELECT $STAMP 'FREQOUT Freq Scaling #CASE BS2 FOFScale CON $0100 #CASE BS2P, BS2PX FOFScale CON $0044 #ENDSELECT #SELECT $STAMP 'Baud Rates #CASE BS2 T1200 CON 813 T2400 CON 396 T4800 CON 188 T9600 CON 84 T19K2 CON 32 T38K4 CON 6 #CASE BS2P T1200 CON 2063 T2400 CON 1021 T4800 CON 500 T9600 CON 240 T19K2 CON 110 T38K4 CON 45 #ENDSELECTI 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.