Shop OBEX P1 Docs P2 Docs Learn Events
Reading and storing measurements — Parallax Forums

Reading and storing measurements

WILLQHWILLQH Posts: 11
edited 2005-12-21 20:08 in Learn with BlocklyProp
Hii,

·· I·will like to·attach a Sonar sensor to my Basic Stamp controller·to provide distance measurement readings (10 readings per sec) and will like to know how I can read in and·store all these values, and then later on display it so that i can use the values for evaluation. Can someone please show me a sample code to carry out this function.

· In addition, can the controller take in PWM signal ?

Thank you and Merry christmas in advance

Regards

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-12-21 17:12
    Hello,

    ·· How many readings are you looking to store?· At 10 per second you could use up a·lot of storage space quickly.· As for the PWM input, it could be read using PULSIN.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • WILLQHWILLQH Posts: 11
    edited 2005-12-21 17:50
    Hii, i am looking at storing about 30 to 40 readings .. after which i will like to retrieve the readings and do analysis .. is there a read, store and retrieve function in Basic Stamp that i can use ? Thank you.

    Regards
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-12-21 17:58
    Using the READ and WRITE commands you can read and write data from/to the EEPROM. If you get a BS2p, BS2pe or BS2px, you can store the data to a different EEPROM slot (using STORE command), saving more EEPROM space for your program.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • edited 2005-12-21 20:08
    Attached is an example program EepromDataStorage.bs2 that you can use to store measurements in the unused portion of the BASIC Stamp's EEPROM program memory.· At present, it stores 11 byte values.· For demonstration purposes, it stores values that are hand entered through the Debug Terminal's transmit windowpane.· You can modify the number of values the program stores by changing the number in parentheses in the Records DATA (10) directive.· For example, if you want to store 1000 measurements, change it to Records DATA (1000).· It can currently store up to 1350 measurements.· If you want to store more than that, just remove characters from the various DEBUG commands to make room.·

    attachment.php?attachmentid=39867
    ·
    Since the Ping))) will return values greater than a byte, I have also attached EepromDataStorageWordValues.bs2, which is a version that stores word values.· It has not been tested, but I'm pretty sure it'll work.· Word size values take up two bytes each, which cuts the number of records you can store in half.
    ·
    You can modify·EepromDataStorageWordValues.bs2 to store Ping))) measurements by replacing the DEBUGIN command in the Record_Data subroutine with a PULSIN command to read the ultrasonic echo time.· Also, remove the DEBUG commands in the Record_Data subroutine's FOR...NEXT loop, and add a PAUSE command that slows down the sampling rate to the 10 samples per second you are looking for.·
    ·

    Post Edited (Andy Lindsay (Parallax)) : 12/21/2005 8:11:47 PM GMT
Sign In or Register to comment.