version 3 通信方式,マイコン等に変更あり

Dependencies:   AQM0802A PID Servo mbed

Committer:
ryuna
Date:
Fri Mar 06 01:16:05 2015 +0000
Revision:
0:65b9e62cc2b6
check????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ryuna 0:65b9e62cc2b6 1
ryuna 0:65b9e62cc2b6 2 #include <sstream>
ryuna 0:65b9e62cc2b6 3 #include "mbed.h"
ryuna 0:65b9e62cc2b6 4
ryuna 0:65b9e62cc2b6 5 string StringFIN;
ryuna 0:65b9e62cc2b6 6
ryuna 0:65b9e62cc2b6 7 using namespace std;
ryuna 0:65b9e62cc2b6 8
ryuna 0:65b9e62cc2b6 9
ryuna 0:65b9e62cc2b6 10 //extern Serial pc; // tx, rx
ryuna 0:65b9e62cc2b6 11
ryuna 0:65b9e62cc2b6 12 string IntToString(int number)
ryuna 0:65b9e62cc2b6 13 {
ryuna 0:65b9e62cc2b6 14 stringstream ss;
ryuna 0:65b9e62cc2b6 15 ss << number;
ryuna 0:65b9e62cc2b6 16 return ss.str();
ryuna 0:65b9e62cc2b6 17 }
ryuna 0:65b9e62cc2b6 18
ryuna 0:65b9e62cc2b6 19 void array(int power1,int power2,int power3,int power4)
ryuna 0:65b9e62cc2b6 20 {
ryuna 0:65b9e62cc2b6 21 int input[4] = {power1,power2,power3,power4};
ryuna 0:65b9e62cc2b6 22 int value = 0;
ryuna 0:65b9e62cc2b6 23 string StringA[4] = {"0","0","0","0"};
ryuna 0:65b9e62cc2b6 24
ryuna 0:65b9e62cc2b6 25
ryuna 0:65b9e62cc2b6 26 string StringX = "0";
ryuna 0:65b9e62cc2b6 27 string StringY = "0";
ryuna 0:65b9e62cc2b6 28 string StringZ = "0";
ryuna 0:65b9e62cc2b6 29 string String0 = "0";
ryuna 0:65b9e62cc2b6 30
ryuna 0:65b9e62cc2b6 31 StringFIN = "0";
ryuna 0:65b9e62cc2b6 32
ryuna 0:65b9e62cc2b6 33 for(uint8_t i = 0 ; i < 4; i++){
ryuna 0:65b9e62cc2b6 34
ryuna 0:65b9e62cc2b6 35 value = input[i];
ryuna 0:65b9e62cc2b6 36
ryuna 0:65b9e62cc2b6 37 StringX = IntToString(i+1);
ryuna 0:65b9e62cc2b6 38
ryuna 0:65b9e62cc2b6 39 if( (value < 0) && (value >= -100) ){
ryuna 0:65b9e62cc2b6 40 StringY = "R";
ryuna 0:65b9e62cc2b6 41 value = abs(value);
ryuna 0:65b9e62cc2b6 42 StringZ = IntToString(value);
ryuna 0:65b9e62cc2b6 43 }else if( (value >= 0) && (value <= 100) ){
ryuna 0:65b9e62cc2b6 44 StringY = "F";
ryuna 0:65b9e62cc2b6 45 StringZ = IntToString(value);
ryuna 0:65b9e62cc2b6 46 }else{
ryuna 0:65b9e62cc2b6 47 value = abs(value);
ryuna 0:65b9e62cc2b6 48 StringY = "F";
ryuna 0:65b9e62cc2b6 49 StringZ = "000";
ryuna 0:65b9e62cc2b6 50 }
ryuna 0:65b9e62cc2b6 51
ryuna 0:65b9e62cc2b6 52 if(value < 10){
ryuna 0:65b9e62cc2b6 53 String0 = "00";
ryuna 0:65b9e62cc2b6 54 StringZ = String0 + StringZ;
ryuna 0:65b9e62cc2b6 55 }else if(value < 100)
ryuna 0:65b9e62cc2b6 56 {
ryuna 0:65b9e62cc2b6 57 String0 = "0";
ryuna 0:65b9e62cc2b6 58 StringZ = String0 + StringZ;
ryuna 0:65b9e62cc2b6 59 }else{
ryuna 0:65b9e62cc2b6 60
ryuna 0:65b9e62cc2b6 61 }
ryuna 0:65b9e62cc2b6 62
ryuna 0:65b9e62cc2b6 63 StringA[i] = (StringX + StringY + StringZ);
ryuna 0:65b9e62cc2b6 64
ryuna 0:65b9e62cc2b6 65 if(i == 0)StringFIN = StringA[i];
ryuna 0:65b9e62cc2b6 66 else StringFIN += StringA[i];
ryuna 0:65b9e62cc2b6 67
ryuna 0:65b9e62cc2b6 68 }
ryuna 0:65b9e62cc2b6 69
ryuna 0:65b9e62cc2b6 70 StringFIN += "\r\n";
ryuna 0:65b9e62cc2b6 71 }