|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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
Thanks ~Tseres |
|
#2
|
||||
|
||||
|
Re: new to EEPROM
Well, first off, here's a listing I wrote a 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 )-q |
|
#3
|
||||
|
||||
|
Re: new to EEPROM
thanks...that really does help clarify things...also...is it possible to see a copy of your eeprom code? is it really complex?.....
ya.... |
|
#4
|
|||||
|
|||||
|
Re: new to EEPROM
Ohhh....So wait, how do I store autonomous data on EEPROM?
|
|
#5
|
||||
|
||||
|
Re: new to 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: Code:
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 -John |
|
#6
|
|||||
|
|||||
|
Re: new to EEPROM
![]() |
|
#7
|
|||||
|
|||||
|
Re: new to EEPROM
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. |
|
#8
|
|||||
|
|||||
|
Re: new to EEPROM
Ok, how do I do that?
|
|
#9
|
|||||
|
|||||
|
Re: new to EEPROM
As everyone else has said, you have 1024 bytes of EEPROM. What they haven't said is how to use it...
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... ).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. Last edited by JBotAlan : 22-05-2007 at 13:05. Reason: More info |
|
#10
|
||||
|
||||
|
Re: new to EEPROM
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....
|
|
#11
|
|||||
|
|||||
|
Re: new to EEPROM
Yep, thank you all and thank you tesers for asking |
|
#12
|
|||
|
|||
|
Re: new to EEPROM
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 k9wis@yahoo.com |
|
#13
|
|||||
|
|||||
|
Re: new to EEPROM
I'd like to see that Autoflex program of yours. I've sent you a message.
Quote:
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? Last edited by Bomberofdoom : 23-05-2007 at 18:08. |
|
#14
|
|||
|
|||
|
Re: new to EEPROM
Quote:
Quote:
But its not a substitute for a well thought out autonomous routine. This year we used the camera to home in on the lights. Quote:
Good Luck and feel free to experiment. Brian |
|
#15
|
|||||
|
|||||
|
Re: new to EEPROM
Thank you very much! I'll be trying your code sometimes.
![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| EEPROM Problem | Jake M | Programming | 0 | 19-02-2007 20:04 |
| EEPROM Code | Kevin Watson | Programming | 31 | 12-01-2006 11:37 |
| EEProm | Ryan Cumings | Programming | 2 | 01-02-2005 12:47 |
| EEPROM Problems | devicenull | Programming | 8 | 27-01-2005 15:07 |
| EEPROM + Backup Battery | Ryan Cumings | Programming | 4 | 28-02-2004 13:30 |