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

accessing a text file using PIC

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



Joined: 18 Nov 2009
Posts: 3

View user's profile Send private message

accessing a text file using PIC
PostPosted: Wed Nov 18, 2009 11:01 pm     Reply with quote

Is it possible to open a text file using pic?
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Wed Nov 18, 2009 11:51 pm     Reply with quote

Do you mean from a storage device like an SD/CF card? or maybe a USB stick? Formatted in FAT or FAT32 or maybe NTFS or EXT3?

Or over a network from a server as a client?

Maybe it's stored in a compressed format on a I2C or SPI attached EEPROM?

Please, we need more information if we're to help.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
aashasurendran



Joined: 18 Nov 2009
Posts: 3

View user's profile Send private message

accessing a text file using PIC
PostPosted: Thu Nov 19, 2009 12:49 am     Reply with quote

Actually I'm a beginner of PIC. Can we use the function like fopen() fclose() etc (), to access a file which stored in harddisk?
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Nov 19, 2009 1:05 am     Reply with quote

Ahh, I see where you're coming from now.

Imagine an Intel/AMD CPU. It's general purpose processor that sits in a box like the one you're using to probably surf this forum.

Now, imagine an embedded 32bit CPU like the one running "under the hood" (or LCD) of your PalmPilot or WindowsCE/Mobile phone or iPod.

Now imagine the kind of CPU that might be in a custom weather sensor or maybe the one controlling the the LCD via USB on your computer or maybe running the control panel on your fridge's ice maker/water dispenser.

THAT is something a PIC (well, for a lot of us) might do. Anything which might need some smarts but without windows or linux running on it.

Maybe some sensors in your car. Maybe running the ignition in your car. Or maybe the fuel flow in my airplane. My Fluke multimeter doesn't have Windows running on it. The user interface is a bunch of buttons and a VFD. THAT's a PIC application.

Now, if you REALLY wanted, you could probably get a 16bit PIC (PIC24 or dsPIC30/33) or 32bit PIC to hook up to an IDE hard drive. But what would you do with it? Run Word? Maybe Open Office and do a little browsing with FireFox. Not any time soon.

Have you looked at the datasheets and product list at www.microchip.com??

That would be a good place to start to see what kind of hardware you're dealing with.

Cheers,

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
aashasurendran



Joined: 18 Nov 2009
Posts: 3

View user's profile Send private message

PostPosted: Thu Nov 19, 2009 1:19 am     Reply with quote

What I'm trying to do here is, open a file using fopen, read in some values into a variable, perform an algorithm on the numbers and save the new values into a new file. By file, I mean files in the C programming language. I'm trying to do this on the embedded C on the pic. Is file handling possible through the embedded C on the pic?
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Nov 19, 2009 1:27 am     Reply with quote

Well, I think I can best explain it this way.

First, You'd have to build yourself a PCB where the PIC can plug into an IDE or SATA or maybe SD/CF drive.

Then you'd have to write or buy drivers to handle using FAT. Make sure you get a PIC with lots of memory so you can support FAT32. Keep in mind you'd be limited to opening very few files at any one time.

If you are writing your own drivers, you'll be writing fopen() and all those things.

If you buy someone's, they might have it already.

PIC-C is a compiler that works with the 'C' language to create code that will run on a Microchip embedded microcontroller.

Have you visited their website yet?

I think you want a Windows/Apple/Linux PC for what your needs describe.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Thu Nov 19, 2009 3:01 am     Reply with quote

bkamen has very good points but I have to ask.
Do you already have some hardware that allows a PIC to connect to a (IDE/SCSI/SATA) hard drive ?
If so what is it and what PIC is it using ?

if you plan on designing this yourself then have a look to see if YOU can actually design and make some hardware to do this. I expect you wouldn't be able to unless you are a very good hardware engineer.
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Nov 19, 2009 11:06 am     Reply with quote

Wayne_ wrote:
bkamen has very good points but I have to ask.
Do you already have some hardware that allows a PIC to connect to a (IDE/SCSI/SATA) hard drive ?
If so what is it and what PIC is it using ?


You and me both. I could see it being done on a 16 or 32bit PIC. Those are powerful enough to do it directly or through a south-bridge style peripheral IC.

So that's done.. now for the file commands he speaks of. That would be the next interesting twist to the tale.

And then, ultimately, what's the point? a dedicated PIC to parse a file? Where did the file come from? why is it on an IDE drive that the PIC needs to hook up to? What exactly is the end product/project configuration.

"Opening a text file" on a "hard drive" is a pretty deep and complex concept when all the mechanisms are considered.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
dbotkin



Joined: 08 Sep 2003
Posts: 197
Location: Omaha NE USA

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Nov 25, 2009 12:06 am     Reply with quote

I don't see where he mentioned the drive interface. I think I've seen a PIC project that used IDE drives -- but it's been a while. A Google search turns up a number of PIC/IDE/FAT projects. At this point, though, USB is my personal choice.

Assuming you have suitable hardware, you can at least open, read, write and close text files on a USB FLASH drive pretty easily. Maybe not fopen() easy, but not terribly difficult. I don't have a FAT formatted partition on a USB attached hard drive (only Linux and NTFS), but I expect you use a USB external hard drive as well. In my case I'm using a Vinculum USB host controller chip. It took me some extra work because of all the other stuff I'm doing, but I'm reading & writing text files with no problem. My product will save all of its configuration and the contents of its attached 24LC65 EEPROM, load saved parameter sets, and even bootload its own firmware. It's pretty slick. The downside is, you get the intense pleasure of dealing with a fine-pitch 48 lead LQFP.

Of course, like I said -- this assumes you have the right hardware. And you're not going to figure out the source code with a C textbook and no PIC experience, either. On the bright side, CCS sells a USB dev kit with some nice examples and some USB host mode source to make it a little easier.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Nov 25, 2009 12:46 am     Reply with quote

Quote:
Is it possible to open a text file using pic?

As said, CCS C doesn't provide the standard C file handling commands, because it doesn't work based on an
operating system respectively a file system.

But, CCS and others (CCS forum code library and professional vendors) supply file systems, that offers similar
functionality with a FAT file system and MMC/SD cards.

The CCS fat16 driver has e.g. a fatopen() function or the code library fat16 project open_file(). So far about
the facts.

It has been correctly mentioned, that a higher performance file system possibly needs more processing power than
provided by a 8-Bit PIC.

But the original poster didn't request a particular performance. In this case, it's inappropriate to discuss about 32-Bit
processors and all the stuff. Microprocessor based file system have once started with CP/M OS and 8-Bit processors.
Some people possibly remember.
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