​ ​ ​ ​ Smart picaxe outdoor light - Page 12
Page 12 of 12 FirstFirst ... 2 10 11 12
Results 111 to 117 of 117

Thread: Smart picaxe outdoor light

  1. #111
    Senior Member
    Join Date
    Apr 2013
    Location
    north dakota
    Posts
    324
    Blog Entries
    2

    Default

    Thanks Hippy ...yes good point ... the motion activation data is not important..it would only be read for interest
    what is important for me is the fact of learning how to save data before main power fails and you ,allycat,texas lots of others showed how
    So I think for this project I will keep it simple and use your suggestion and save the low power warning for a different project

  2. #112
    Senior Member
    Join Date
    Jan 1970
    Location
    Nova Scotia, Canada
    Posts
    2,632

    Default

    Quote Originally Posted by newplumber View Post
    ... is that the full eeprom memory on the at24c32? b0-b15? ...
    The at24c32 has 4K bytes of eeprom (that's the "32" (number of K bits) divided by 8 bits per byte). I used b0-b15 because that's the number of bytes in a "block" on this eeprom. If you try to write crossing a block boundry, you will overwrite to the beginning of the block. For instance, "HI2COUT 15, ("A","B") will write "A" to the 15th byte in the eeprom (starting from 0), and "B" into the first byte (eeprom address 0)--probably not what you intended.

    So to fill all of the at24c32 eeprom with A-P you would do the following:
    Code:
    #picaxe 20M2
    hi2csetup i2cmaster,%10101110, i2cslow, i2cword
    w13 = 0
    do ' through the last 16-byte block
      hi2cout w13, ("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P")
      pause 20
      w13 = w13 + 16
      if w13 = 0 then exit ' upon wraparound--I think I got the terminating condition right--untested
    loop
    I'll second Tex's thanks for your enthusiastic and JK-y contribution to the forum. We geezers (speaking only for myself) love it when someone wants to know about the esoteric stuff we know.
    Last edited by lbenson; 25-09-2017 at 15:34.

  3. #113
    Senior Member
    Join Date
    Apr 2013
    Location
    north dakota
    Posts
    324
    Blog Entries
    2

    Default

    thanks alot Lance
    now I think i understand (easy for everyone else)

    so to have "B" saved correctly
    "HI2COUT 15, ("A","B")
    you need to use
    Code:
    HI2COUT 15, ("A")
    HI2COUT 16, ("B")
    EDIT: Okay I have ds3231/at24c32 eeprom mastered ..of course with all the help from you
    my test code
    Code:
    #picaxe 20M2
    #terminal 4800
    hi2csetup i2cmaster,%10101110, i2cslow, i2cword 'address for the at24c32 memory 
      hi2cout 0,  ("block0_block0_00") :pause 2
      hi2cout 16, ("block1_block1_01") :pause 2' each block is 16 bytes 
      hi2cout 32, ("block2_block2_02") :pause 2
    
    do 	
    hi2cIN 0,(b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15)	' read block 0	
    sertxd (" 0=  ",b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,CR,LF) 'terminal display
     pause 2000 
    hi2cIN 16,(b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15)	' read block 16	
    sertxd ("16=  ",b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,CR,LF) 'terminal display
     pause 2000 
    hi2cIN 32,(b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15)	'read block 32	
    sertxd ("32=  ",b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,CR,LF) 'terminal display
     pause 2000 
    loop
    Last edited by newplumber; 25-09-2017 at 15:32.

  4. #114
    Senior Member
    Join Date
    Jan 1970
    Location
    Nova Scotia, Canada
    Posts
    2,632

    Default

    You got it. As a special bonus, this works both in the PE6 simulator (with "Simulate 24LC512 EEPROM" selected under "Simulation Options") and on a real 08M2 with DS3231 module attached:
    Code:
    ' 20at24c32 at24c32 tester
    #picaxe 08M2 ' 20M2
    #terminal 4800
    pause 2000
    sertxd("Beginning",cr,lf)
    hi2csetup i2cmaster,%10101110, i2cslow, i2cword
    w13 = 0
    do ' through the last 16-byte block
      hi2cout w13, ("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P")
      sertxd("-") ' progress indicator
      w13 = w13 + 16
    '  if w13 = 0 then exit ' upon wraparound--I think I got the terminating condition right--untested
      if w13 > 255 then exit ' upon wraparound--I think I got the terminating condition right--untested
    loop
    sertxd(cr,lf)
    data 0, (6,14,14,3,9,14,1)
    for b25 = 0 to 3
      read b25,b24
    '  w13 = $fff0 + b24
      w13 = $00f0 + b24
      hi2cin w13,(b24)
      sertxd(b24)
    next b25
    sertxd(" ")
    for b25 = 4 to 6
      read b25,b24
    '  w13 = $fff0 + b24
      w13 = $00f0 + b24
      hi2cin w13,(b24)
      sertxd(b24)
    next b25
    sertxd("!",cr,lf)
    (Only first 256 bytes are written.)

    Your code also works in the simulator as well as on the chip.

  5. #115
    Senior Member
    Join Date
    Apr 2013
    Location
    north dakota
    Posts
    324
    Blog Entries
    2

    Default

    Thats cool Lance thanks ...i guess I only mastered sending/receiving bytes now
    you showed some learning on how to use them.
    So the eeprom memory on the at24c32 is 4k bytes
    so it will have 249 blocks = 3984 bytes plus 16
    this little ds3231 RTC has billions of uses

  6. #116
    Senior Member
    Join Date
    Jan 1970
    Location
    Nova Scotia, Canada
    Posts
    2,632

    Default

    4K may be 4,000 when you are talking dollars, but not when talking powers of 2 (which is generally what an eeprom storage amount will be--128 bytes, 256, 512, 4096, and 65536 (2^16) for an AT24C512). 2^12 is 4,096 and that's how many bytes you have with the AT24C32--256 16-byte blocks.

    That particular indexing technique in the program I posted is not likely to be very useful--it was just a little bit of sport to illustrate that the data had been written as expected.

  7. #117
    Senior Member
    Join Date
    Apr 2013
    Location
    north dakota
    Posts
    324
    Blog Entries
    2

    Default

    Okay yes i should have known good reminder
    That particular indexing technique in the program I posted is not likely to be very useful
    Maybe true but it does open another way for messaging data

Bookmarks

Posting Permissions

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