Shop OBEX P1 Docs P2 Docs Learn Events
how to read the data in PBASIC to other program? --- help~~ — Parallax Forums

how to read the data in PBASIC to other program? --- help~~

blue yiublue yiu Posts: 5
edited 2007-02-15 18:17 in BASIC Stamp
Hi, I am a new user. But what I want to do is to export the variable in real time
to other program (e.g. Matlab or C or.....). If anyone know how I can export the variable
to a file in real time which I can read from other program. That will be great.

thanks a lot.

Comments

  • NewzedNewzed Posts: 2,503
    edited 2007-02-15 00:39
    If you send the data to Hyperterminal, then in Hyperterminal you could capture it to an Excel or a Word program.· I've done it many times.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver

    Yesterday is history, tomorrow is a mystery, and today is a gift.
    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • blue yiublue yiu Posts: 5
    edited 2007-02-15 00:42
    Thanks Sid. However, the excel will capture the value. But how can my program read it at real time?
    Can it output to a pure text file? If yes, then other program might be able to share the same data in the file.
    Any help would be appreciate! Thanks a lot.
  • NewzedNewzed Posts: 2,503
    edited 2007-02-15 00:47
    Does your Stamp have a DS1302 or other RTC that could time stamp the data you send to Hyper.· If not,and you don't want to add one, then you will probably have to go to Visual Basic.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • blue yiublue yiu Posts: 5
    edited 2007-02-15 00:51
    I really appreciate your help, Sid. But I think I am too new in this. I am having a BS2 basic board. And going to get the ultra sound sensor. I only want to read the signal from the standard program they have which store the time in a variable in PBASIC. Do you have any idea what can I do? Thanks again! ^^ and happy valentine's day!
  • NewzedNewzed Posts: 2,503
    edited 2007-02-15 01:02
    "I only want to read the signal from the standard program they have which store the time in a variable in PBASIC."

    Candy, how can you store time if you don't have an RTC?· Did you mean what you wrote in the above statement?

    And Happy Valentine day to you!

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • blue yiublue yiu Posts: 5
    edited 2007-02-15 01:25
    Here is the program: this "time" variable is the data I want it in real time. It is in a loop so it will basically run forever.
    I actually not sure what is RTC ( sorry =( ). But here you go:

    time VAR Word
    DO
    PULSOUT 15, 5
    PULSIN 15, 1, time
    DEBUG HOME, "time = ", DEC5 time
    PAUSE 100
    LOOP
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2007-02-15 02:14
    RTC stands for Real Time Clock. Here is the one Parallax sells:

    www.parallax.com/detail.asp?product_id=604-00005

    The Basic Stamp can't keep accurate time by itself, so it needs the help of a real time clock. The RTC keeps the time, and the Basic Stamp reads the time from the RTC. If you need to log that info with Matlab or C, you could write a program that sends a command to the BS2 that tells it to return the time. The BS2 will read the time, and write it to the serial port, where your program reads the value, then writes it to a file.
  • FranklinFranklin Posts: 4,747
    edited 2007-02-15 02:28
    Your BS can output serial data. you need to capture that data with your other program (Matlab or c or...) debug does this on port 15 I think but any pin can be used with serout.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-02-15 02:32
    Awhile back I posted a program (ser2ftp.exe) that will do what you describe. It will also ftp the data to a remote site, if you want it to. In addition, it has the ability to schedule the upload of data at programmable time intervals, letting the PC keep track of the time and scheduling. Perhaps it will work for you.

    -Phil
  • Tom WalkerTom Walker Posts: 509
    edited 2007-02-15 14:23
    blue yiu,
    If I understand you correctly, you wish to get the contents of the "time" variable from the "read the distance sensor" program on your Stamp into the PC for display/processing in "real time". Does this sound correct?

    It looks like your program gets continuous readings from the distance sensor. Then your program sends the value of your "time" variable to your PC using the DEBUG statement. Now what you need is a way to "capture" that value on the PC side for processing. As long as your Stamp IDE software is not running, any program on the PC that can read the serial port can receive this value...StampPlot is one way, programming something to listen to the serial port is another. The important thing to remember is that your Stamp programming IDE must be closed so that it does not keep any other program from getting to the serial port.

    I think we ran into a little language speed bump which led to discussions about the need for a real-time clock. If you really need to know the time a reading being transmitted to the PC happened (as opposed to the value of the "time" variable that is the "time of flight" of your sonar signal), this is usually handled by the PC when it is being used as the data logger. RTCs become necessary when the data collection is handled by a "stand-alone" system and then later "downloaded" to the PC.

    If you really need a "file" to be transmitted, then Phil's suggestion should work for you.

    I hope I haven't confused things too much.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
  • blue yiublue yiu Posts: 5
    edited 2007-02-15 18:17
    Thanks guys. It really helps. I actually don't necessary need a file. I only need the data in real time. I don't want to use "excel" because the experiment will run a long time. It might hang at some point I predict. But I will need to figure out how to read from the serial port then. Thanks a lot! =)
Sign In or Register to comment.