circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

June 2006, Issue 191

Earth Field Magnetometer
Cypress PSoC High Integration Challenge 2004 Winner


MEASUREMENT DATA

The LCD shows a graph of stored measurements when a button is pressed. The graph is generated by creating a 20 × 16 bitmap using a 4 × 2 array of characters in the LCD’s character generator RAM (see Listing 1). The characters are generated in a memory buffer by the LCD_1_DrawBG routine, which sets a single bit at the correct height in the selected column without changing any other bits. This enables the C code to plot multiple data values in the same column. A scale factor selects whether there are one, three, or 72 values per column corresponding to a total graph width of 20 min., 1 h, or 24 h.

Pressing either button shifts the display forward or backward in time one screen width at a time. Pressing both buttons together changes the scale factor. Pressing the Forward button when the graph is already showing the most recent data will switch the system to Continuous Measurement mode. This displays a measurement value repeatedly until you press the Back button to return to normal operation. This is used when setting up the magnetometer because the sensor must be rotated to be facing north-south for proper operation, which is indicated by the highest displayed measurement value. Holding down the Forward button in this mode will enable Offset Adjustment mode, which adjusts the DAC output up or down in an attempt to bring the ADC value near the center of its range (0x0800). The display shows the offset and ADC values as well as the measurement value.

The magnetometer can be connected to a PC serial port to download data from its EEPROM at 19,200 bps. Any incoming data will wake it up. It will then look for a valid command byte. If it receives an A, all of the data points in its memory will be sent. A B will send only data stored after the buffer pointer was last reset. A C will reset the buffer pointer. If the magnetometer receives any other character or sees nothing for 500 ms, it will go back to sleep.

The straightforward download routine has no handshaking or error correction. I wrote a simple C program to convert the raw data to a list of decimal numbers that can be imported to a spreadsheet. Refer to the magconv.c file on the Circuit Cellar FTP site.