View previous topic :: View next topic |
Author |
Message |
farhanhaseeb
Joined: 28 Dec 2011 Posts: 2 Location: Pakistan
|
External memory with pic 16f877a |
Posted: Fri Dec 30, 2011 4:22 am |
|
|
hello,
I am new with ccs and micro controllers. I am designing a data logger based on pic micro-controller. I am using pic 16f877a, ccs c compiler. I want to save voltage values from different sensors and save them in external memory. I'm confused in selecting memory. Can anybody guide me in choosing a memory which must be able to save at least 500 values. I'm in component choosing phase. |
|
|
freedom
Joined: 10 Jul 2011 Posts: 54
|
|
Posted: Fri Dec 30, 2011 6:30 am |
|
|
First we have to know about your value of voltage.
As example, volt= 0 to 255 , then you need int8 datatype variable, if you have more than this then you need int16 or int 32 datatype.
How much memory you need, that depends on how many data you want to save as well as their datatype.
you can declare separate variable for each sensor
Here is a program concept
Code: |
#include <16F877A.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 8000000)
#include <2432.c> // here is your memory device / EEPROM
#include <external_eeprom.c> // Utilities to write various data types to external eeprom
int8 sensor1_volt; // declare global variable
void main()
{
// condition to read your data (volt)
init_ext_eeprom(); // to initialize EEPROM
sensor1_volt=read_ext_eeprom(0x0000); // to read data (volt) from EEPROM
while(true)
{
// condition , while you want to write/save volt data to EEPROM
write_ext_eeprom(0x000, sensor1_volt); // write or save data (volt) to EEPROM
}
}
|
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Fri Dec 30, 2011 6:49 am |
|
|
Also need to know what you're going to do with the data !
If its something the PIC will use later, then some small external EEPROM will work fine but if the data is to go to a PC, then perhaps a USB flashdrive is better.
ADC readings are either 8 or 10 bit, if using 10 bit, they use 16 bits or 2 bytes of storage( double that of 8 bit readings), so you'll need a bigger device.You don't say how many sensors are used.
The speed of the readings/storing of data is important.EEPROM is slow compared to USB,again you know the numbers, we don't.
As this is a 'data logger' then each reading(or set) should have a 'time stamp'(when the reading took place. That will take more storage space which takes more time to write the data.
Also with multiple sensors, you'll have to figure out which data came from which sensor. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Fri Dec 30, 2011 1:46 pm |
|
|
if you use 74LVC translation - ( 3.3v rated )
you might consider microchips SPI RAM
such as the 23K256
....as a very low overhead way to address 32k bytes of static ram |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Fri Dec 30, 2011 1:48 pm |
|
|
Or, FRAM.
Much faster writing, than any of the other memories that hold their contents when unpowered.
Best Wishes |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Fri Dec 30, 2011 1:51 pm |
|
|
oh oh ..another 5 volt PIC 3 volt peripheral 'challenge', more parts and wiring, things to go wrong...endless debugging cause 'they' think they can cheat with resistors.....
still think vinny and flash is the way to go IF you need to log and transfer data to another computer.
then again the 20 year old board I was just working on had 64KB of Sony static RAM..... |
|
|
farhanhaseeb
Joined: 28 Dec 2011 Posts: 2 Location: Pakistan
|
|
Posted: Mon Jan 09, 2012 9:02 pm |
|
|
Thanx for all the help, but I also want to save the time stamp (the time of value along with date). I'm using ds1307 ic for this purpose along with pic. I'm also interested in saving in external usb device. I'm having four sensors and my input values will be within 0-5 volts. |
|
|
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Tue Jan 10, 2012 6:02 pm |
|
|
The easiest way has to be a serial EEPROM.
Saving to a USB device is a problem. You mean make the PIC processor look like the computer end of a USB line? That's very difficult to do. But you might be able to make a dual-port memory setup, with (let's say) your PIC16F877A communicating with it on one side, and USB on the other. I think if that's necessary, you'd be better off learning to use one of the PIC18 devices that plug directly into USB, and make that processor do everything, reading the sensors and running the memory, and forget the PIC16F877A. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Tue Jan 10, 2012 6:23 pm |
|
|
John P ... Using USB with a PIC is very easy,at least a LOT easier than interfacing a 5 volt PIC to a 3 volt eeprom .
By using the Vinculum II series you get BOTH the abilty to use a flash drive for easy data logging with simple commands. It uses easy serial commands to store the data. NO overhead for FAT file drivers,'drive' commands like create,erase,creating sub directories,etc.Since NO drivers are in the PIC, you gain valuable code space.
With respect to interfacing to a PC, the 'drivers' to allow an 18F4550 to talk to a PC via the builtin USB interface take 1/3 of the code space.That's a huge amount!. By letting the Vinculum II do all the work and handle the USB 'details', you get that whole 1/3 of memory back to use!
Yes, it comes at a cost., about $24 for a complete DIP style module that has 2 USB ports.Since the Vinculum II is programmable it can be used to play music,be a host,be a slave,access other USB devices,or even a 'simple' USB-serial interface.It is a tremendously powerful 'peripheral'.
As for the OP request for 'external memory' that implied to me, that the data should be available to say a PC for 'downloading'. That means some kind of 'memory stick' and by using the Vinculum, the PIC can store the data via simple serial commands into a CSV file. It takes less time to cut that code than me typing this 'two finger' reply. |
|
|
dalexdisuja
Joined: 21 Feb 2014 Posts: 1
|
Interfacing external EEPROM with PIC Microcontroller |
Posted: Fri Feb 21, 2014 9:55 am |
|
|
hi i googled and get a very good website Where i found post on Interfacing external EEPROM with PIC Microcontroller via i2c protocol with FM24C64 and the code which they given in post which i tested and working fine. i give that link may it help you. http://www.nbcafe.in/interfacing-external-eeprom-with-pic-microcontroller/ |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Fri Feb 21, 2014 11:06 am |
|
|
i use this item in a number of products, to capture VAST amounts of
data -sent via PIC TTL serial port.
how does using a CHEAP removable MICRO-SD 4GB card sound ?
https://www.sparkfun.com/products/9530 |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Feb 21, 2014 8:47 pm |
|
|
This a 2 year old thread !!!
Please stop posting in the old threads as the original poster has long gone. It took me reading till the last message until I realised it was an old thread and I wasted my time. |
|
|
|