PDA

View Full Version : Maximum Amount of Variable ?

Duke
06-03-2005, 09:35 AM
Hello,

I'm a Basic Stamp 2P novice, I've been·working with a pulse detect device (Photo interupter + disc).
I would like to know·is the memory of Basic Stamp 2P enough to keep the data of 200 train pulses,
So that I count use these data to calculate later ex. Average, Max ,Min.

Like this..
w1=5.7 ms
w2=6.3 ms
w4=8.5 ms
...
w200= 11.3

or can I store these data into array

Duke..

Chris Savage
06-03-2005, 10:29 AM
Duke,

·· You don't need to store 200 pulses to calculate Average, Min and Max values.· You can do that on the fly using·maybe 4·variables.· One could store the Min value, one could store the max value, one could store the current value, and one to keep a running average based on the current value.· You could also store 5 samples at a time and run that average into a variable.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)

Duke
06-03-2005, 11:13 AM
Chris,

Thank you,
Im sorry but my question is not so clear about the propose of those data.
I will use them for Max Min Average and .. Data Recall. As I finished monitors those pulse 1 time I want to see the serie data in backward.

Like this..

w200=11.3 ms

press a button then show

w199=10.5 ms

...

In this case, how many data can I store or do I have to learn to keep them in EEPROM address

Duke..

Chris Savage
06-03-2005, 09:59 PM
Duke,

·· If they are BYTE sized data, you have 26 BYTES available, if you don't use any other variables, which is unlikely.· If they're WORD sized, you have 13 WORDS.· Now, storing them in EEPROM may be possible depending on how fast the data is coming in, and exactly how much you need to store.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)

allanlane5
06-04-2005, 12:46 AM
You could use an external EEPROM to store this data. Note it would only support a million writes or so per location, so you'll want to average out its use. Still, they are not expensive, and easily replaced.

You could also use the BS2 to take data, then immediately send it to a PC using the "SEROUT 16" command. Then save and do the math on the PC.

Tracy Allen
06-04-2005, 11:29 PM
You have a BS2p, so you could store this data in the scratchpad RAM, using PUT and GET statements. There are 127 locations, not quite the 200 you need. It looks like you need only one byte per reading:
FOR idx=0 TO 126
GOSUB detect_pulse
PUT idx,result ' 57 for 5.7 milliseconds and so on, 63, 85 ... 113
NEXT

FOR idx=0 TO 126
GET idx,result ' 57 for 5.7 milliseconds and so on, 63, 85 ... 113
DEBUG DEC result/10,".",DEC1 result,CR
NEXT

If you use the Stamp's internal eeprom, remember that the Stamp pauses until the WRITE completes, a delay ususally of around 5 miliseconds. If you use an external eeprom, the Stamp could aquire a new reading while the eeprom is still busy writing the old one, so the throughput could be faster. That is an issue only if the pulses follow one another closely. If you do use eeprom, be sure to implement a scheme that rotates around the entire eeprom space, that is, don't start each and every run at address zero. For each new run, start at a base address above the last run, and come back to the beginning only when the eeprom is full. A 32k eeprom could last a long time with that strategy.

I use an AT45 flash memory chip on my data loggers, and it has 528 bytes of RAM for this kind of buffering, apart from the flash memory.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

Duke
06-06-2005, 08:29 AM
Thank you very much.