new to EEPROM

hey everyone…i’m going to be the team programmer next year. so far i can do the major robot functions (driving, solenoids, etc) and i’m working on gyro code as well as camera code. i have a few questions about the EEPROM. i have kevin’s code, and i understand the concept and all, but what actually gets written to the eeprom when i use the write functions? cas i assign a variable that gest written? can i store a series of values to one of the 16 slots (i think its 16…)? or, could i even store a function? and for the camera code, i know how to assign the RGB values to track in the header file, but i also know that the code can get values from the eeprom…how do i save the values there? i noticed that the eeprom_write function in the code saves an unsigned character…so i can only save one byte of data per slot? i’m confused about all of this…any answers would be helpful :slight_smile:

Thanks:)

~Tseres

Well, first off, here’s a listing I wrotea while ago of hardware in the 18F series processors.

There are 1024 (what a coincidence! :] ) bytes of EEPROM right on board the processor. One unsigned character is one byte of memory… personally, I don’t use kevin’s driver, I have my own, but, in concept all you are doing is writing and reading bytes to/from a non volatile memory… just remember to hold on to your addresses!

most likely what kevin has done is divided the 1024 bytes of memory into 16, 64-byte ‘chunks’… to help with organization of your memory. If you need more specific to kevin’s code help, for the time being somebody else will have to help! (i’ll read up on kevin’s eeprom code when i get a chance though, just for the sake of knowing :rolleyes: )

-q

thanks…that really does help clarify things…also…is it possible to see a copy of your eeprom code? is it really complex?..
ya…

Ohhh…So wait, how do I store autonomous data on EEPROM?

if you have say 3 motors and you want to try a simple example, youc an store the value to send to the victors during autonomous. Then make a timer so it reads and assigns all 3 values every 1 sec or what ever time intervale you want.

as an example:

EEPROM Contents:
Motor Left
Motor Right
Arm Motor
Motor Left
Motor Right
Arm Motor
Motor Left
Motor Right
Arm Motor
Motor Left
Motor Right
Arm Motor
Motor Left
Motor Right
Arm Motor
Motor Left
Motor Right
Arm Motor

I didn’t include addresses because I have never actually dealt with EEPROM before. But this is the basic theory behind it.

-John

:confused:

The user-programmable PIC in the Robot Controller has 1024 bytes of EEPROM in it. Reading a byte from EEPROM is easy: set the address and read the value. Writing is a bit more complex: set the address, set the value, flip some control bits, wait a specific amount of time, flip some more bits, wait, flip, wait, done. Kevin Watson wrote a library that takes care of all the details behind the scene, so all you need to do is call the functions that read and write values. It keeps a buffer of requested data writes so you don’t have to wait around for it to finish each time you want to change a value.

It might help if you consider EEPROM to be the equivalent of a data file on disk. You can make changes to it which will not disappear when the RC is powered down. Kevin’s camera communication and servo tracking code uses EEPROM to store configuration values. The TechnoKats this year adapted and extended the idea to hold PID calibrations for the drivebase and arm, as well as the desired pan and tilt values for driving to the target light. Instead of changing #defines in the code, recompiling, and downloading every time we want to modify a value, we just use a menu-driven system to change the numbers directly on the robot.

Ok, how do I do that?

As everyone else has said, you have 1024 bytes of EEPROM. What they haven’t said is how to use it…:wink:

When you have Kevin Watson’s EEPROM code installed, you call EEPROM_Write() with the address you want to write to (this needs to be between 0 and 1023, inclusive) and the value you want to write. Later on, call EEPROM_Read() with the address you wrote to, and it will return the value saved in EEPROM.

If you call EEPROM_Write(0,1); (which writes 1 to the first byte, byte 0, in EEPROM) then call EEPROM_Read(0); it will return 1. This lasts even if the controller loses power–if you called EEPROM_Write(x,y), and that’s the last byte you wrote to that address in EEPROM, EEPROM_Read(x) will always return y.

The controller doesn’t care where you save data in the EEPROM; it is entirely up to you. I suggest making a quick spreadsheet listing which address is what.

The best part about EEPROM is that all of it is at your disposal. The default code does not touch EEPROM at all. You can use every byte, 0 to 1023, for whatever you want. You could even make it a 1KB flash drive, if you want (but I’m not sure if you could find a good enough MP3 encoder to get your music compressed that small…:smiley: ).

If you need specific code, I can probably supply it, but you learn best when you figure it out yourself–try it!

Happy coding
JBot

EDIT: If you want a menu-driven system, you will need to build it yourself. Check into some more of Kevin’s code–there is an example of a terminal in Kevin’s “Bells and Whistles” camera code. You will need his serial driver (no point in writing that yourself…it’s a lot of gross low-level garbage) at the very least.

Again, I’ll help you with the specifics if you really can’t figure it out, but I’d like you to take the plunge yourself.

thanks. ya…i figured out how the camera tracking values use the eeprom, now i’ll just have to play around with it. maybe a menu driven system? or maybe autonomous stuff…

:smiley: Yep, thank you all and thank you tesers for asking

Send me your email and I will send you a copy of our Autoflex program that stores driver commands into the eeprom . Then when your in auto mode the robot will re-enact what your drivers justt did.

I have an FRC and vex version.

Brian
team 1675
[email protected]

I’d like to see that Autoflex program of yours. I’ve sent you a message.

our Autoflex program that stores driver commands into the eeprom . Then when your in auto mode the robot will re-enact what your drivers justt did.

If I understand how your program works from what you’ve said, I must say it isn’t always effective for Rack n’ Roll. You re-enact what the drivers just did, but when the rack is shifted it won’t always be in the exact spot.
Of course, it’s much better than nothing(nothing being doing nothing or driving by dead reckoning).

Well, I received the code. It’s really neat for rookie teams, I must agree. Good job.

So, now that I understand a bit about EEPROM, I understand that I don’t need to use that function I did to save points of distances from the rack, I can use the EEPROM.
So lets say if I want to save a few points of distances while I’m on manual mode, I need to assign a button to call for EEPROM_Write(); and advance the address number in order to assign another point?

If I understand how your program works from what you’ve said, I must say it isn’t always effective for Rack n’ Roll. You re-enact what the drivers just did, but when the rack is shifted it won’t always be in the exact spot.

BC-True enough…If your going to have a dynamically changing field then autonomous get complicated. Your robot will have to read and react to its environment. Autoflex worked very well for Triple Play and Aim High.

Of course, it’s much better than nothing(nothing being doing nothing or driving by dead reckoning).

Well, I received the code. It’s really neat for rookie teams, I must agree. Good job.

BC-Exactly the purpose of Autoflex. To get teams who either ran out of time or resources to have autonomous ready for a tournament. We could get robots up and recording in about 15 minutes. With autoflex there is no excuse for just sittng there.

But its not a substitute for a well thought out autonomous routine. This year we used the camera to home in on the lights.

So, now that I understand a bit about EEPROM, I understand that I don’t need to use that function I did to save points of distances from the rack, I can use the EEPROM.

So lets say if I want to save a few points of distances while I’m on manual mode, I need to assign a button to call for EEPROM_Write(); and advance the address number in order to assign another point?

You got it…

Good Luck and feel free to experiment.

Brian

Thank you very much! I’ll be trying your code sometimes. :smiley: