CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

saving sensor values on the computer

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








saving sensor values on the computer
PostPosted: Tue Feb 19, 2008 11:56 am     Reply with quote

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.
Bob Sacamano



Joined: 17 Jan 2008
Posts: 16
Location: Somewhere Cold, USA

View user's profile Send private message

PostPosted: Tue Feb 19, 2008 12:10 pm     Reply with quote

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."
Guest








PostPosted: Tue Feb 19, 2008 1:15 pm     Reply with quote

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



Joined: 24 Jun 2004
Posts: 1903

View user's profile Send private message

PostPosted: Tue Feb 19, 2008 1:33 pm     Reply with quote

This book might have some information that would help you: http://books.google.com/books?hl=en&id=tC2yFVQfWsUC&dq=aubrey+kagan+excel&printsec=frontcover&source=web&ots=LOr9jgbhHD&sig=iHZJge3aKJR_-KIumlHQBOH1ZfU#PPR7,M1
rberek



Joined: 10 Jan 2005
Posts: 207
Location: Ottawa, Canada

View user's profile Send private message

PostPosted: Tue Feb 19, 2008 2:08 pm     Reply with quote

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.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Feb 20, 2008 8:21 am     Reply with quote

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.
Guest








PostPosted: Thu Feb 21, 2008 2:40 pm     Reply with quote

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



Joined: 17 Jan 2008
Posts: 16
Location: Somewhere Cold, USA

View user's profile Send private message

PostPosted: Thu Feb 21, 2008 3:39 pm     Reply with quote

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."
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group