Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SDFileSystem mbed
Fork of Power_meter_kai_TP2 by
Diff: main.cpp
- Revision:
- 4:5858bcd3dc60
- Parent:
- 3:e7f77ec41f33
- Child:
- 5:131cbc4990e9
--- a/main.cpp Mon Sep 04 06:41:39 2017 +0000
+++ b/main.cpp Wed Sep 06 07:08:16 2017 +0000
@@ -7,14 +7,20 @@
Timer Time ;
Ticker sd_write ;
DigitalOut myled1(LED1);
+AnalogIn vin(dp9);
//Serial pc(dp16,dp15);
int count =0;//最初はTimeLog[0]から始まる
-//static unsigned long TimeLog[20];//20個の要素を「箱」を用意する
static unsigned long TimeLog[20];//10個の要素を「箱」を用意する
+
+float VinLog[20];
+float v; //mbedはfloat値として電圧を12bitで変換する。
+
unsigned long nowTime = 0;
+
+
void SD(){//この関数を0.05秒ごとに呼び出して、その度に経過時間をTimeLog[]に代入する。
//つまり、50ms毎の時間が配列に保存される。
@@ -26,13 +32,17 @@
if(count<19){
TimeLog[count]=nowTime;
+ VinLog[count]=v;
+ pc.printf("Bridge=%.2f\r\n",VinLog[count]);
+
count++;
}else{
TimeLog[19]=nowTime;
+ VinLog[19]=v;
- pc.printf("Hello World!\n");
+ pc.printf("Bridge=%.2f\n",VinLog[count]);
mkdir("/sd/mydir", 0777);
@@ -40,13 +50,16 @@
if(fp == NULL) {
error("Could not open file for write\n");
}
- fprintf(fp, "%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n",TimeLog[0],TimeLog[1],TimeLog[2],TimeLog[3],TimeLog[4],TimeLog[5],TimeLog[6],TimeLog[7],TimeLog[8],TimeLog[9]
- ,TimeLog[10],TimeLog[11],TimeLog[12],TimeLog[13],TimeLog[14],TimeLog[15],TimeLog[16],TimeLog[17],TimeLog[18],TimeLog[19]);
+ // fprintf(fp, "%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n%d\r\n",TimeLog[0],TimeLog[1],TimeLog[2],TimeLog[3],TimeLog[4],TimeLog[5],TimeLog[6],TimeLog[7],TimeLog[8],TimeLog[9]
+ // ,TimeLog[10],TimeLog[11],TimeLog[12],TimeLog[13],TimeLog[14],TimeLog[15],TimeLog[16],TimeLog[17],TimeLog[18],TimeLog[19]);
+
+ fprintf(fp,"%d,%.2f\r\n%d,%.2f\r\n",TimeLog[0],VinLog[0],TimeLog[1],VinLog[1]);
+
myled1 = 1 ;
fclose(fp);
free(fp);
- pc.printf("Goodbye World!\n");
+ pc.printf("Noe logging\r\n");
count=0;//カウントをリセットする
@@ -62,5 +75,6 @@
while(1){
nowTime = Time.read_ms();
+ v=vin.read()*3.3;
}
}
