View previous topic :: View next topic |
Author |
Message |
Guest
|
saving sensor values on the computer |
Posted: Tue Feb 19, 2008 11:56 am |
|
|
I have a PIC18F2520. I want to read 5 sensor values and the output them from the serial port(RS-232) as an array of 5 values.
I want to output them in a format into the computer so I can generate an excel spreadsheet with 5 columns, and tons of rows. Rows would signify the sampling rate.
I know using printf() will print the array of 5 values on the hyper terminal.
But how do I write into a file in the computer, that can be opened using excel and will contain sets of 5 values for each acquisition?
Thanks. |
|
![](templates/subSilver/images/spacer.gif) |
Bob Sacamano
Joined: 17 Jan 2008 Posts: 16 Location: Somewhere Cold, USA
|
|
Posted: Tue Feb 19, 2008 12:10 pm |
|
|
I don't know about Hyperterminal; I (and many others) tend to avoid it based on it's "quirkiness". Most terminal programs (including CCS' SIOW) allow you to log the received characters to a file on the PC. Generally, a good idea is to separate the values using commas and save the file with the .csv (comma-separated variable) extension. Excel will know how to interpret the CSV file. Each value between the commas will be interpreted as a column. Line breaks (CR,LF or '/r','/n' in windows) are used to delimit a new row. _________________ "And you want to be my latex salesman." |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Tue Feb 19, 2008 1:15 pm |
|
|
Thanks for the info. But to do so I imagine I will have to do the following:
Write a file name in the firmware
Give it a directory from the computer
Open the file
Write data into the file
And then someway close the file after certain no. of aquisitions.
All the interaction between the PIC and comp would need to be with RS-232.
To do the above steps are there any functions in the CCS compiler library I can use? |
|
![](templates/subSilver/images/spacer.gif) |
newguy
Joined: 24 Jun 2004 Posts: 1903
|
|
![](templates/subSilver/images/spacer.gif) |
rberek
Joined: 10 Jan 2005 Posts: 207 Location: Ottawa, Canada
|
|
Posted: Tue Feb 19, 2008 2:08 pm |
|
|
The PIC does not open and close files on the computer, nor write data into a specific file. It is just sitting on one end of an RS232 bus. The PC software is responsible for opening and closing files.
This can be as simple as opening a terminal program and capturing the PIC data in a file you specify. It would be up to the PIC to transmit the data as space or comma separated data with can easily be pulled into Excel.
Or, you may wish to write your own Visual Basic or similar program to open the COMM port, create a file and add data to the file in some manner of your choosing.
r.b. |
|
![](templates/subSilver/images/spacer.gif) |
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Wed Feb 20, 2008 8:21 am |
|
|
The PIC just shuffles bytes. It has no idea what a "file" is. Most any terminal program can capture bytes into a file but you usually have to close the file manually. If you write something like the Xmodem or Zmodem protocols for the PIC then a terminal program could interpret those protocols and know when the file is done. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Thu Feb 21, 2008 2:40 pm |
|
|
can I make the PIC write into two diff files. If the PIC is running in an infinite loop, and I need to make it write into one of the two open files depending on the type of data, how would I do that?
How do you really open a file on the computer, and direct the printf() data from the PIC into that file in the computer? |
|
![](templates/subSilver/images/spacer.gif) |
Bob Sacamano
Joined: 17 Jan 2008 Posts: 16 Location: Somewhere Cold, USA
|
|
Posted: Thu Feb 21, 2008 3:39 pm |
|
|
Other than writing your own app in VB (or something) as rberek suggested, I don't think there's a simple way of doing what you want.
The basic way of writing from a PIC to a file on a PC is to have a terminal program open on the PC that takes the characters from the serial port and writes them to a file. The PIC simply writes characters to it's serial port and "hopes" everythings going OK on the PC side of things.
Anything more complicated than that would probably require a custom program to be written for the PC. If that's the case, then it can do almost anything. _________________ "And you want to be my latex salesman." |
|
![](templates/subSilver/images/spacer.gif) |
|