Shop OBEX P1 Docs P2 Docs Learn Events
Creating text files using PBASIC... — Parallax Forums

Creating text files using PBASIC...

robo04robo04 Posts: 7
edited 2009-03-16 18:11 in BASIC Stamp
Is it possible to create text files using other programming lanuages and somehow merge the two languages together?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-03 22:29
    What do you mean by "create text files" and "merge the two languages together"?

    Do you have an example of what you would hope to do?

    Strictly speaking, the Stamp Editor doesn't do any merging. There's no include facilty for example. You could use some other program to do the work like a scriptable text editor or a language like AWK designed to manipulate text files. The Stamp Editor (and the Stamp) can store text data in its EEPROM and a program in the Stamp can access the text and do something with it. I'm not sure if this is what you're talking about.
  • Craig EidCraig Eid Posts: 106
    edited 2009-03-03 23:22
    This posting is very similar to your earlier·posting on text files -·please describe what you need to accomplish so a proper answer can be delivered. I am guessing·that would like·to use a Basic Stamp to create a text file accessible by code written in another language and running on a PC. You can use Visual Basic, Visual C++, etc to create the file from information that is provided by the Stamp via a COM·port or a USB port using SERIN and SEROUT.





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Craig Eid

    www.TriadRD.com

    Post Edited (Craig Eid) : 3/4/2009 12:09:45 AM GMT
  • robo04robo04 Posts: 7
    edited 2009-03-04 23:57
    Mr. Craig Eid

    thanks for your answer. Here what I want to do

    I have a program on my Basic Stamp 2 module. I have two word-sized variables, named "latitude" and "longitude", in this program on the RAM which belongs to Basic Stamp 2 module.

    The Basic Stamp 2 module is connected to the PC using COM port #7.

    I want to create a text file on PC (using for example JAVA or C++), named "test.txt", and save the contents of my two variables in pbasic program (latitude and longitude) on that text file.

    So my question will be how can I get this to programs communicate with each other?
    how can I send serial data (or in other word content of a variable) from a pbasic program to another program on PC using a specific COM port using SEROUT command?

    your guess is pretty close to what I had in mind I guess. I'll appreciate if you can explain a little bit more.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-05 00:16
    From the Stamp side, this is trivial. Use the DEBUG statement or the SEROUT statement with port #16 (which works the same as DEBUG) to transmit the two word values to the PC. You might want to add punctuation (like a space) between the two values and a carriage return at the end like this:

    DEBUG SDEC latitude," ",SDEC longitude,CR
    or
    SEROUT 16,16468,[noparse][[/noparse]SDEC latitude," ",SDEC longitude,CR]

    See the Stamp Basic Manual for an explanation of these statements.

    This will send a signed value. If you're using unsigned values, use DEC instead of SDEC.

    On the PC side you'll need some kind of program in some convenient programming language that allows you to open a COM port and receive characters from it. The DEBUG statement transmits at 9600 Baud with 8 data bits and 1 stop bit. Your PC COM port will have to be configured for that.

    Your program will have to convert the received digits to a numeric value. If the number ends with a space, it's the latitude. If it ends with a return (13), it's the longitude.
  • robo04robo04 Posts: 7
    edited 2009-03-06 20:11
    Mr. Green

    thank you for the response. I found it quite helpful.

    I am probably going to use JAVA or C++ on the PC side.
    do you think you can help me with finding the appropriate command (in C++ or JAVA) that allows me to open a COM port and receive characters from it?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-03-06 21:22
    If you have Excel, you might also take a look at PLX-DAQ, which can be downloaded from this page. Quoting the blurb:

    "PLX-DAQ Real-Time Data Acquisition for Microsoft Excel

    The Parallax Data Acquisition tool (PLX-DAQ) software add-in for Microsoft Excel acquires up to 26 channels of data from any Parallax microcontrollers and drops the numbers into columns as they arrive. PLX-DAQ provides easy spreadsheet analysis of data collected in the field, laboratory analysis of sensors and real-time equipment monitoring."

    -Phil
  • robo04robo04 Posts: 7
    edited 2009-03-16 18:01
    hi

    I used PLX-DAQ and I sent the contents of two word-sized variables ("latitude" and "longitude" in PBasic program) to the PLX-DAQ macro on PC.
    I have this problem now. in PLX-DAQ it always draws "latitude" versus "time" OR "longitude" versus "time" or you can even have "latitude" and "longitude" in one diagram, both versus "time" though (in two separate graphs).
    I need to have "latitude" versus "longitude" in just one graph. can anybody help me with that
  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-16 18:11
    You'll have to do that yourself using Excel's graphing functions. PLX-DAQ will just download the data. It's designed to do that and to do simple analysis only. Once you have the data on the PC, you can do all sorts of things with it, but not with PLX-DAQ.
Sign In or Register to comment.