TUTORIAL: How to Wire up & Code an EEPROM with Arduino - Module (Part 2 - Wire Up & Coding)
Вставка
- Опубліковано 6 вер 2024
- How to wire up and code an EEPROM with Arudino.
Part 1: Theory, and about bits and bytes.
Part 2: Wire up, Coding and testing.
Wow! Looks like I have found another friend to spend time learning from! Thanks for your excellent work telling me a bit about a chip I have had in my Altoids box now for well over a year. You see, it came in a bulk parts box from Electronic Goldmine, they sell big lots of this sort of thing, you would be surprised what all comes. The chip I found in my box is nearly the same, but a bit larger, availing me of 256K and made by SK. I ran into it today as I was cleaning around my old power recliner that has been my home for all to many years now following an accident that took me out of the law enforcement game and left me quite unable to work. I just lost my wonderful wife of 51 years and 5 days a bit over a month ago, and that still smarts worse then I could ever have imagined. Cancer took her, it was quick and dirty form that left the whole family exhausted when it was over. Enough about my life, thanks so much for sharing yours. Now I have to figure out exactly what I want to store in my little memory chip, the data sheet says she is good for one million writes so I guess the only danger is, perhaps ESD, I too have been playing with cmos chips since their introduction to the general public and have yet to blow one that way. I think I had one of those wrist bands but never used it, it was, well a bit to confining for me, and for some reason I have developed a quite nasty case of claustrophobia. Too many buried alive films I think, I know when I was planning my late wife's funeral, I happened upon a UA-cam video on how they cremate, that cost me over 10 thousand USD, as after watching it, I went against my wonderful wife's wish to be cremated and went forward with a traditional burial. My family all agreed the only reason she wanted to be cremated was the cost, she wanted me to be able to take her insurance money and pay off some debts so I could go on without her paycheck. Wonderful lady, my wife, GOD how I miss her every damn second of every damn day since she was taken from me.
The naming 'Vcc' and 'Vss' has to do with the types of transistor in the IC package, and refer to the power rails within the chip. Vcc = Voltage Common Collector, is positive with respect to ground, while Vss = Voltage Source Supply is negative with respect to ground (and in many cases can just be tied to ground).
I thought your video was a little wordy at first - but I ended up really appreciating all the detail ! Great work ! I never saw part 1; your part 2 was more than sufficient by itself.
Thanks! It's difficult to find the balance in these videos, but generally speaking, I'll provide minimum theory/maximum practical. :-)
To elaborate a little on A0, A1 and A2 and the chip address starting at 80.........
The chip is designed to allow you have a chain of up to eight of them addressed 80 to 87 (50 to 57 in hex or 1010000 to 1010111 in binary. You do this by setting the A0, A1 and A2 pins high as necessary to form the least three significant bits.
A good example as to why you would want to do this are printer toners. My Ricoh laser printer has four colour toners with 24LC01 (1 kbit) EEPROMS. These are set to addresses 80, 81, 82 and 83 by the wiring on the little PCB they are mounted on to. This way, the printer can address each toner individually on the one I2c bus.
Well done Antony! This is a great building block! I was able to reproduce your result here at home. I was wondering what you did with the bit shift and the AND operation. You are such a good developer, you probably did that without even realizing it's on another level! Well thank you and keep these building blocks coming!
OK: figured it out, I think... An unsigned integer is 2 bytes, you shift right 8 places and bitwise AND the value so you have no leading ones as you write the command register byte. Nifty!
beautiful tutorial! I plan on making an "open source" mp3 player with programmable pins for projects revolving around simple things, such as hooking up another "open source" mp3 of its kind into making a more powerful variant of itself and etc.
sir, how to save data with char, float, or string?
Definitely a lot safer than using an SD card to store the data. Also, probably uses a lot less memory, too. I think I'll be incorporating an EEPROM in my BMS I'm working on 😎
Korishan Hey, yeah, I wasn't actually looking forward to doing this video because I assumed it would be difficult for me to learn, tedious to code, and a headache to explain. It turns out though that it wasn't too bad. Actually, the concept and methodology is pretty good. I think I'd probably use this for my projects too. You can get much larger eeproms too!
Sure it's nice using EEPROMs and I absolutely liked the video - so thanks for it! Still I'm wondering what would be the particular drawback of using an SD card instead. Aren't there finished libraries to use it? And how about storing data in EEPROMs: Are there no libraries available and if Yes is that because EEPROMs are much less frequent used yet?
I mean it's great understanding the concept behind an EEPROM and I will have to fiddle arround with some to read out its content to get to the secret keys of my own car 😝 but in general I'm a bit surprised that there aren't libraries for some EEPROMs or maybe that was just not really spoken about in the video?
You'd use an EEPROM to store data that doesn't change, or doesn't change often. Keep in mind the 'ROM' part of the name.
EEPROMs are much slower to write to than an SD card. I wouldn't there'd be any space saving advantage to using an EEPROM. Your data is what it is, and it won't change by storing it in a different place. Also, because of the targeted uses of EEPROMs, they tend to be very small compared to an SD card. We're probably talking Megabytes at max. Most will hold less than a 3.5" floppy disk. There are big EEPROMs in use, like a BIOS EEPROM on a computer, but the type shown here is less than 64kB. You could fill it, and that would be around 1/12th of a floppy.
Well explained. But just for info, a byte holds between 0 and 255 (not 254 as you said at the end), or in hexadecimal 0x00 to 0xff
stuartajc Hi, thanks, you're right. 2^8=256 cells. 0-255. I think I've been doing too much networking!
Hi, guys. Is it 255 for EEPROM of all sizes? Does it change?
A Byte is by definition 8 bits, and so is the same in EEPROM, RAM, Disk, Tape or whatever. It never changes.
That's was the first thing i thought, network address and broadcast address.
@@feitan8745 255 is still a valid network address
Nice work Antony.
Thanks andrew... I think I've mixed the thumbnails up lol.
Thank you very useful.
i thought the EndTransmission before the request would make it not work when i watched your video. but i understand now, you let the thing do its thing and then wait until the data is transmitted
Antony, nano you used has 1k eeprom but adding this chip has 64k which is good - it can come in handy in future
lots of use cases for these if you can address things in ascii. Also, did not know from your coding that are cmp-sci fella( just for laughs )
Raad Yacu haha! Yes, for many years now. Only 1 year low level though.
hi, this video has helped me a lot..........but
Im getting (error: expected ',' or '...' before numeric constant) error at line 2
i.e #define chipAddress 80 .....could you help me out pls.
Awesome vid - a great primer for me, i need an outboard storage for assembler code for an audio DSP chip im thinking of extending your code using an esp32 with wifi comms. So anyway thx a bunch 👍
I dont understand what was happening here for chip and cell address. I thought this was a hardwired thing and therefor the Arduino wouldn't need to be told this, could you explain this part a little more for me plz. eg could i just do something like digital.write (A0 =LOW), A1, A2. Wire.beginTransmission();......
Can anyone please help me , confusion is why there is
wire.write() used in readFrom() ?
Can you please upload a video . making of rtc module ds3231 and eeprom
Where are any of the other pins on the chip used? This looks like all data is read and written from the I2C bus.
Very helpful. ..can you please share SPI EEPROM interfacing with pic18f4550
So can i change the data in immobiliser eeprom and make it accept an value?
Fs0c1ety_BS actually I found that video for the same or similar reason.
I would think one could answer 'Yes' as long as the EEPROM doesn't have additional security features.
The point is rather with working on IC level on cars: 1. You have to get physical access to the IC equals to you need to know where it is located and then take that part out of your car = car out of work for as long the work goes. Then you have to open up the part i.e. the tacho and you still need to know which chip it is.
2. Possibly you need to desolder the IC which is a next risk... OR you might have to put power on the IC while it is connected on the board... which also can be a risk.
3. You need equipment to contact the IC...of course that isn't a problem for professionals and IF you know experienced people it will be easy to get the right equipment for a low price.
4. Besides suitable contacting hardware i.e. a SOIC-8 clamp you will either need a finished SW tool which you have to trust to work fine... or you would end up writing your own code and just trying to solder connections directly to the IC while sitting on the PCB and of course in any case you would need to ensure that maximum ratings for that chip are never exceeded.
So, in short, yes it should simply work fine and I am actually myself considering that at least as I am electronics by first education and IT by second one... but I would tremendously prefer another way of reading out the EEPROM by in my case example VAG K+Can commander not needing to take the risk even I have visibly had the corresponding PCB and chip in front of me on the bench yesterday :o
Great work sir... I have to test an ATAES132A crytpo IC... This IC works on SPI communication protocol..I wanted to know that for connections we just need to attach the jumpers like this...or we have to add capacitors to the ground?? Or would require logic level shifter to work with Arduino...Please reply it's really urgent..
That's pretty cool. Can you use this to read any eeprom off commercial equipment, save it , then re-write it to an new eeprom?
Can I use it for memory extension for program itself? I have lot of libraries in the program and memory is too small
Hi Please help I only have 48 hours to do this project. I have a stm32f411(black pill module) and a 24LC64. I am using the arduino IDE. I have lots of other things going like TFT, rotary encoder, analog etc... so i just want to keep my program in arduino IDE. The 24LC64 i have 3 address pins to ground like you... address DEC 80 or HEX 50 ... on the stm32f411 the Data pin for i2c is PB7 and the CLK pin is PB6.
I need the correct header file and then i guess the code you have here will work just fine.
the pin numbers are different.
I downloaded stm32Cube MX that apparently will make the board talk to an eeprom via i2c... however it makes about 30 files!!! and of course wants to make all the configuration files for KEEL or other IDE than Arduino... please help. :o) cheers Ian
Hello, could you help me, how to just read the ink chip, what code inside the chip, using this arduino, the chip is MDK341V
Superb video! Subscribed. :o)
Hello Ian I watched all your videos on programming EEPROMS I am wondering are you going to make a tutorial about 12C serial programming?
@@ihtsarl9115 oh... that's not me! however I would also like a video on 12C :D
Hey mate where did you buy all of this stuff from? Could you past me a link please?
thank you so much!
Ottima spiegazione. Vorrei sapere come utilizzare la eeprom esterna, accoppiandola ad un ATTINY 85 per aumentare la memoria e la capacità di caricare uno sketch più grande.
grazie
How do i adjust the code for the 24LC01B?
I'm interested in the same question. Have you found a solution?
Vss is basically source supply
your screen is not focused so we cannot read the program can you send a copy of the program ?
Awesome...
Hi ..
It has 24LC04B and I have a problem reading the data. All the readings come with the number 255. What is the solution in your opinion? Please Help
By default, EEPROMs have a 1 written to every bit location, so 8 bits of 1 adds up to 255, meaning that your EEPROM is erased. Either that, or you're not reading anything and every bit comes out as 1 just because ports tend to "float" high.
Great
Thank you for the video, but 0xFF (FF Hex) is 255 decimal... there is no other "way to look at it". For anyone who gets confused by zero-based counting - look at it like this: Take eight apples, line them up on the table in a row. Get a knife and carve a '0' (zero) in the first apple. Carve a '1' in the second, carve a '2' in the third, and so on. When you get to the eighth apple, you'll have carved a '7' into it. You still have eight apples, but when you start counting at zero, you only get to '7'. If this boggles your mind, and you're thinking to yourself, "I can't, I just can't..", first, see a life counselor :-), then switch to Python or another high level language where addresses are mostly things you'll never have to deal with.
Counting in Hexadecimal is no different. ("Should I say 'zero lives matter'?" "No, that'd probably be taking it too far, too easily misunderstood." "Fine...") Zeroes Matter. So if you're talking about digital addressing, 0xFF is 255, but it's also the 256th address. Just something you have to get used to. When you're talking data, you can start at zero (it can avoid confusion if you have a lot of addresses in the same code), or start at one. Use whichever you're more comfortable with, but addresses will always (with a few weird exceptions) be zero-based.
I like to think of binary numbers as states. So a 3-bit number has 8 states. Those 8 states can be numbered (as in a cardinal number set, starting at zero) as 0->7. But their rank (ordinal number) is 1-8 (1st, 2nd, 3rd...7th, 8th) If we just use their cardinal order for counting, we can obviously represent 8 different numbers: 0, 1, 2, 3, 4, 5, 6 and 7. It's just the issue of starting at zero which most people aren't familiar with.
We can use those states to represent things other than numbers also. I still have to do mental gymnastics sometimes to remember that 256 values will start at 0 and end at 255, but I'm not confused by it. Once you deal with numbers like these enough, you'll get to know them by rote, and won't be worried about it.
If it helps, imagine you have a single switch. You want to represent as much information as you can with that switch.
When the switch is off, that is one state. When it's on, that is a second state. So with 1 BIT (binary digit) you can represent 2 states. Numerically, that's 0 and 1. You have a number set {0,1}. You have 2 values in there. With those values you can count 0... 1. You only get to 1, but you have 2 numbers.
When you add a second BIT, you double your set:
00 = 0
01= 1
10 = 2
11 = 3
So your number set is {0, 1, 2, 3}. You have 4 values. You can count 0... 1... 2... 3...
You can only get to 3, but you've taken 4 steps or values to get there.
Add another bit and you double the number of values in the set, and so on.
The bonus of using the concept of states is when using binary to represent "options" instead of a number.
You can make a value of 0 to be useful. It can represent something specific (not 'nothing' as is our habit) and 1 can represent some different. So 1 bit, 2 states, 2 specific and meaningful values or options. Of course this also brings with it the importance of LEADING zeros. We normally don't write 000100 to represent 100, because numerically, those leading zeros have no value. But if you're using those BITs to represent meaningful states, those leading zeros are just as critical as the 1 or the following zeros.
I have got "0" even without EEPROM. I guess it should return 128 even without connecting to the chip.
Hi Antony, can you tell my how I can store Float value or a String in EEPROM? Please advice me or create video tutorial on it. Suppose I want to store a predefined temperature like 25.5 C in EEPROM. Please advice me.
Hey, to store 25.5 (or up to 255.99), you can use 2 bytes. The first byte can represent the integer portion, and the second byte can represent the decimal portion. So to save 25.5, (or 25.50) you'd simply use the method in the video to store '00011001' (25) in one byte, and '00110010 (50) in the next. When you come to assemble the number, if you simply want to display it somewhere, you can simply concatenate it together, but if you want to cast it into a float or whatever and perform operations on it, then you can simply do this FLOAT = INTEGERPART + (DECIMALPART/100).
If you were to store that as a string, it would take 5 bytes. This is because strings are stored character by character, byte by byte. So for each character which you save, you actually save a number which represents that letter according to the ASCII key code. Strings kind of add another layer of complexity to the equation.
For real floating point, wouldn't you just store the first 8-bits, but shift to the left by 8, store the first 8 bits, etc until all the bits are stored?
Then to read them back, read 8-bits, shift left, read the next 8-bits, OR the 2 values together, read the next 8-bits, OR them together etc?
All the time tracking how many bytes are used for each float, and use that size as an offset for the address to read?
May use 4 or 8 bytes, but you get the full precision. Don't know how bit shifting effects floats, but I think that would work.
So if there is a 3 bit address, does that mean there are 9 registers? Or is that not the word to use for it?
3-bits allows you to set an address of 0 - 7. It's one address. The address is 3-bits long. You can have the following addresses:
0, 1, 2, 3, 4, 5, 6 and 7
So, you can have up to 8 of these devices (device 0 through to device 7) on the I2C bus. Each device on an I2C bus needs a unique identifier 'address'.
If you have 8 people standing in a group and you say to the group "Tell me how old you are", 8 people will reply and you'll get 8 answers simultaneously. Not helpful if you want to know how old 'John' is. You may not even be able to hear John's response!
But if you say to the group "John, how old are you?". only John should reply. You get a single answer. This is how the above concept works.
No registers are involved.
Thanks! Do you see feasible for store bitmaps?
Ander R hi, you could, but remember that it only has a small amount of memory.
can the arduino be used as an eprom? that would negate the need for an eprom
takeaway guru the question is not if it can be used as such - just if it has EEPROM or not ;) and I guess Arduino doesn't, but as much as I know some CPUs comprise small eeproms
Some Arduinos use a microcontroller with an internal EEPROM. They can be restrictively small (like 1024 bytes) and the number of times they can be written to is much smaller than the discrete external EEPROMs. If you need to write many times, or a lot of data, an external discrete EEPROM is required.
The internal EEPROM _may_ be faster to access (read from) so it's worth considering very important, unchanging data in the built-in EEPROM.
Hi dear ..
where the code for this eeprom with arudino PLZ
hello sir great project but I need coding of it can you give me the code
please
That helped a lot. Nice clear well explained tutorial! Any chance you could help me switch my code from internal avr eeprom to a 24c64?
Not "nice clear well explained" at all.
Can you store arrays?
You can store just about anything. You only need to figure out how.
For example: How big an array? How many dimensions? How much storage does each array element take up? Answering these questions are essential to figuring out how much storage you'll need and therefore the size of EEPROM you'll need.
After that, you need to figure out how to store the contents of the array in a format which will allow you to retrieve it later.
AT93C46D ??
programing language name please?
C++?
How many addresses are there?
Michael Dahlinger check the first part of the video where such is explained well
ide(code) video view too small otherwise excellent lesson
CHADDRESS
where is the code please?
I don't release any code sorry! :-)
Pause the video when the code is on the screen, take a screen shot and then copy it into Arduino. Problem solved.
How to name change (for icon) DVD player for memory ic .