加速度計まで実装した相互通信動くやつ、レシーバー
Dependencies: ADXL345_I2C mbed INA226
Fork of RS485R_2 by
Revision 3:8e73f0779dc5, committed 2015-12-27
- Comitter:
- YusukeWakuta
- Date:
- Sun Dec 27 19:50:07 2015 +0000
- Parent:
- 2:2b98a651b0a1
- Child:
- 4:dbe62d9b6087
- Commit message:
- INA?????????????
Changed in this revision
INA226.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/INA226.lib Sun Dec 27 19:50:07 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/tosihisa/code/INA226/#8950b0f31d73
--- a/main.cpp Sat Dec 05 11:21:06 2015 +0000 +++ b/main.cpp Sun Dec 27 19:50:07 2015 +0000 @@ -1,6 +1,7 @@ //相互通信確認用 #include "mbed.h" #include "ADXL345_I2C.h" +#include "INA226.hpp" #define BUFFER 30 Serial rs485(p13,p14); @@ -9,10 +10,15 @@ ADXL345_I2C accelerometer(p9, p10); PwmOut servo1(p21); PwmOut servo2(p22); +I2C i2c_Ina(p28,p27); +INA226 Ina226(i2c_Ina); + int counter = 0; int servo_deg1 = 0; int servo_deg2 = 0; +double *Voltage; +double *Current; int acc[3] = {0,0,0}; @@ -37,6 +43,10 @@ rs485.putc((signed char)acc[1]); rs485.putc('Z'); rs485.putc((signed char)acc[2]); + rs485.putc('V'); + rs485.putc((signed char)*Voltage); + rs485.putc('C'); + rs485.putc((signed char)*Current); // rs485.printf("X%iY%iZ%i\n\r",(short)acc[0],(short)acc[1],(short)acc[2]); wait_ms(2); Receiver = 0; @@ -65,8 +75,16 @@ accelerometer.setPowerControl(0x08); } +void INA226(double *Voltage,double *Current){ + if(Ina226.isExist() == 0){ + Ina226.getVoltage(Voltage); + Ina226.getCurrent(Current); + } + } + int main() { + rs485.baud(14400); init(); while(1) { accelerometer.getOutput(acc);