Loading...
  Show Posts
Pages: 1 [2] 3 4
16  Using Arduino / Storage / How to read 24Cxx I2C Eprom bigger than 2Kb (ie 4kb) on: April 03, 2013, 05:08:38 am
Hi.

I had already some problem with I2C Eeprom, but bit by bit I'm getting sorted out.

I've used Nick Gammons' I2C scanner and found my Eeprom is a 4kb, so I find 2 devices 0x50 and 0x51 on the same Eeprom.

Here is Nick Gammons' I2C scanner I've used.

Code:
// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011

#include <Wire.h>

void setup() {
  Serial.begin (9600);

  // Leonardo: wait for serial port to connect
  while (!Serial)
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
 
  Wire.begin();
  for (byte i = 1; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

Then, to read i'm using this :

Code:
#include <Wire.h>
 
#define disk1 0x50
 
void setup(void){
 Serial.begin(9600);
 Wire.begin();
 unsigned int address = 0;
 for (address = 0; address < 4096; address++)
 { 
 Serial.print(address);
 Serial.print("\t");
 Serial.print(readEEPROM(disk1, address), DEC);
 Serial.println();
 }
 }
 void loop()
 {
 }
 byte readEEPROM(int deviceaddress, unsigned int eeaddress )
{
 byte rdata = 0xFF;
 Wire.beginTransmission(deviceaddress);
 Wire.write((int)(eeaddress >> 8));   // MSB
 Wire.write((int)(eeaddress & 0xFF)); // LSB
 Wire.endTransmission();
 
 Wire.requestFrom(deviceaddress,1);
 
 if (Wire.available()) rdata = Wire.read();
 return rdata;
}

But I've got only 255 value in all world adress.

If I take off this part of code :
Code:
Wire.write((int)(eeaddress >> 8));   // MSB

I've can read till #255 the right value, then on #256 I'm reading back #0 value.

How can I do for correctly addressing world further than 255 ?
17  Using Arduino / Programming Questions / Re: Why am I having so much trouble working with I2C EEPROMs? on: April 02, 2013, 03:29:59 am
Hello Nick.

Unfortunately, the Smiley faces disappeared when I modified the quote tag to code tags.

Concerning this part of code :

Code:
while(1) {
      Wire.beginTransmission(i2caddr);
      if(Wire.endTransmission() == 0)break;
    }

It is (I think) to be sure "the job has been done". Before, I used a Delay(), but as I had problem, somebody told me to use this code instead. The problem I was facing was not from here, but I thought it clever to check if the job was done instead of waiting a certain amount of time between each writing.

AWOL, I don't understand what you mean. Sorry.

18  Using Arduino / Programming Questions / Re: Why am I having so much trouble working with I2C EEPROMs? on: April 02, 2013, 02:33:18 am
Ok, so I put back the 5kOhm  pull up resistor and now it still works fine.
I don't know what I've done, maybe using a wrong piece of code.

The Eeprom's reference I'm using are hard to read.

I've one :
ST CHN  F
24C02 6
K0C828

I can write and read  till 256 value in it. If I write, then read more than 256 value, the #256 store the same value as #0 and so on.

The second one I'm using is :
24C04
BL116
But the reference is very hard to see, so there might be something after the 4.
It behaves the same way as the first one despite it should be double size in memory !!!!

Here is the code I'm using :
Code:
#include <Wire.h>     // for I2C
#define i2caddr 0x50    // device address
byte d=0; // data to store in or read from the EEPROM

void setup()
{
  Serial.begin(9600); // Initialize the serial line
  Wire.begin();         // wake up the I2C
 
  Serial.println("Writing data...");
  for (int i=0; i<258; i++)
  {
    writeData(i,i);
  }
  Serial.println("DONE");
  Serial.println("Reading data...");
  for (int i=0; i<258; i++)
  {
    Serial.print(i);
    Serial.print(" : ");
    d=readData(i);
    Serial.println(d, DEC);
  }
  Serial.println("DONE");

}

// writes a byte of data in memory location addr
void writeData(unsigned int addr, byte data)
{
  Wire.beginTransmission(i2caddr);
  // set the pointer position
  //Wire.write((int)(addr >> 8));
  Wire.write((int)(addr & 0xFF));
  Wire.write(data);
  Wire.endTransmission();
  while(1) {
      Wire.beginTransmission(i2caddr);
      if(Wire.endTransmission() == 0)break;
    }
}

// reads a byte of data from memory location addr
byte readData(unsigned int addr)
{
  byte result;
  Wire.beginTransmission(i2caddr);
  // set the pointer position
  //Wire.write((int)(addr >> 8));
  Wire.write((int)(addr & 0xFF));
  Wire.endTransmission(1);
  Wire.requestFrom(i2caddr,1); // get the byte of data
  result = Wire.read();
  return result;
}

void loop()
{
}

Both Eeprom work the same with this code.
If I change the code to this, (concerning the way of addressing) I've got only 255 in all the bytes.

Code:
#include <Wire.h>     // for I2C
#define i2caddr 0x50    // device address
byte d=0; // data to store in or read from the EEPROM

void setup()
{
  Serial.begin(9600); // Initialize the serial line
  Wire.begin();         // wake up the I2C
 
  Serial.println("Writing data...");
  for (int i=0; i<258; i++)
  {
    writeData(i,i);
  }
  Serial.println("DONE");
  Serial.println("Reading data...");
  for (int i=0; i<258; i++)
  {
    Serial.print(i);
    Serial.print(" : ");
    d=readData(i);
    Serial.println(d, DEC);
  }
  Serial.println("DONE");

}

// writes a byte of data in memory location addr
void writeData(unsigned int addr, byte data)
{
  Wire.beginTransmission(i2caddr);
  // set the pointer position
  Wire.write((int)(addr >> 8));
  Wire.write((int)(addr & 0xFF));
  Wire.write(data);
  Wire.endTransmission();
  while(1) {
      Wire.beginTransmission(i2caddr);
      if(Wire.endTransmission() == 0)break;
    }
}

// reads a byte of data from memory location addr
byte readData(unsigned int addr)
{
  byte result;
  Wire.beginTransmission(i2caddr);
  // set the pointer position
  Wire.write((int)(addr >> 8));
  Wire.write((int)(addr & 0xFF));
  Wire.endTransmission(1);
  Wire.requestFrom(i2caddr,1); // get the byte of data
  result = Wire.read();
  return result;
}

void loop()
{
}
19  Using Arduino / Programming Questions / Re: Why am I having so much trouble working with I2C EEPROMs? on: April 01, 2013, 01:49:32 pm
Quote
don't confuse the I2C eeprom with the
eeprom inside the Arduino chips
i'm really talking about external I2C Eeprom.

Quote
Also, for external I2C eeprom, you need to use
pullup resistors.

I was having trouble with external pull up resistor, so I took them off and now it seems to work fine  without ! I thought the code of the wire.h library configured the Arduino's internal pull up resistor ! But in any case, now I'm thinking, even whether I put external pull up resistor, it should not disturb it ! The problem is that I've been doing so many manipulation and trying so many code without really understanding what I was doing, I'm making a real mess !

The link that made me thinking I may not need the external pull up resistor is :
http://playground.arduino.cc/Code/I2CEEPROM

I'm using a 24C02_6. I think the 5 of 256 is missing. So it must be a 24C0256.
I'm also using a 24C0.. unreadeable value but I can write from 0 to 255, 256 is otherwriten with the first value so I guess it's a 24C0256 also.

The project is to copy the data from an Eeprom to a new one.

If I got my code working for writing and reading now, I don't know how to do this.
Now I stored the good Eeprom's data in a Excel spreadsheet but have no idea how to program the new chip.



20  Using Arduino / Storage / Re: Problem writting I2C 24Cxx Eeprom on: April 01, 2013, 12:04:05 pm
Well, I put some pull up resistor on SDA and SCL (5KOhm between 5V and SDA and SCL) as it was said on were I've been looking from.

But it seems that the way the code is made is using the inner Arduino's pull up resistor !
And the wiring doesn't need external pull up resistor.

When I remove them, It seems to work fine.
I'll make some new test to be sure now that I'm getting unstuck with this.

But Why, when I made the mistake to put the Eeprom under 12V, it worked ?
Am I missing something ?
A luck I didn't burned my arduino and the Eeprom.

Anybody know the internal Arduino's pull up resistor. These must have been quite hot for some time
21  Using Arduino / Programming Questions / Why am I having so much trouble working with I2C EEPROMs? on: April 01, 2013, 11:20:02 am
Hi.

I'm a beginer with Arduino and coding.
Till now, I've done some small thing copying and modifying some part of code from different place.
I moreless understood what I was doing and at least, acting this way I was learning.

But now I want to work with I2C EEPROM, I'm facing so many trouble !
I wonder why ? I already used library for LCD and it was quite easy and evident.

But for the EEPROM, I'm stuck, stuck, stuck !
I'm trying to read example but no way it becomes clear to me. There is always a lack of comment to me.


I was given this link to help :
http://playground.arduino.cc/Main/LibraryForI2CEEPROM

So I understand that we can write or read Byte by Byte or also with big bunch of data like "page" or maybe bit by bit if needed.
All of this is surely very interesting but doesn't unstuck me.
I think the coding comment are way to light for me.
There is a too big step with my coding experience and using the wire.h library.

I feel so sorry already asking so much help on the forum, but the situation makes me depressed.
I don't want to give up with my project.
I don't even know precisely what to ask for help. On top of that, I'm facing problem writing (eratic writing) to the Eeprom, so it doesn't help to progress !

Moderator edit: thread title toned down.
22  Using Arduino / Storage / Re: Problem writting I2C 24Cxx Eeprom on: April 01, 2013, 04:07:48 am
No sorry, I have no datasheet because they are bits from different places.

Some are from my toner printer chip I want to rewrite, and some other from old TV's to try and test.

I'll have a look at the link but I'm very bad in programming and understanding program.

I'll come back and say something.

Thanks.
23  Using Arduino / Storage / Problem writting I2C 24Cxx Eeprom on: March 29, 2013, 12:33:33 pm
Hello.

I've been trying to work with I2C  24C02 Eeprom and got trough different issues.

With some help from the forum I fixed some but I still have problem writting data in the Eeprom.
I have erratic data when using this code.

Code:
#include <Wire.h>     // for I2C
#define i2caddr 0x50    // device address
byte d=0; // data to store in or read from the EEPROM

void setup()
{
  Serial.begin(9600); // Initialize the serial line
  Wire.begin();         // wake up the I2C
 
  Serial.println("Writing data...");
  for (int i=0; i<257; i++)
  {
    writeData(i,i);
  }
  Serial.println("DONE");
  Serial.println("Reading data...");
  for (int i=0; i<257; i++)
  {
    Serial.print(i);
    Serial.print(" : ");
    d=readData(i);
    Serial.println(d, DEC);
  }
  Serial.println("DONE");

}

// writes a byte of data in memory location addr
void writeData(unsigned int addr, byte data)
{
  Wire.beginTransmission(i2caddr);
  // set the pointer position
  //Wire.write((int)(addr >> 8));
  Wire.write((int)(addr & 0xFF));
  Wire.write(data);
  Wire.endTransmission();
  while(1) {
      Wire.beginTransmission(i2caddr);
      if(Wire.endTransmission() == 0)break;
    }
}

// reads a byte of data from memory location addr
byte readData(unsigned int addr)
{
  byte result;
  Wire.beginTransmission(i2caddr);
  // set the pointer position
  //Wire.write((int)(addr >> 8));
  Wire.write((int)(addr & 0xFF));
  Wire.endTransmission(1);
  Wire.requestFrom(i2caddr,1); // get the byte of data
  result = Wire.read();
  return result;
}

void loop()
{
}

I tried many thing and made a mistake.
I put 12V to the Eeprom instead of 5V. It means the Vcc Eeprom  was 12V, but also the SDL and SDA pull up resistor !

And this way, I got the writing procedure working good !

I was lucky to not fry the Eeprom and the SDA /SCL port of my Arduino !

But why does it work with 12V and not with the 5V (Arduino fed from USB or 12V). Even with proper 5V from Arduino board or external 5V, it doesn't write the Eeprom.
24  Using Arduino / Storage / Re: Problem for reading and writting I2C Eeprom 24c02 6 on: March 14, 2013, 07:51:49 am
Hi.

Sorry for the late response but I was on something else these time.

To make it working, I needed to power up the Arduino  through an external 12VDC power supply instead of the USB cable from the computer or even a 5vDC supply through Vin of the ARDUINO.

I also replace the delay by El Supremo's piece of code witch I thing is much more clever than wasting time with Delay and being not sure that the job is done !

But the problem was raelly the power supply of the ARDUINO. At least it now works fine.

Now I'm sure the writing and reading is ok, how can I write the proper number in each piece of memory ?

See, I've read the Eeprom I want to copy so I stored all the data in an open office format as .ods (OoCalc)or .odt (OoWriter) format)
1/   Read the data
2/   Copy from the SerialMonitor
3/   Paste in a calc or writer page to save the data in a safe place.

But I don't know how to program the new Eeprom with these data.
I'm not going to write each data at a time in the serial monitor. here must be a better way for sure.

Any advice.

How I can put these data in ?
25  Using Arduino / Installation & Troubleshooting / Re: How to find back my threads or the threads I've been answerring ? on: March 13, 2013, 07:42:41 pm
OK Nick, I've got this already.

I wanted to find back my threads even when there is no reply done.

So I got it trough my "Profile"...

Many thks
26  Using Arduino / Installation & Troubleshooting / How to find back my threads or the threads I've been answerring ? on: March 13, 2013, 08:16:01 am
Well, here is my present problem.

How to find back my threads or the threads I've been answering ?

I always have hard time to find back the threads I've posted.
Is there an easy way to do it ?
27  Using Arduino / Project Guidance / Re: Arduino Solar MPPT battery charger on: March 07, 2013, 04:49:00 pm
Hi.

Please, keep talking about this topic.

You might already know that some other people are working on that kind of project but I still give the following link in case :
http://www.freechargecontroller.org/index.php?title=Main_Page

http://thesolarpowerexpert.com/introducing-the-v4-charge-controller/

http://www.atmel.com/images/doc1659.pdf

Unfortunately, I'm a very beginner with ARDUINO and  I can't understand all the information given. But I'm very interested and I'm studying this project.

Please keep talking, sharing and giving your advice about it.

About what I know about the ARDUINO community, It would be much more active to share about the topic's link I've just given above on the ARDUINO forum.

I'm personally  looking forward a high voltage input (200V-250V) to 12V/24V output MPPT regulator. Not for the MPPT function but mostly to use high voltage and lower the line losses on solar panel and batteries' line and save cost on big and long copper wire. In that case; MPPT would just be a nice side effect !

Something like this would be nice !
http://www.dcsolutionsaustralia.com.au/renewables/solar-controllers-mppt/midnite-classic-200v-mppt-solar-controller.html


The one I'm talking about is not 20$. And the link doesn't even work in France !
28  Using Arduino / Storage / Re: Problem for reading and writting I2C Eeprom 24c02 6 on: February 15, 2013, 11:33:30 am
Hello Pete.

I've changed the (1) with the () ind the write, but it doesn't make any change. Still wrong data in the EEPROM.
The sketch in now as below :
Code:
#include <Wire.h>     // for I2C
#define i2caddr 0x50    // device address
byte d=0; // data to store in or read from the EEPROM

void setup()
{
  Serial.begin(9600); // Initialize the serial line
  Wire.begin();         // wake up the I2C
 
  Serial.println("Writing data...");
  for (int i=0; i<257; i++)
  {
    writeData(i,i);
  }
  Serial.println("DONE");
  Serial.println("Reading data...");
  for (int i=0; i<257; i++)
  {
    Serial.print(i);
    Serial.print(" : ");
    d=readData(i);
    Serial.println(d, DEC);
  }
  Serial.println("DONE");

}

// writes a byte of data in memory location addr
void writeData(unsigned int addr, byte data)
{
  Wire.beginTransmission(i2caddr);
  // set the pointer position
  //Wire.write((int)(addr >> 8));
  Wire.write((int)(addr & 0xFF));
  Wire.write(data);
  Wire.endTransmission();
  delay(10);
}

// reads a byte of data from memory location addr
byte readData(unsigned int addr)
{
  byte result;
  Wire.beginTransmission(i2caddr);
  // set the pointer position
  //Wire.write((int)(addr >> 8));
  Wire.write((int)(addr & 0xFF));
  Wire.endTransmission(1);
  Wire.requestFrom(i2caddr,1); // get the byte of data
  result = Wire.read();
  return result;
}

void loop()
{
}


By the way. I'm having so hard time with this I2C EEPROM, would you have any good link with some sketches very well explained. I haven't been able to find something that could help me properly yet !

At the end, my project is to reprogram a Laser printer chip.
So, read an EEPROM (brand new and already programmed), then, write the data to the old one, so I've got a spare one.

I'll need some advice to do this. I've already read the data of the new 24C04.
I'll now need to inject these data in the old one.

29  Using Arduino / Storage / Re: Problem for reading and writting I2C Eeprom 24c02 6 on: February 15, 2013, 03:25:55 am
Hi Pete (El Supremo).

As I said, I'm at the very beginning with I2C EEPROM devices, so I've just copied the code from the web without really understanding what is happening.

You're right about the comment, but I have only 1 EEPROM connected.
So I think it doesn't really matter for my present issue.
30  Using Arduino / Storage / Re: Problem for reading and writting I2C Eeprom 24c02 6 on: February 14, 2013, 06:07:52 am
Yes Nick, you might be right.

But as I wanted to try to write and read, I have a new issue.

The sketch I'm using :
Code:
#include <Wire.h>     // for I2C
#define i2caddr 0x50    // device address for left-hand chip on our breadboard
byte d=0; // data to store in or read from the EEPROM

void setup()
{
  Serial.begin(9600); // Initialize the serial line
  Wire.begin();         // wake up the I2C
 
  Serial.println("Writing data...");
  for (int i=0; i<255; i++)
  {
    writeData(i,i);
  }
  Serial.println("DONE");
  Serial.println("Reading data...");
  for (int i=0; i<255; i++)
  {
    Serial.print(i);
    Serial.print(" : ");
    d=readData(i);
    Serial.println(d, DEC);
  }
  Serial.println("DONE");

}

// writes a byte of data in memory location addr
void writeData(unsigned int addr, byte data)
{
  Wire.beginTransmission(i2caddr);
  // set the pointer position
  //Wire.write((int)(addr >> 8));
  Wire.write((int)(addr & 0xFF));
  Wire.write(data);
  Wire.endTransmission(1);
  delay(10);
}

// reads a byte of data from memory location addr
byte readData(unsigned int addr)
{
  byte result;
  Wire.beginTransmission(i2caddr);
  // set the pointer position
  //Wire.write((int)(addr >> 8));
  Wire.write((int)(addr & 0xFF));
  Wire.endTransmission(1);
  Wire.requestFrom(i2caddr,1); // get the byte of data
  result = Wire.read();
  return result;
}

void loop()
{
}

The result I got in the Serial monitor that I put in a spread sheet.
You can notice, all the Bytes seems not to be written as they should be.

I modified the 10ms delay in the "writeData" subroutine but nothing change even with 20ms delay instead !

Any Idea ?
Pages: 1 [2] 3 4