I had a misconception about the BS2px24
MovieMaker
Posts: 502
I thought when you hit the buttons up there in the stamp editor that switched from the say BS2 to the chip of your choice and hit the buttons to switch to 2.5 basic, I thought that it automatically changed the syntax for you. I mean, if you had a program that worked perfectly on the basic stamp 2 and you upgraded the chip to a higher cpu like the BS2px24 like mine it would automatically change things to match the new parameters. So, if I am understanding correctly, you have to do your calculations and change the formulas to match the speeds of the cpus. I guess I am understanding correctly. If I am, this would make the whole picture of why things were not working correctly on my bots. Timing is everything.
Am I correct in the above statements?
Thanks,
Am I correct in the above statements?
Thanks,
Comments
You are correct. You will need to change any constants in commands involving timing (i.e., SERIN, SEROUT, PULSIN, PULSOUT, FREQOUT, and others). The BASIC Stamp Windows Editor doesn't do this for you - it only puts a BS2px directive at the top of your program. Changing the values is up to the programmer.
Considering timing is everything, this is why your BS2 code won't function as expected in other BS2-style modules.
Ken Gracey
There also was a template file you would use that had a select/case that set parameters for the different chips but I can't find it now.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
[noparse]/noparse Change Serial Rates
[noparse]/noparse Change Shift Rates
[noparse]/noparse Change Constant _____ to ____
Stephen, if you see the temple I would love to have a link.
It has taken months, but now things are becomming in focus! I thank the person who I read in another thread an article that made me think of such a possibility.
God Bless!~
Is it merely to inform the programmer that the following program is specific to that stamp but otherwise has no effect on the compiled program?
just interested to understand the thinking behind it.
Also, you can use conditional compilation based on the model of stamp you are using. Many of the Parallax examples are written to work with multiple models. You will see code like:
#SELECT $STAMP
· #CASE BS2, BS2E, BS2PE
··· T2400 CON 396
··· T9600 CON 84
··· T19K2 CON 32
· #CASE BS2SX, BS2P , BS2PX
··· T2400 CON 1021
··· T9600 CON 240
··· T19K2 CON 110
#ENDSELECT
This will substitute the correct baud rate constant depending on the model of stamp specified.
I'm not sure what the thinking was behind it, but this may assist in your understanding of the PBASIC directives. The real source for these questions is the author of the PBASIC language. Since he's not available at the moment, I guess this will have to do.
I guess the best way I'd describe the PBASIC $STAMP Directive is to say that there are differences among the different PBASIC Stamp models, such that the interpreter knows which one its dealing with. The author of the IDE may have different PCODEs for the different Stamp models. This is a supposition on my part, so don't take it as gospel. If you would like to see what the PBASIC Help file says, here it is:
"The $STAMP directive is a special compiler command that must be included (usually near the top) in a program to indicate the model of BASIC Stamp targeted." In addition to that, its also used to indicate the names of each of the programs which are to be fetched for inclusion in the each of the banks which are used in a multi-bank project. A project is just a collection of separate PBASIC programs which comprise one single and cohesive unit.
As far as the PBASIC $PORT directive is concerned, here's what the PBASIC Help file says:
"The purpose of the $PORT directive is to select a specific serial port for programming the BASIC Stamp. Both standard serial and USB ports (with proper adapter circuitry) may be used. The syntax is as follows:
' {$PORT COM#}
where # is a valid port number. When any PBASIC program containing this directive is downloaded, all other ports will be ignored. This directive is especially important if using two of the same BASIC Stamp models (such as two BS2 modules) on two COM ports and you have two different PBASIC programs to download (one for each BS2). Without this directive, developing and downloading in this case would be a tedious task of always answering the "which Stamp?" prompt."
Lastly, here is what the PBASIC Help file says about $PBASIC:
"The $PBASIC directive allows the programmer to specify the syntax level for the compiler to use. Example:
' {$PBASIC 1.0} ' use version 1.0 syntax (BS1 only)
' {$PBASIC 2.0} ' use version 2.0 syntax
' {$PBASIC 2.5} ' use version 2.5 syntax
Note that while the $PBASIC directive is optional, only version 1.0 syntax is allowed when using a BS1 module. If an attempt is made to select an incompatible syntax for the specified $STAMP directive, the editor will generate a warning. Buttons on the editor tool bar simplify adding or modifying the $PBASIC directive.
That is a summary of the various PBASIC Directives.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When all else fails, try inserting a new battery.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Post Edited (Chris Savage (Parallax)) : 12/1/2008 11:15:39 PM GMT