We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello everybody giving a helping hand,
got me some trouble here. I was making a program that reads out the duty cycle of an ADXL202 sensor. Everything works, except the part were i want to print my data in a file using this :
FILE *stream, *fopen(); if ( (stream = fopen(...)) != NULL) fscanf(stream,''%s'', string);
Ok this is were my problems start. The compiler gives me the error that he doesn't know this type FILE ore the function fopen (). This seems to be logical to me since i looked in my stdio.h header and found nothing really according to that declaration. Is there a posibility that this is stored in another source file or does not exist??? Or .... how do i get my data's in a *.txt file ???
Thanks for the help i'm about to receive :))
P.S: Im using a 80C535 µC, sorry for not mantuening
My *.txt file is named test_acc.txt and is located on my desktop that means in c:/Dokumente und Einstellungen/Desktop. My controler is via serial port connected to the pc.
My controler is via serial port connected to the pc.
In that case, maybe you should have a look at the putchar(), puts() and printf() functions:
http://www.keil.com/support/man/docs/c51/c51_puts.htm http://www.keil.com/support/man/docs/c51/c51_putchar.htm http://www.keil.com/support/man/docs/c51/c51_printf.htm
They are still very much part of the PC world (and you'll be surprised about the amount of code memory that the "simple" printf functions takes up), but will work on the uC.
Of course, you will have to configure the serial port first and have something (Hyperterminal might do for starters) on the PC side that can receive the output of the uC.
If your uC application has real-time constraints, you may need to "roll your own" serial output routines that are interrupt-driven.
Thanks for the advise but this is not helping me. Maybe im not clear enought. My fault, sorry. I am using HyperTerminal to comunicate with my µC. And i can see the data he's sending me via serial port but on the terminal window. Now if i want to hape this data in a text or in a excel file (even better) i must record the transmision on the terminal. I would like to see the data in my terminal window but at the same time record it in a text file or a tabel in Excel. That would be great because i must deliver a diagram and trough that i could save a step. I mean i still receive data in my terminal, see if there are corect, record tham in txt input them in excel and make my diagramm. Now if i could transfer them directly to the Excel file and make the diagram i could save 1-2 steps and so make a "automatical" program.
"I am using HyperTerminal to comunicate with my µC. And i can see the data he's sending me via serial port but on the terminal window. Now if i want to have this data in a text or in a excel file (even better) i must record the transmision on the terminal."
That's right - this is a PC question, not a Keil question.
Hypoterminal can record the received data to a file - see 'Capture Text' on the 'Transfer' menu.
Or you can write your own PC application to automate the process.
To do it in Excel, see: www.windmill.co.uk/rs232.html
Remember: as far as the PC is concerned, it's all just serial data - the fact that it happens to be coming from an 8051 is entirely irrelevant to the PC.
Writting a serial receiving program in PC enviroment(Visual Studio,Delphi,GCC,etc) will save you out.
Yes real nice "ninja Z", thats the best solution, write myself a serial receiving program. And loose another 2 weeks on that. I'll bet that the www got something for me that does not include selfprograming serial ports and other desolating methods of human knowledge. Thanks again mister Dragon Ball Z
"write myself a serial receiving program. And loose another 2 weeks on that."
Actually, it's not entirely "losing" 2 weeks, is it?
From your original post, it sounds like getting the data onto your PC is an integral part of your project?
Of course, if you can find something ready-made and suitable, there's no point re-inventing the wheel.
Well actualy my project includes reading an ADXL202 acceleration sensor and transcribe the messurments into a table (diagram), and i figured that would do great with excel. But with the normal Hyperterminal i must record the data into an *.txt file. And then transcribe into excel and then to the table etc.... Help....
"with the normal Hyperterminal i must record the data into an *.txt file. And then transcribe into excel and then to the table etc."
Did you actually look at www.windmill.co.uk/rs232.html ?
They have a lot of stuff about getting serial data into Excel...
"with the normal Hyperterminal i must record the data into an *.txt file. And then transcribe into excel and then to the table etc"
If you won't put the effort into creating an automated application, then you're going to have to put effort into doing it manually, aren't you?
Only you can say where the break-even point is...
"Help..."
Well, as you said yourself, "I'll bet that the www got something for me ..."
Yes i tried the free version and it seems its entirely bulls**t. And my pocket is a little bit tight for the new version, u know what i mean?? So i looked everywere but in the and i gotta stick to the old plan and use the hyperterm..... life's cruel, isn't it?? Sadly ironic.. does anybody have maybe an idee how this could work without special payments and extra work time ???
If your 8051 application is able to send data over the serial port, then have it insert a COMMA in between each bit of data and a LINEFEED at the end of each record. If you open such a csv (comma-separated-value) in any recent version of excel, it will know how to handle it.
"have it insert a COMMA in between each bit of data"
That's "bit" as in "item" of data - not as in "binary digit"!
"a LINEFEED at the end of each record."
The line terminator for PC files should be a Carriage Return (CR) followed by a Linefeed (LF). This 2-character sequence is often known as "CRLF"
eg, see: blogs.msdn.com/.../91899.aspx and follow the links...
"If you open such a csv (comma-separated-value) [file] in any recent version of excel, it will know how to handle it."
In fact, Excel's text-import wizard can cope with many formats - inlcuding fixed-width and lots of other delimiters.
It's still a lot of manual messing about though: get Hypoterminal to capture the data, close the file, open the file in Excel, etc, etc, etc,...
You can see how 2 weeks "lost" in writing a custom data receiver would soon be recovered!
Andy,
Thanks for providing the OP with the clarifications. The rigor with which I craft my posts is directly proportional to the amount of caffeine I've managed to ingest so far that day. :)
-Jay D.
Yes thank you but that is what im doin' right now. Its this thing that bothers me. I must record data, insert it in the excel file (with csv) and than do the table ( or diagram, or whatever you wanna call him ). If there is a posibility i would like to jump over these steps and make a direct connection to the serial port and transform the values directly into an diagram. That Windmill thing ain't working because it costs money witch i don't have and the free version is a joke. I heard it could be done with the macros in excel but i have no idea how to do this. If anybody has an idea or an webpage with the macro language or a done program it would be great.... Thanks
Google for:
serial wedge +excel