This is the development sandbox for the DRV425EVM and its magnetic sensing.

Dependencies:   mbed

/media/uploads/Krabby127/ohmboyzvectorized.png

Repository for the 2015 OhmBoyZ Capstone group.

main.cpp

Committer:
davidcerrone
Date:
2015-11-28
Revision:
7:405e3ff6cbcd
Parent:
5:760f85b3f309
Child:
8:b127541c9149

File content as of revision 7:405e3ff6cbcd:

#include "mbed.h"
#include <math.h>
 
AnalogIn analog_value(A0);
 
DigitalOut led(LED1);

int main() {
    float meas;
    float b;
    printf("\nAnalogIn example\n");
    while(1) {
        meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
        meas = meas * 3300; // Change the value to be in the 0 to 3300 range (currently to mV)
        printf("meas = %fmV\n\r",meas); // Print out raw measurement in terms of mV
        b=((meas-1.65)/(4.0*12.2*100.0)); // Based on equation 1
        //VVOUT [V] = B × G × RSHUNT × GAMP = B [mT] × 12.2 mA/mT × RSHUNT [Ω] × 4 [V/V]
        //0 Tesla is VDD/2
        // 12.2 mA/mT
        printf("b = %f  Gauss\n\r",b); // Print out b field measure in milliTesla
        printf("B = %f  uT\n\r", b*100.0); // Output B field in micro-Tesla
        if (meas > 2000) { // If the value is greater than 2V then switch the LED on
          // greater than 410 microGauss [40 mT]
          led = 1;
        }
        else {
          led = 0;
        }
        wait(1.5); // wait 1 second
    }
}