sampleProgram

Dependencies:   QEI accelerator bit_test cyclic_io cyclic_var cylinder event_var limit mbed mecanum motor_drive pid pid_encoder rs422_put sbdbt servo

Fork of 17robo_fuzi by kusano kiyoshige

Revision:
13:dfae731e239f
Parent:
12:1fec80ae8a2c
Child:
14:aac2f18f6779
diff -r 1fec80ae8a2c -r dfae731e239f main.cpp
--- a/main.cpp	Sun Jul 16 08:35:45 2017 +0000
+++ b/main.cpp	Mon Jul 17 04:55:49 2017 +0000
@@ -10,7 +10,8 @@
 #include "limit.h"
 #include "accelerator.h"
 #include "encorder.h"
-#include "QEI.h"
+#include "cyclick.h"
+//#include "QEI.h"
 
 #define pc_baud     460800
 #define sbdbt_tx    p13
@@ -31,17 +32,15 @@
 #define acceleration    25
 #define pin_cylinder_on     p17
 #define pin_cylinder_off    p18
-#define interrupt_pin       p23
+#define pin_interrupt       p23
 #define encoder_A       p25
 #define encoder_B       p26
 #define enc_Kp      0.01
 #define enc_Ki      0.01
 #define enc_Kd      0.01
 
-DigitalOut led(LED1);
-DigitalOut sylinder_on(pin_cylinder_on);
-DigitalOut sylinder_off(pin_cylinder_off);
-DigitalIn interrupt(interrupt_pin);
+DigitalOut led1(LED1);
+DigitalIn interrupt(pin_interrupt);
 Serial pc(USBTX,USBRX);
 RS422 rs422(rs422_tx, rs422_rx);
 Sbdbt sbdbt(sbdbt_tx, sbdbt_rx);
@@ -53,10 +52,13 @@
 Accel v2;
 Accel v3;
 Accel v4;
+Cyclic_IO led2(LED2);
+Cyclic_IO sylinder_on(pin_cylinder_on);
+Cyclic_IO sylinder_off(pin_cylinder_off);
 
 //追加点
-//Encoder enc_cylinder(encoder_A,encoder_B);
-QEI wheel(encoder_A, encoder_B, NC, 624);
+Encoder enc_cylinder(encoder_A,encoder_B);
+//QEI wheel(encoder_A, encoder_B, NC, 624);
 
 void setup();
 void output();
@@ -70,8 +72,8 @@
 {
     setup();
     while(1) {
-        led = interrupt;
-        pc.printf("Pulses is: %i\r\n",wheel.getPulses());
+        led1 = interrupt;
+        //pc.printf("Pulses is: %i\r\n",wheel.getPulses());
     }
 }
 
@@ -91,11 +93,11 @@
     v2.setup(acceleration,output_period);
     v3.setup(acceleration,output_period);
     v4.setup(acceleration,output_period);
-    cylinder_origin();
+    //cylinder_origin();
 
 //追加点
-//    enc_cylinder.setup(1200);
-//    enc_cylinder.set_parameter(enc_Kp,enc_Ki,enc_Kd);
+    enc_cylinder.setup(1200);
+    enc_cylinder.set_parameter(enc_Kp,enc_Ki,enc_Kd);
 }
 
 void cylinder_origin(){
@@ -121,21 +123,17 @@
 
 void cylinder_check()
 {
-    if(sbdbt.up) {
-        sylinder_on = 1;
-    } else {
-        sylinder_on = 0;
+    //printf("up\t%d\tstate\t%d\tdown\t%d\tstate\t%d\t\r\n",sbdbt.up,sylinder_on.getState(),sbdbt.down,sylinder_off.getState());
+    /*
+    if(sylinder_on?){
+    sylinder_on.cyclic(sbdbt.up);
+    }else if(){
+    sylinder_off.cyclic(sbdbt.down); 
     }
-
-    if(sbdbt.down) {
-        sylinder_off = 1;
-    } else {
-        sylinder_off = 0;
-    }
+    led2.cyclic(sbdbt.left);
+    */
 }
 
-
-
 void put_output()
 {
     yaw = bno055.getYawRad();
@@ -154,7 +152,6 @@
     static int counter;
     int id[nucleo_num] = {n1_id, n2_id, n3_id};
 
-
     switch (counter) {
         case 0:
             rs422.put(id[counter], v1.duty(mecanum.v1()), v3.duty(mecanum.v3()));