Kazyoshi Morita / Mbed 2 deprecated friction_measure

Dependencies:   Dynamixel mbed

Revision:
0:4e684157ecca
Child:
1:f43ebe88228e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Sep 06 12:54:00 2018 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+#include "HX711.hpp"
+#include "Dynamixel.h"
+
+HX711 hx711(p21, p22);
+Serial pc(USBTX, USBRX);
+Dynamixel motor(p13,p14,p15,0xFE,57600);
+
+//Dynamixel回転方向対応用
+//多分11bitのうちMSBが符号,最上位で回転方向を指定している
+move(int speed){
+    if(speed >= 0)
+        motor.setSpeed(speed);    
+    else{
+        motor.setSpeed(-1*speed+1024);  //11bitのうちMSBが符号
+    }
+}
+
+//--------------------HX711
+void calibrate(float gram){
+    hx711.setScale(1.f);
+    hx711.tare();
+    //この辺をProcessing用に組み替える
+    printf("place the weight and put any key\n");
+    char c = pc.getc();
+    
+    float natural = hx711.readGram();
+    float calibVal = natural / gram;
+    hx711.setScale(calibVal);
+    //printf("calibrated! %f %f %d\n", calibVal, natural, hx711.read());
+}
+
+
+int main() {
+    //ホイールモードにするための設定
+    motor.setAngleLimit(0, ADDRESS_CW_ANGLE_LIMIT);
+    motor.setAngleLimit(0, ADDRESS_CCW_ANGLE_LIMIT);
+    while(1) {
+    }
+}