
Measure resistance with INA226
Dependencies: INA226 TextLCD mbed
Fork of INA226TEST by
Revision 3:1bd37786be90, committed 2016-05-14
- Comitter:
- oteki
- Date:
- Sat May 14 10:10:05 2016 +0000
- Parent:
- 2:d3723c3e869b
- Child:
- 4:04014356c355
- Commit message:
- LCD??
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat May 14 00:51:05 2016 +0000 +++ b/main.cpp Sat May 14 10:10:05 2016 +0000 @@ -93,7 +93,7 @@ led[0] = 1; led[1] = 0; if((VCmonitor.getVoltage(&V) == 0) && (VCmonitor.getCurrent(&C) == 0)){ - offset = 10*V/C; + offset = (float) 10*V/C; } //offset = R1 / (VCC / (sensor.read() * 3.3)- 1);//オフセット初期値の取得 speaker = 0.0; @@ -128,8 +128,8 @@ }*/ float voltage = 0.0; for(int i = 0; i < SAMPLES; i++)voltage += sensor.read(); - voltage = voltage * 3.3 / SAMPLES; - resistance = R1 / (VCC / voltage - 1); + //voltage = voltage * 3.3 / SAMPLES; + //resistance = R1 / (VCC / voltage - 1); //if((fp = fopen("/local/data.txt", "a")) == NULL)return EXIT_FAILURE; //fprintf(fp, "%lld %f %f %f\r\n", now + time_sum, voltage, resistance, offset); //fclose(fp); @@ -210,13 +210,16 @@ case 'c'://continue float voltage = 0; - //for(int i = 0; i < SAMPLES; i++)voltage += sensor.read(); - //voltage = voltage * 3.3 / SAMPLES; - //resistance = R1 / (VCC / voltage - 1); + for(int i = 0; i < SAMPLES; i++)voltage += sensor.read(); + voltage = voltage * 3.3 / SAMPLES; + resistance = R1 / (VCC / voltage - 1); if((VCmonitor.getVoltage(&V) == 0) && (VCmonitor.getCurrent(&C) == 0)){ - //pc.printf("%d %fV , %fmA , R %f\r\n",count,V/1000,C/10,10*V/C); - pc.printf("%f,%f,%f\n", V/1000, 10*V/C, offset); + voltage = (float) V/1000; + resistance = (float) 10*V/C; + } + pc.printf("%f,%f,%f\n", 1.1, 200.0, 0.0); +// pc.printf("%f,%f,%f\n", voltage, resistance, offset); count++; break;