m3pi EEPROM

Any way to access the 3pi EEPROM from m3pi and in slave? I want to make an LCD menu, to keep from recompiling upon a change of parameters.
donde

Hello.

You could definitely modify the 3pi serial slave program to support that. We don’t have specific library support for using EEPROM on the ATmega328, but WinAVR makes it really easy. Here is a short example of how you can do this using the functions in avr/eeprom.h:

winavr.scienceprog.com/avr-gcc-t … eprom.html

Note that there are also functions for reading and writing two-byte values (words): eeprom_write_word() and eeprom_read_word().

Keep in mind that writing to EEPROM on the AVR is slow (it typically takes more than 4 ms), and each EEPROM location is only rated for a limited number of writes. That number is something like 10k or 100k, which should be plenty, but if you aren’t careful, you can accidentally put an EEPROM write in a loop and exceed that rating in a matter of seconds.

You would then just need to add some new 3pi serial commands for writing bytes to and reading bytes from EEPROM, and you could modify the mbed’s m3pi library to send those new commands.

- Ben

Hi Ben,

Can I do this EEPROM addressing from the m3pi environment? Would I use m3pi. in front a statement? Probably not. I’m thinking this example could be within the slave 3pi slave program? And bringing in #include <avr/eeprom.h>
donde

If you want to use the EEPROM on the 3pi’s AVR microcontroller, you need to reprogram it to add that functionality. I don’t know off-hand if the mbed’s microcontroller has internal EEPROM you could use instead, but it must have some form of persistent memory. Do you actually need the 3pi to store the variables or could you just do it on the mbed itself? If it’s the latter, you should look for existing mbed libraries/examples that you can try out.

- Ben

I would like to show short menu of 3pi speed selections from 0.2 to 1.0 on 3pi LCD, before while() runs of line follower-PID program. I don’t think the mbed has user EEPROM to access. I would put the stored values in the 3pi EEPROM. Like 9 floats, from 0.2 to 1.0. Not sure how to do that.
donde

Hello,

You might want to look at the LocalFileSystem library.

-Paul

Hey Paul,

I wound up putting 7 speed values in an array, tied to 7 RFID tags. So, if I want the m3pi to go real slow, I pick the # 1 tag that says 0.25. If I want to go real fast, I pick the # 7 tag that says 0.9. The tags do double duty. They control access to the robot and select speed.
donde