working with external memory


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    malc-c's Avatar
    malc-c Guest

    Default working with external memory

    Hi,

    I'm looking at using an external Eprom (something like an 24LC256) to store time and temperatures, which can then be downloaded to a PC application via the serial port. However I need some pointers from you guys.

    I currently have a RTC chip from which I use just time information at present.
    Code:
    I2CRead SDApin,SCLpin,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,RTCDay,RTCMonth,RTCYear,RTCCtrl]  ; read DS1307 chip
    I then have the following routine to give me Hrs and Mins which I use in parts of the program where I need to compare the current time to pre-sets

    Code:
    timeH=(RTCHour>>4)                               'convert the BCD format of the hours register and store in variable timeH
    timeH=(timeH &$03)*10
    timeH=timeH+(RTCHour&$0F)
    
    timeM=(RTCMin>>4)
    timeM=(timeM &$07)*10
    timeM=timeM+(RTCMin&$0F)                         'convert the BCD format of the mins register and store in variable timeM
    Temperatures are read from a DS18B20 (4 off) and simply end up and an array variable - Temperatures[0] - [3], and are represented by a 3 digit decimal, so 234 would be 23.4C.

    There should not be much change in the temperatures as this is for my thermostat project, so the logging interval doesn't need to be too frequent (as in realtime !) probably once per minute, maybe once every 5 min - depending on the amount of data I could store in the chip. So I guess I need to use something like

    Code:
    IC2write, address, timeH, timeM, temperatures[0], temperatures[1], temperatures[2], temperatures[3]
    I would then have a "download data" button on the PC application which would send something like "D" to the RS232 port and then once detected jumps to a subroutine where it then reads the chips contents, sends them as a data stream back to the PC application, so a single data line would probably look like
    Code:
    1230300302297289
    So sending that via serial
    Code:
    Hserout [dec TimeH, TimeM] 
    Hserout [DEC3 Temperatures(0)]
    Hserout [DEC3 Temperatures(1)]
    Hserout [DEC3 Temperatures(2)]
    Hserout [DEC3 Temperatures(3)]
    This is where I get stumpped !

    I would probably need to use some form of delimiting character to indicate the end of a data line, or could simply send a long data stream and let the software start a new line after every 16 digits. Either way I would need to loop the above in some way for each line of data. I would also would like the memory contents cleared after the "log file" has been downloaded, so would need suggestions on how to do that.

    I would welcome your ideas, and if possible some sample code.

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    I don't think one byte is enough to store your temperature . with one byte the maximum reading will be 25.5 degree then 25.6 will make your byte overflow to 0.

    Al.
    All progress began with an idea

  3. #3
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Sorry, should of mentioned, they are words

    Code:
    Temperatures      VAR WORD[4]
      Temp1           VAR Temperatures[0]
      Temp2           VAR Temperatures[1]
      Temp3           VAR Temperatures[2]
      Temp4           VAR Temperatures[3]
    with bytes for time

    Code:
    	TimeH var byte     
    	TimeM var Byte
    Last edited by malc-c; - 10th September 2010 at 16:55.

  4. #4
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    One alternative (assuming I can find it in the UK) is this

    http://www.jianpingusa.com/datasheet...nstruction.pdf

    Basically an SD/MMC card reader that communicates via serial


    Ouch - $50

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Have you seen this?
    Need an 18F with a fair amount of memory. 18F2550 works great with it.
    Dave
    Always wear safety glasses while programming.

  6. #6
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Have you seen this?
    Need an 18F with a fair amount of memory. 18F2550 works great with it.
    Seen what Dave ....

    Currently using an 18F4580 - The current version of my code compiles to around 24K

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts