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





 

June 2006, Issue 191

Earth Field Magnetometer
Cypress PSoC High Integration Challenge 2004 Winner


MAIN ROUTINE

The main routine is shown in Figure 4. After initialization, the system enters Sleep mode until you press a push button, a transition occurs on the serial receive data, or the sleep timer expires. Once each minute, the analog hardware is powered on and a new measurement is stored in the EEPROM. It’s arranged as a 16-KB circular buffer, which can store about 10 days of data. I save bits 11:4 of the 14-bit measurement, which gives a resolution of 4 nT and a 1,024-nT range. Values outside this range will wrap around.

(Click here to enlarge)

Figure 4—The main routine waits for a button press or incoming serial activity while taking measurements at regular intervals.

The sleep timer isn’t accurate enough to time the samples, so I calibrate it against the main oscillator by computing the number of sleep timeouts needed for 1 min. Because the low-speed oscillator can drift over time, this calibration is repeated once per hour. The purpose of the magnetometer is to examine trends in the magnetic field variations rather than log the exact times of occurrences, so precision isn’t needed.