Existential question: Why don't Stamps do floating point math?
Migs
Posts: 95
Friends:
This is an off the wall musing, but I see chips getting smarter every day yet unable to do basic floating point math. I also see the workarounds, and the lengths we all go to to avoid these numbers (primarily because of the on chip space "wasted" by this type of math ???). Is it so much to ask for these abilities?
Similarly, the Basic uses DEBUG to write back to the computer. What happened to the rest of the BASIC language commands (like for printing) Were they thought NOT to be useful?
What do you all know about all this?
As always, best regards -Migs
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Sometimes we forget that the world itself is paradise." Douglas Coupland, 'Microserfs'
"If the doors of perception were cleansed every thing would appear to man as it is, infinite" - William Blake
"We either make ourselves miserable, or we make ourselves strong. The amount of work is the same." Carlos Castaneda
"One single grateful thought raised to heaven is the most perfect prayer. " G. E. Lessing
“How much of human life is lost in waiting.” Ralph Waldo Emerson
"Men often mistake notoriety for fame, and would rather be remembered for their vices and follies than not be noticed at all.” Harry Truman
My website: www.intoku.net my e-mail:mreznicek@pretensa.com me:Miguel Reznicek
This is an off the wall musing, but I see chips getting smarter every day yet unable to do basic floating point math. I also see the workarounds, and the lengths we all go to to avoid these numbers (primarily because of the on chip space "wasted" by this type of math ???). Is it so much to ask for these abilities?
Similarly, the Basic uses DEBUG to write back to the computer. What happened to the rest of the BASIC language commands (like for printing) Were they thought NOT to be useful?
What do you all know about all this?
As always, best regards -Migs
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Sometimes we forget that the world itself is paradise." Douglas Coupland, 'Microserfs'
"If the doors of perception were cleansed every thing would appear to man as it is, infinite" - William Blake
"We either make ourselves miserable, or we make ourselves strong. The amount of work is the same." Carlos Castaneda
"One single grateful thought raised to heaven is the most perfect prayer. " G. E. Lessing
“How much of human life is lost in waiting.” Ralph Waldo Emerson
"Men often mistake notoriety for fame, and would rather be remembered for their vices and follies than not be noticed at all.” Harry Truman
My website: www.intoku.net my e-mail:mreznicek@pretensa.com me:Miguel Reznicek
Comments
Since the Stamps have been developed, processors have become more powerful. For example, the Propeller, even though it's primarily a 32 bit integer processor, has some support in the Spin compiler for floating point and there's a complete floating point library available in the Object Exchange. You have to use function calls instead of using the arithmetic operators, but floating point is there and is pretty speedy (download the Floating Point object for the documentation with the speeds).
The Stamps are pretty stable with only small incremental changes made. With inexpensive 3rd party floating point processors available for the Stamps and the floating point capability of the Propeller, I don't think there's much advantage to adding floating point support to the Stamps.
The PRINT command and the INPUT command in standard Basic are intended for file I/O and console I/O. PBasic does the equivalent with the several output/input commands like SEROUT/SERIN, I2COUT/I2CIN, SHIFTOUT/SHIFTIN, etc. and DEBUG/DEBUGIN. Theoretically, these could have been switched to the standard statements between the BS1 and BS2 models, but the standard Basic statements don't fit easily into the task of low level I/O control that the PBasic statements provide.
So to answer you more directly, the standard Basic statements didn't work with the very limited BS1 interpreter platform and there was more to be gained in keeping and extending the PBasic statements for the BS2 interpreter rather than switching to the standard statements that don't fit the function needed. Similarly, floating point was too slow and too memory intensive for inclusion in the BS1 and early BS2 models and there's not enough to be gained by adding it now rather than other new features like those in the BS2px. Someone who needs that kind of computational support should either use an external processor or switch to the Propeller.
Harrison
In addition to what's already been said, the BASIC commands (like) PRINT, INPUT and similar commands require device dependence. By contrast, the PBASIC commands SERIN/SEROUT, SHIFTIN/SHIFTOUT and similar commands don't care what type of device is sending the serial data, only that it exists.
DEBUG is only one way of sending asynchronous serial data back to a PC. DEBUG is just a specific and limited form of SEROUT, to a dedicated pin port. Again there is a form of device dependence (in this case a particular pin port) so if you want more device independence, and greater abilities in formatting and the like, SEROUT is a far better command to use than DEBUG.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thanks for the explanations. What I had in mind with the print statement, was for one for example to be able to recieve input from the stamp via the laptop and print output. For example: every time a value goes high to print something on a printer. Similarly if one could open for output then input comming from the Stamp through the laptop could be written to a file. That's kind of why I miss many of the unimplemented Basic commands.
As for floating point, I would like to do floating point to do trigonometry for range computation of a sensor, or averaging of values read by a sensor or for example to encrypt some user inputed key strokes via a keypad. This last one brings me to the following question: Are you folks aware of a floating point coprosessor that can be added easily to the Basic Stamp 2 series and of a way to increase the memory (via perhaps an add on chip) that would make writing a much larger program to the Basic Stamp? For example: lets say my Boe Bot has several programs, and I would like to choose between them at a remote place where my laptop isnt availaible, then I could select amongst the ones in the extended memory. The basic requirement would be that all this run in the Basic Stamps Basic language, as I am great at making C mistakes and whence frustrated, giving up!
Thanks again for sharing your insight.
Migs
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Sometimes we forget that the world itself is paradise." Douglas Coupland, 'Microserfs'
"If the doors of perception were cleansed every thing would appear to man as it is, infinite" - William Blake
"We either make ourselves miserable, or we make ourselves strong. The amount of work is the same." Carlos Castaneda
"One single grateful thought raised to heaven is the most perfect prayer. " G. E. Lessing
“How much of human life is lost in waiting.” Ralph Waldo Emerson
"Men often mistake notoriety for fame, and would rather be remembered for their vices and follies than not be noticed at all.” Harry Truman
My website: www.intoku.net my e-mail:mreznicek@pretensa.com me:Miguel Reznicek
You could do the PRINT thing you describe using SEROUT, but it would require programming on the PC side. If you had a printer with a serial port (not very common these days), you could even print directly from the Stamp using SEROUT.
Parallax sells two different models of floating point co-processors. Here's one: www.parallax.com/detail.asp?product_id=604-00030
There's no way to add extended program memory beyond what's already available. All of the Stamp models beyond the BS2 have multiple "slots" which each store a 2K program and one program can transfer control to another. Most current Stamps have 8 slots. Using the Stamp Editor, you can indicate in the program source which slot to load. For the kind of situation you describe, some people have created a "menu" program in slot 0 (the default) usually using a small LCD display and a keypad or a couple of pushbuttons for control. When the Stamp starts up, it asks which program you want, allows you to enter its number, then runs that program. Alternatively, you could use a Stache which is a small program loader you can get from EMESystems (www.emesystems.com). This is a small device that works with a serial BoeBot or other serial Stamp board, holds 8 programs, looks like a Stamp to the Stamp Editor (for loading it) and it looks like the Stamp Editor to a Stamp. You use a pushbutton and LED to select which program to download. I've used this for backup of several versions of a program for an out-of-town project where there were simpler "fall-back" versions if part of the hardware didn't work.
RE: Paragraph 2 You hit the nail on the head! There are, in fact, floating point co-processors. http://www.micromegacorp.com/
Hmmm· clearly mike and I were composing reponses at the same time...· does hearing the same thing twice (independently)·make a point?· <BIG GRIN HERE>··
Pete
Post Edited (pwillard) : 7/19/2007 1:57:13 PM GMT
To this theme:
The article by Mr.Gracy http://www.byte.com/art/9412/sec13/art3.htm
shows that he has reduced a Sine Wave calculation down to 6 steps. But really, who has time for this? Who has the cognitive ability for this? That - is why our chips must do floating point math.
Comments?
Migs
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Sometimes we forget that the world itself is paradise." Douglas Coupland, 'Microserfs'
"If the doors of perception were cleansed every thing would appear to man as it is, infinite" - William Blake
"We either make ourselves miserable, or we make ourselves strong. The amount of work is the same." Carlos Castaneda
"One single grateful thought raised to heaven is the most perfect prayer. " G. E. Lessing
“How much of human life is lost in waiting.” Ralph Waldo Emerson
"Men often mistake notoriety for fame, and would rather be remembered for their vices and follies than not be noticed at all.” Harry Truman
My website: www.intoku.net my e-mail:mreznicek@pretensa.com me:Miguel Reznicek
If you really need to delve into floating point solutions, you are really looking in the wrong place. You should be looking into the Propeller product.
Awesome information! You can't imagine what a useful reply to a post this is. I never knew about slots! Thank you - thank you!
Dear pwilard:
In reference to "paragraph 1" I do understand what you say, but by having to invoke yet another programming environment jut to print out output involves a huge complexity: Getting that other application to talk to the Stamp, learning yet another programming environment, etc. It would all be so much easier to have it all in one place. Remember, that like me, many of the Basic stamp folks are mere mortals with limited EE and CE knowledge, so if the Basic Stamp programming environment had these Basic standard commands, it would be so much easier. As an aside, I'm 47 and I asked my school superintendent at what age they teach kids basic at school. He looked at me as if I were from another planet. "We don't do that anymore..." If Basic gets watered down with the passage of time, even our kids will wonder of what use it was in the first place!
To all of you:
I apologize for waxing about Basic, as surely, like you all, I too enjoy what we have here in with the Basic Stamp and the marvelous job Parallax has done of documenting and teaching micros. It's just fun to put my finger on something I have doubts about and have the most knowledgeable people in the world (you) to give me your feel on it. As an aside, I got a ton out of this small conversation just learning about slots!
Outstanding! I am grateful! - Migs
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Sometimes we forget that the world itself is paradise." Douglas Coupland, 'Microserfs'
"If the doors of perception were cleansed every thing would appear to man as it is, infinite" - William Blake
"We either make ourselves miserable, or we make ourselves strong. The amount of work is the same." Carlos Castaneda
"One single grateful thought raised to heaven is the most perfect prayer. " G. E. Lessing
“How much of human life is lost in waiting.” Ralph Waldo Emerson
"Men often mistake notoriety for fame, and would rather be remembered for their vices and follies than not be noticed at all.” Harry Truman
My website: www.intoku.net my e-mail:mreznicek@pretensa.com me:Miguel Reznicek
To me, it makes sense that the debug statements do what they do and no more than that. I realize that there may be learning hurdles encountered when I mention PC based programming languages since I very well understand that constant brick wall myself. I don't just whip out a Visual Basic program either. What one person might consider real easy might take me months to do.
I also understand that PC's should save us effort and not actually make things harder for us, which is why I historically have written programs that write programs for me... if that make sense. I've written more of that kind of program than any other kind of code that I've written for the PC (and don't assume my list is very long). For example, right now, I'm writing a program that spits out a custom stamp template with code snippets inserted based on user choices I make. Will I ever finish it? Could be months...
There is no question FP can make application development far easier. That said, having developed several hard real-time control systems I find the overhead and (frequently) lack of accurate characterization of delays inherent in FP routines insurmountable roadblocks in development. I've used the BS2 as a supervisory control element in some hybrid digital/analog controls (automatic gain control of a very high power RF amplifier) and have had excellent results through nominally clever use of integer math. */ is your friend! With relatively little effort one is able to convert ADC values to voltages, map to power in Watts ... through simple lookup tables and interpolation compute power in dBm, etc. Most users are shocked to find out the actual product has no FP support. I hear "you must be wrong .. see? there is a decimal point in the number on the LCD". Ah, well, I can't choose my users!
I've been deeply impressed by what the staff at Parallax has managed to package in the PICs which comprise various stamps. The later Scenix controllers have a little more room but they're still nothing I'd mistake for a general purpose computer.
On the Propellor I've found the floating point library useful insofar as my applications have sufficient time to use it. Bear in mind that, with the internal log and antilog tables, combined with a 32-bit word size, you have at your fingertips the ability to perform all kinds of operations: raising to powers, taking roots, efficiently multiplying, etc. etc. You can reasonably expect to perform a log/antilog conversion in 60 clock cycles or less, so its pretty good. This month's task is to implement a fuzzy control loop for a high power amplifier; I'm going to try and close the loop entirely in software on a Propellor (loop time constant ~100us) -- thereby eliminating an awful lot of analog hardware and saving some money (hopefully enough to make the pain of algorithm development worthwhile). To meet the time goal I'm compelled to use multiple cogs: one dedicated for fast data acquisition over SPI, a data computation service (all integer math), a user interface service, and a fast SPI output to DAC service. All memory linked. Good luck trying this on a general purpose computer with operating system overhead...
V/R
Mike
Thanks for the extensive comment. I am coming to realize that when some feature is not there and several iterations of the product have passed, that the mistake must be in my thinking and as such have to reconsider. I'm barely Basic Stamp 2 savy (If that is completely possible) so some of the advanced concepts you mention are years into my future. I do appreciate your thoughts! -Migs
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Sometimes we forget that the world itself is paradise." Douglas Coupland, 'Microserfs'
"If the doors of perception were cleansed every thing would appear to man as it is, infinite" - William Blake
"We either make ourselves miserable, or we make ourselves strong. The amount of work is the same." Carlos Castaneda
"One single grateful thought raised to heaven is the most perfect prayer. " G. E. Lessing
“How much of human life is lost in waiting.” Ralph Waldo Emerson
"Men often mistake notoriety for fame, and would rather be remembered for their vices and follies than not be noticed at all.” Harry Truman
My website: www.intoku.net my e-mail:mreznicek@pretensa.com me:Miguel Reznicek
Jean-Paul Sartre
or rephrased:
"Everything has been figured out, except some Basic Stamp code."
Migs
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Sometimes we forget that the world itself is paradise." Douglas Coupland, 'Microserfs'
"If the doors of perception were cleansed every thing would appear to man as it is, infinite" - William Blake
"We either make ourselves miserable, or we make ourselves strong. The amount of work is the same." Carlos Castaneda
"One single grateful thought raised to heaven is the most perfect prayer. " G. E. Lessing
“How much of human life is lost in waiting.” Ralph Waldo Emerson
"Men often mistake notoriety for fame, and would rather be remembered for their vices and follies than not be noticed at all.” Harry Truman
My website: www.intoku.net my e-mail:mreznicek@pretensa.com me:Miguel Reznicek
I forgot to mention a whole class of devices you may want to look at if you have an application that needs serious floating point work -- dedicated digital signal processing chips. Most of these dwarf most general-purpose microcontrollers in terms of complexity and power -- but there is no reason why a low-end controller can't be used in a supervisory role.
The only code I did for anything in this class was back in school, on the Texas Instruments TMS320-series devices. Back then these were state of the art, very expensive, and not much was available online (heh, there barely *was* an "online") in terms of code. With these I was doing real-time speech processing (generating spectrograms, filtering, etc). I imagine that now these chips would be pretty much dirt cheap compared to the new monsters on the market, and plenty powerful for most needs.
I've not played in this arena for about 8 years. I checked with the guy in the cube next to me, our DSP guru, an he suggests that the Analog Devices parts have a usability and power edge. Probably the industry leader right now are the Analog Devices SHARC processors; their latest generation are the "Blackfin", but the SHARCs are quite powerful:
http://www.analog.com/processors/sharc/
To get a feel for the machine you can get some emulation software from this link:
http://www.analog.com/processors/sharc/evaluationDevelopment/sharcProcessorTestDrive.html
The package is about 270Meg so I'd probably opt for the CD mailing option.
My DSP guy is under the impression the development tools cost some serious $$ but neither of us has a number.
Hope this helps!
Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Sometimes we forget that the world itself is paradise." Douglas Coupland, 'Microserfs'
"If the doors of perception were cleansed every thing would appear to man as it is, infinite" - William Blake
"We either make ourselves miserable, or we make ourselves strong. The amount of work is the same." Carlos Castaneda
"One single grateful thought raised to heaven is the most perfect prayer. " G. E. Lessing
“How much of human life is lost in waiting.” Ralph Waldo Emerson
"Men often mistake notoriety for fame, and would rather be remembered for their vices and follies than not be noticed at all.” Harry Truman
My website: www.intoku.net my e-mail:mreznicek@pretensa.com me:Miguel Reznicek