Log in

View Full Version : Writing to Files


JoshJ
29-01-2004, 23:19
Ive been looking at all the stuff of EEPROM, and i dont think its gonna suit for what i want to do (not to mention we cant seem to get it to work). The other programmer on my team suggested writing to a file, say .txt, so that we could atleast copy and paste all our info. Is this any faster than EEPROM, and can it handle writing twice during each user_routine loop? Also can/ how do we do this with this compiler? If we cant, any other (simpler) suggestions? Thanks

Rickertsen2
29-01-2004, 23:24
Ive been looking at all the stuff of EEPROM, and i dont think its gonna suit for what i want to do (not to mention we cant seem to get it to work). The other programmer on my team suggested writing to a file, say .txt, so that we could atleast copy and paste all our info. Is this any faster than EEPROM, and can it handle writing twice during each user_routine loop? Also can/ how do we do this with this compiler? If we cant, any other (simpler) suggestions? Thanks
Umm could you please be a little clearer? There are no files on the RC.
Perhaps you could explain what it is you are trying to do.

Dave Flowerday
29-01-2004, 23:30
Ive been looking at all the stuff of EEPROM, and i dont think its gonna suit for what i want to do (not to mention we cant seem to get it to work). The other programmer on my team suggested writing to a file, say .txt, so that we could atleast copy and paste all our info. Is this any faster than EEPROM, and can it handle writing twice during each user_routine loop? Also can/ how do we do this with this compiler? If we cant, any other (simpler) suggestions? Thanks
Like Rickertsen said, there are no files on the robot controller, because there is no filesystem. EEPROM or FLASH are your only options for storing data when the RC is off. Both are fairly slow and both only allow a finite number of writes to a particular section, so you should not be writing to them every loop or anything like that. If you need to store off some data, you should probably only do it when a button is pushed by the driver or something.

WillyC
29-01-2004, 23:31
Good idea, but if I'm not mistaken you'll have some trouble writing to a file from the C code in the robot. This is because the robot controller (microprocessor) doesn't even have a file system - "files" can't even exist within this processor. EEPROM is your best bet if you want to store something to memory and have it persist through a power cycle/reset. There are a few good threads on here about writing and reading with the EEPROM, and I'm sure a lot of people will answer any EEPROM-related questions you have. And on that note, here's a question for you guys: how do I insert a link to another thread into my post????

JoshJ
29-01-2004, 23:38
What i was trying to do was write to a file on the PC, while the robot is tethered (instead of printf to a screen, output to a file). I understand that there is no place for it on the RC, except EEPROM and whatnot. We've just had problems with EEPROM, with trying to retrieve data, and we're not quite sure how to shift hex storage locations and all the other stuff that comes with using EEPROMs. Any more help would be appreciated, thanks again.

deltacoder1020
29-01-2004, 23:46
your best bet would be to find a dashboard program with logging/save capabilities - there are no functions to write to files, only whatever functionality the dashboard/output window provides.

Rickertsen2
29-01-2004, 23:47
What i was trying to do was write to a file on the PC, while the robot is tethered (instead of printf to a screen, output to a file). I understand that there is no place for it on the RC, except EEPROM and whatnot. We've just had problems with EEPROM, with trying to retrieve data, and we're not quite sure how to shift hex storage locations and all the other stuff that comes with using EEPROMs. Any more help would be appreciated, thanks again.
So you are tryign to write files on the computer from the RC? You will need to write a seperate program to do this. For information on coding for your PC's serial port search MSDN for info on MS COMM control.

Ok wait... besides using hyperterminal, you might want to look into a program called "Stamp Plot pro" It allows you to set up a GUI with all sorts of nifty graphs, text boxes etc to display seria lport input. It can save to files.

deltacoder1020
29-01-2004, 23:47
And on that note, here's a question for you guys: how do I insert a link to another thread into my post????

see the "Reply" button in the lower-right corner of every post? click that, and it will automatically open a reply window with the contents of that post quoted in it.

WillyC
29-01-2004, 23:48
What i was trying to do was write to a file on the PC, while the robot is tethered (instead of printf to a screen, output to a file). I understand that there is no place for it on the RC, except EEPROM and whatnot. We've just had problems with EEPROM, with trying to retrieve data, and we're not quite sure how to shift hex storage locations and all the other stuff that comes with using EEPROMs. Any more help would be appreciated, thanks again.

