Wednesday, April 21, 2010

pHduino Firmware v041 released

Hi everybody.

It is a newest release of the pHduino firmware with some little modifications. The most import addition is a magic number to simplify the pHduino operation.

Changelog v04_20100421
  • Removed duplicated unsigned word from readADC function.
  • Added magic number for check empty memory or different data block.
  • Clean up of version strings.

Magic Number

Let's suppose you just mounted a new pHduino. This the first time you will turn it on. During the first initialization, the firmware reads the EEPROM device to read the last parameters. But, this is the first time. So, there isn't no data in the EEPROM that makes sense. In this case, the pHduino will stop. You need open a serial terminal and type the command to reset the device. Then, the reset process will "format" with default values and the devices will work correctly.

The magic number simplify this process. Magic number is a number that helps to identify some procedure.

http://en.wikipedia.org/wiki/Magic_number_(programming)

This number can be any value. In my case, I encoded the word base, from acid/base, using Hexspeak.

http://en.wikipedia.org/wiki/Hexspeak

The results is 0xB45E (BASE).

So, every time you turn the pHduino on, the firmware reads the parameters data block from the beginning of the EEPROM and updates the variables. After that, the firmware check if the magic number is 0xB45E. A new microcontroller will have garbage in the EEPROM and this test will fail. As a result, the firmware will reset the EEPROM automagically :-)

Have fun.

Project
http://code.google.com/p/phduino

Discussion group
http://groups.google.com/group/phduino

Blog
http://phduino.blogspot.com

2 comments:

  1. Hello Carlos,

    Can you provide me the link for pHduino code.

    Many thanks

    Ula

    ReplyDelete
  2. http://code.google.com/p/phduino

    ReplyDelete