BS1: Read values stored in EEPROM after re-connecting to PC
Hasenauer
Posts: 5
in BASIC Stamp
Hello everyone!
We use the BS1 for teaching purposes. We would like to save data (e.g. temperature) in the EEPROM (no problem using WRITE) while the BS1 is disconnected from the PC. And then, later on, we would like to show the data collected by re-connecting the BS1 to a PC. Therefore, we thought we could upload a second program that uses READ, since the lower adresses (0...) are not erased. My understanding is, that only the necessary adresses of the EEPROM are erased when uploading a new program to the BS1 (see: http://www.cs.columbia.edu/~hgs/research/projects/stamptag/Final/Manuals/stamp_faqs.pdf, page 12).
Different souces say this should be possible e.g.: http://www.parallax.com/go/BASICStampConnectHelp/Content/FAQTopics/UsbBoardResets.htm.
However I only managed to WRITE data to the EEPROM and READ it within the same program and without the BS1 being disconnected from the PC.
It would be great if somebody could help me out here!
Thanks in advance
Daniel
We use the BS1 for teaching purposes. We would like to save data (e.g. temperature) in the EEPROM (no problem using WRITE) while the BS1 is disconnected from the PC. And then, later on, we would like to show the data collected by re-connecting the BS1 to a PC. Therefore, we thought we could upload a second program that uses READ, since the lower adresses (0...) are not erased. My understanding is, that only the necessary adresses of the EEPROM are erased when uploading a new program to the BS1 (see: http://www.cs.columbia.edu/~hgs/research/projects/stamptag/Final/Manuals/stamp_faqs.pdf, page 12).
Different souces say this should be possible e.g.: http://www.parallax.com/go/BASICStampConnectHelp/Content/FAQTopics/UsbBoardResets.htm.
However I only managed to WRITE data to the EEPROM and READ it within the same program and without the BS1 being disconnected from the PC.
It would be great if somebody could help me out here!
Thanks in advance
Daniel
Comments
The BS2 only writes the portion used by the program, and saved data in EEPROM is not overwritten unless it occupies space needed for the new program.
"Writing a new program to the BS1 overwrites the entire EEPROM, even parts that aren't used by the program. [...] The BS2 only writes the portion used by the program, and saved data in EEPROM is not overwritten unless it occupies space needed for the new program."
So with the BS2 you could read out the EEPROM with a separate program, with the BS1 you cannot?
"Saved data is not lost when power is removed, but the program that saved it needs to be able to retrieve it later."
I do have a program that writes values to the EEPROM, but only reads and shows them on the DEBUG-Window after a switch is pressed. The only problem is, the DEBUG-Window opens when uploading the program and when I deconnect the BS1, the BS Editor shows an error. It does not re-connect to the BS1 later on. For temperature measuring it would, however, be necessary to have the BS1 separate from the PC.
Any idea how this could work out?
Thanks again, Daniel
Mostly ... Any part of the BS2's EEPROM occupied by the "read out" program gets overwritten. Any other locations are untouched and could be used to pass data between programs. The BS2 uses the high end of memory (higher addresses) to store its programs so using locations near zero is generally safe for keeping data. If you use a BS2sx or BS2p/pe/px, these have additional EEPROM that is normally never used for programming.
Another option would be to use a battery backed real time clock with a small amount of RAM like the DS1302 (here) to store your data. This would allow you to timestamp any data stored.
-> That sounds promising! I have used SEROUT for BS1-to-BS1 networking and also for LDC with a serial backpack.
What would such a terminal program to view data be? Is is any other software (other than the BASIC Stamp Editor) that can communicate with the BS1?
-> Interesting idea! I thought that using the DS1302 (or any other RTC) with the BS1 takes up a lot of program space, though (We do not use the BS2, so our options are limited). Do you happen to have a BASIC Stamp 1 example code?
The amount or RAM in the RTC is really limited. It looks like the DS1302 has 31 bytes SRAM.
This sort of SRAM can be extremely useful for backing up variables which frequently change, but the SRAM on a RTC would make a very limited data logger.
There are EEPROM chips with SPI interfaces. These should be relatively easy to use with a BS1. An EEPROM chip combined with a RTC could make a very useful data logger.
Your BS1 program would keep running and automatically output the numbers stored in EEPROM between sampling new data. So even if switched off, it would resume outputting data after powerup.
Here's what I am thinking of now: building a network of two BS1.
One that is measuring temperature and storing the data in EEPROM. I does not have to be connected to a PC for that (good for measurement in all kind of places). After having sampled the data, it will wait in a loop for someone pressing a swith. I pressed, it will SEROUT the EEPROM Data to a secont BS1.
This will be a stationary BS1 that needs to be connected to a PC, because it will receive the data (SERIN) and show it on the DEBUG-screen. The data can then easily be exported (copy + past) spreadsheet software (Excel or other) for further data analysis.
I will keep you posted!
---
Daniel