Ok, I see what you mean. How about this? Use the HyperTerminal program on your PC to capture the printf'd output from the robot (on a Windows-based PC it's at Start-Programs-Accessories-Hyperterminal). HyperTerminal has a logging function that lets you make a log file (.txt or .log) of all the text it captures. Just be careful that you "Disconnect" Hyperterminal before you try to use IFI loader to put a new load into the robot, because Hyperterminal blocks the serial port. After dumping a new load into the robot using the IFI loader, you can "Connect" to the robot from Hyperterminal again.

WillyC
29-01-2004, 23:50
see the "Reply" button in the lower-right corner of every post? click that, and it will automatically open a reply window with the contents of that post quoted in it.

Cool, thanks. I figured this much out. But how do I put an inline link (like a hyperlink) into my post, that will let the reader link to another thread?

deltacoder1020
29-01-2004, 23:52
Cool, thanks. I figured this much out. But how do I put an inline link (like a hyperlink) into my post, that will let the reader link to another thread?

See here:
http://www.chiefdelphi.com/forums/misc.php?do=bbcode

Also, any URL that you put in your post is automatically made into a link, as long as it begins in http:// or www. - this can be turned off by unchecking the "Automatically parse links in test" box below the reply form.

Astronouth7303
30-01-2004, 14:06
What i was trying to do was write to a file on the PC, while the robot is tethered (instead of printf to a screen, output to a file). I understand that there is no place for it on the RC, except EEPROM and whatnot. We've just had problems with EEPROM, with trying to retrieve data, and we're not quite sure how to shift hex storage locations and all the other stuff that comes with using EEPROMs. Any more help would be appreciated, thanks again.
Write a program that takes the printf() transmissions and logs them in a file. Like he said, VB (or VBA if your desperate) and MSCOMM should do the trick. I have a feeling (don't quote me on this) that if you set it to text mode, the receive buffer should be whatever is sent. But I haven't tested this hunch (yet).

WillyC
30-01-2004, 14:57
Write a program that takes the printf() transmissions and logs them in a file. Like he said, VB (or VBA if your desperate) and MSCOMM should do the trick. I have a feeling (don't quote me on this) that if you set it to text mode, the receive buffer should be whatever is sent. But I haven't tested this hunch (yet).

You could do this, and it would work well I'm sure. But the super-easy, no programming, no fuss way to just log all the printf's is to use the HyperTerminal program and get it to log the session. Hyperterminal is already installed on your machine and it's easy to use, so if all you want to do is make log files of your printf's, this is the easiest way, I believe. Try it out and let me know if you need help with it...

Astronouth7303
30-01-2004, 14:59
I would, but I don't have anything with me. I will, however, try to write a program to do exlusively that.


UPDATE:
I wrote v.1 already. See attachment. If you need DLL's, pm me. (the install is at least 2 mB)

seanwitte
30-01-2004, 15:16
There is a program available at members.cox.net/seanwitte that works sort of like a bi-directional dashboard. You can send 8 bytes, 6 16-bit signed integers, and 16 binary values back to the PC. The PC sends 8 bytes and 8 digital values to the RC. It will capture, plot, and save up to 10 of the IO values at once. This will not work if you have any printfs in your code.

Install the EDUController application (windows only). Grab pc_interface.h and pc_interface.c from the MPLAB project on the web site above and add them to your project. Heres how you would use it:

1) Add #include "pc_interface.h" to the top of user_routines.c
2) Call function "InitializePCInterface()" at the end of User_Initialization().
3) Call function "SendReceivePCData()" from Process_Data_From_Master_uP, right before the call to Putdata().

Now, whenever you set the values of the aliases in pc_interface.h those values will be sent to the EDUController application. To verify, try adding the line "sensor1 = 116;" to Default_Routine(). Make sure the RC is running and start the EDUController program. Select the correct COM port, and click Open. You should see the value for Analog Input 1 change to 116. The rest of the controls are pretty self explanatory. The connection is closed automatically when you stop a capture.