45

Dependencies:   mbed BufferedSerial LS7366LIB FastPWM

Committer:
lsh2205
Date:
Mon Mar 23 08:38:40 2020 +0000
Revision:
0:c21936a3520a
ss

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lsh2205 0:c21936a3520a 1 #include "mbed.h"
lsh2205 0:c21936a3520a 2 #include "main.h"
lsh2205 0:c21936a3520a 3
lsh2205 0:c21936a3520a 4 //DigitalOut myled(LED1);
lsh2205 0:c21936a3520a 5
lsh2205 0:c21936a3520a 6
lsh2205 0:c21936a3520a 7 int main()
lsh2205 0:c21936a3520a 8 {
lsh2205 0:c21936a3520a 9
lsh2205 0:c21936a3520a 10 board_init();
lsh2205 0:c21936a3520a 11
lsh2205 0:c21936a3520a 12 //encoder_check();
lsh2205 0:c21936a3520a 13 find_limit();
lsh2205 0:c21936a3520a 14
lsh2205 0:c21936a3520a 15 //pc.printf("Work~\n");
lsh2205 0:c21936a3520a 16
lsh2205 0:c21936a3520a 17 timer_init();
lsh2205 0:c21936a3520a 18 while(1)
lsh2205 0:c21936a3520a 19 {
lsh2205 0:c21936a3520a 20
lsh2205 0:c21936a3520a 21
lsh2205 0:c21936a3520a 22 bool_cnt++;
lsh2205 0:c21936a3520a 23 if(bool_cnt>10000)
lsh2205 0:c21936a3520a 24 bool_cnt=10000;
lsh2205 0:c21936a3520a 25 /*
lsh2205 0:c21936a3520a 26 pc.printf("%5.3f,",first_degree);
lsh2205 0:c21936a3520a 27 pc.printf("%5.3f,",second_degree);
lsh2205 0:c21936a3520a 28 pc.printf("%5.3f,",third_degree);
lsh2205 0:c21936a3520a 29 pc.printf("%5.3f,",four_degree);
lsh2205 0:c21936a3520a 30 pc.printf("%5.3f,",five_degree);
lsh2205 0:c21936a3520a 31 pc.printf("%5.3f,",six_degree);
lsh2205 0:c21936a3520a 32 pc.printf("\n");
lsh2205 0:c21936a3520a 33 */
lsh2205 0:c21936a3520a 34
lsh2205 0:c21936a3520a 35
lsh2205 0:c21936a3520a 36 //loop_time_run();
lsh2205 0:c21936a3520a 37 //wait_us(2000);
lsh2205 0:c21936a3520a 38
lsh2205 0:c21936a3520a 39 //Read_DATA();
lsh2205 0:c21936a3520a 40
lsh2205 0:c21936a3520a 41 comunication(); // 모터의 위치 값을 받음
lsh2205 0:c21936a3520a 42
lsh2205 0:c21936a3520a 43 // not_play_check();
lsh2205 0:c21936a3520a 44
lsh2205 0:c21936a3520a 45 if(bool_cnt<2500)
lsh2205 0:c21936a3520a 46 {
lsh2205 0:c21936a3520a 47 cmd_roll = 32768;
lsh2205 0:c21936a3520a 48 cmd_pitch = 32768;
lsh2205 0:c21936a3520a 49 cmd_heave = 32768;
lsh2205 0:c21936a3520a 50 cmd_sway = 32768;
lsh2205 0:c21936a3520a 51 cmd_surge = 32768;
lsh2205 0:c21936a3520a 52 cmd_yaw = 32768;
lsh2205 0:c21936a3520a 53 }
lsh2205 0:c21936a3520a 54
lsh2205 0:c21936a3520a 55 taget_position_cal((double)cmd_roll,(double)cmd_pitch,(double)cmd_heave,(double)cmd_sway,(double)cmd_surge,(double)cmd_yaw);
lsh2205 0:c21936a3520a 56
lsh2205 0:c21936a3520a 57 //pc.printf("%s",command);
lsh2205 0:c21936a3520a 58
lsh2205 0:c21936a3520a 59 /*
lsh2205 0:c21936a3520a 60 pc.printf("%d,",cmd_roll);
lsh2205 0:c21936a3520a 61 pc.printf("%d,",cmd_pitch);
lsh2205 0:c21936a3520a 62 pc.printf("%d,",cmd_heave);
lsh2205 0:c21936a3520a 63 pc.printf("%d,",cmd_sway);
lsh2205 0:c21936a3520a 64 pc.printf("%d,",cmd_surge);
lsh2205 0:c21936a3520a 65 pc.printf("%d,",cmd_yaw);
lsh2205 0:c21936a3520a 66 pc.printf("\n");
lsh2205 0:c21936a3520a 67 */
lsh2205 0:c21936a3520a 68
lsh2205 0:c21936a3520a 69
lsh2205 0:c21936a3520a 70 encoder_read();
lsh2205 0:c21936a3520a 71
lsh2205 0:c21936a3520a 72 Position_PID();
lsh2205 0:c21936a3520a 73
lsh2205 0:c21936a3520a 74 Speed_PID();
lsh2205 0:c21936a3520a 75
lsh2205 0:c21936a3520a 76 for(int i=0;i<6;i++)
lsh2205 0:c21936a3520a 77 motor_power(i,Speed_PID_OUTPUT[i]);
lsh2205 0:c21936a3520a 78 //tor_power(i,200);
lsh2205 0:c21936a3520a 79
lsh2205 0:c21936a3520a 80
lsh2205 0:c21936a3520a 81 }
lsh2205 0:c21936a3520a 82 }
lsh2205 0:c21936a3520a 83
lsh2205 0:c21936a3520a 84