Shop OBEX P1 Docs P2 Docs Learn Events
BS1: Read values stored in EEPROM after re-connecting to PC — Parallax Forums

BS1: Read values stored in EEPROM after re-connecting to PC

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

Comments

  • Writing a new program to the BS1 overwrites the entire EEPROM, even parts that aren't used by the program. Saved data is not lost when power is removed, but the program that saved it needs to be able to retrieve it later.

    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.

  • Thanks so much for the reply!

    "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
  • Mike GreenMike Green Posts: 23,101
    edited 2017-03-17 22:26
    So with the BS2 you could read out the EEPROM with a separate program, with the BS1 you cannot?

    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.
  • The DEBUG in the BS1 is actually implemented in the editor, not the BS1 itself, and that's why disconnecting it causes it to stop working. It also takes a lot of BS1 processing time. If you have the space in your program, you could use SEROUT to a spare pin to write the data instead of DEBUG, and then just connect to any terminal program to view it after pushing the switch.
  • Sapphire wrote: »
    The DEBUG in the BS1 is actually implemented in the editor, not the BS1 itself, and that's why disconnecting it causes it to stop working. It also takes a lot of BS1 processing time. If you have the space in your program, you could use SEROUT to a spare pin to write the data instead of DEBUG, and then just connect to any terminal program to view it after pushing the switch.

    -> 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?
    Mike Green wrote: »
    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.

    -> 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?

  • You could use the debug terminal in the editor. You'll have to set the baud rate to match the BS1, and remove all DEBUG statements from your program since you are receiving data from SEROUT on one of the pins and not the programming port. Other terminal programs (e.g. HyperTerm, TerraTerm) can also be used to receive serial data.
  • Thanks a lot! I will try this a.s.a.p.
  • The DS1302 uses SPI for its communications and most of that is handled by the SHIFTOUT and SHIFTIN statements. There's an article as part of the Nuts and Volts columns on Parallax's website that talks about the DS1302 and should include BS1 sample code. I don't have a link, but someone else might.
  • The N&V columns Mike is referring to is in volume 1. They are columns 33 and 34. The BS-1 version appears to use something called a PWB instead of the DS1602. I think one would be hard pressed to interface a 1602 to a BS-1 with much left over.
  • Mike Green wrote: »
    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.

    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.

  • ercoerco Posts: 20,244
    edited 2017-03-19 18:02
    Daniel: Great project! I still love the BS1 and like to hear about others still using it. Another SEROUT option is to hook up an LCD as a terminal to display values. It could be removable or not. A serial LCD display could connect through a 3-pin stereo jack.

    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.
  • Thanks for all your thoughts!

    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
Sign In or Register to comment.