Sunday, August 30, 2009

Testing Wiseduino - EEPROM

This is the second post related to the testing of Wiseduino. The first one talked about RTC and it started by showing how to correctly plug in the FTDI cable or the FTDI breakout.

Now lets move on, to the external EEPROM, a 24LC256 memory chip, with a capacity of 32KB. It is connected on I2C (analog 4 and 5) and uses the Wire library to talk with the microcontroller.

We will test the EEPROM by loading some text from a file. This is how this works: a program on the PC reads the text file and sends the characters to Wiseduino, which, in turn, is running a sketch that reads the incoming characters and saves them to EEPROM.

Download the sketch here.

Some VBscript code is included at the bottom of the pde file. Cut and paste that VBscript code into its own file, and name it writeFileToCom.vbs, for example (the extension vbs is mandatory). (This is tested and working on Windows. On Linux or Mac OSX, this script needs to be re-written.)

How this works was explained earlier, in this post.

With the eeprom_quotes.pde sketch uploaded, Wiseduino waits for characters to be received from the PC. Now execute the writeFileToCom.vbs VBscript by double clicking on the file (Windows associates the file with its script engine, wscript.exe).
The VBscript opens the file C:\docs\quotes.txt, reads 10 characters at a time, then sends them over the serial port, until the end of file is reached.
Two things are required in preparation for the text transfer:

  1. create the C:\docs\quotes.txt text file (or download this file to c:/docs);
  2. in the VBscript, change the COM port number from COM7 to the one you are using;

The process of transferring the content of the file takes about 10 minutes for a 32KB of text at a baud rate of 9600.

We check that the text was saved correctly in the EEPROM by reading its content. We will use the same eeprom_quotes.pde to read data from EEPROM. To do this, open the serial monitor, then type "\l" (backslash, lower l) in its input box and hit "Send" button. The bottom window should start displaying the lines of text stored in the EEPROM.


Related posts:

No comments:

Post a Comment