123

Dependencies:   mbed-dev_spine

Files at this revision

API Documentation at this revision

Comitter:
shaorui
Date:
Wed Feb 19 05:22:32 2020 +0000
Parent:
8:95a914f962bd
Commit message:
1

Changed in this revision

DATA_COMMAND/data_command.cpp 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
diff -r 95a914f962bd -r bf02fd2d7a0a DATA_COMMAND/data_command.cpp
--- a/DATA_COMMAND/data_command.cpp	Tue Jan 07 09:23:24 2020 +0000
+++ b/DATA_COMMAND/data_command.cpp	Wed Feb 19 05:22:32 2020 +0000
@@ -46,7 +46,7 @@
         else
         {
             duoji_command=0;
-            }
+        }
         
         if(state==REST_MODE)
             {
@@ -69,7 +69,15 @@
              }
        if((state==MOTOR_MODE)&&(data[0]!='m'))
         { 
-           a_control.ef.p_des=int(c);//*2*PI/360;
+           //a_control.ef.p_des=int(c);//*2*PI/360;
+           a_control.ef.p_des=int(data[0])*2*PI/360;
+            send_enable = 1;
+            printf("f: %.3f\n\r", a_control.ef.p_des);
+            }
+            
+       if((state==MOTOR_MODE)&&(data[2]!='m'))
+        { 
+           a_control.wf.p_des=int(data[2])*2*PI/360;
             send_enable = 1;
             printf("f: %.3f\n\r", a_control.ef.p_des);
             }
diff -r 95a914f962bd -r bf02fd2d7a0a main.cpp
--- a/main.cpp	Tue Jan 07 09:23:24 2020 +0000
+++ b/main.cpp	Wed Feb 19 05:22:32 2020 +0000
@@ -13,7 +13,6 @@
 int main()
 {
    
-    
     pc.baud(115200);
     shouzhua.baud(9600); 
     command.baud(115200);
@@ -48,8 +47,15 @@
          //获取AD
         ad1 = AD1.read() * 3300;
         ad2 = AD2.read() * 3300;
+        /********************AD 通讯协议***********************/
+        //将ad的值用八位表示
+        //7位-0表示ad1,1表示ad2
+        //6-0位表示ad值
+        ad1=ad1/26;       //将ad1值限制在0-6bit,7bit set to be 0
+        ad2=ad2/26+128;   //将ad2值限制在0-6bit,7 bit set to be 1
         command.putc(ad1);
         command.putc(ad2);
+        /********************AD 通讯协议***********************/
         //////////////////////// CAN获取电机位置速度信息 //////////////////////////
         ef_can.read(ef_rxMsg);                                                                            
         unpack_reply(ef_rxMsg, &a_state);