yei
Dependencies: interface mbed enc_1multi calPID motorout KondoServoLibrary
Fork of cat18_operate by
Diff: interrupt/interrupt.cpp
- Revision:
- 20:13934809e117
- Parent:
- 19:48c3af917932
- Child:
- 23:f45eb02433a5
--- a/interrupt/interrupt.cpp Fri Aug 17 08:47:23 2018 +0000 +++ b/interrupt/interrupt.cpp Mon Aug 27 03:47:21 2018 +0000 @@ -1,61 +1,61 @@ #include "interrupt.h" #include "mbed.h" +#include "debug.h" #include "go.h" #include "check.h" #include "coordinate.h" #include "pinnames.h" #include "cat18_can_info.h" -#include "debug.h" -#include "workposition.h" -#define RIGHT//右用ならRIGHT,左用ならLEFT - +#include "workinfo.h" +#include "define_right_or_left.h" +#include "calplace.h" +//#define CAN_ON //CAN通信するならdefine Ticker ticker; CAN can(pin_can_rd,pin_can_td); int counterpart_is_in_common; char can_pub_data[kCanlength_rightleft]; - +//tickerタイミング計算関係 const double kTicker_s = 0.001; const int kCanCount = kCanTicker_s / kTicker_s; const int kPIDCount = kPIDTicker_s / kTicker_s; -const int kServoCalCount = kServoCalTicker_s / kTicker_s; -const int kServoMoveCount = kServoMoveTicker_s / kTicker_s; -const int kCountReset=kPIDCount*kServoCalCount*kCanCount*kServoMoveCount; +const int kCalTargetCount = kCalTargetTicker_s / kTicker_s; +const int kCountReset=kPIDCount*kCalTargetCount*kCanCount; +//tickerで呼び出す void TimerInterrupt(); +//CAN通信 void CanRead(); void CanSend(); void InterruptSetup() { + DEBUG("InterruptSetup() start\r\n"); can.frequency(kCanFrequency); ticker.attach(TimerInterrupt,kTicker_s); + DEBUG("InterruptSetup() finish\r\n"); } void TimerInterrupt() { static int count = 0; if(count % kPIDCount == 0) PIDInterrupt(); - if(count % kServoCalCount==0){ - ServoCalInterrupt(); + if(count % kCalTargetCount==0) { + CalTargetInterrupt(); } - //if(count % kServoMoveCount==0){ - // ServoMoveInterrupt(); - //} - /* - if(count % kCanCount==0){ +#ifdef CAN_ON + if(count % kCanCount==0) { CanRead(); CanSend(); } - */ +#endif if(count == kCountReset) count=0; count++; } int GetCounterpartIsInCommon() { - if(shootingbox[9].is_exist == 0) counterpart_is_in_common = 1; - else counterpart_is_in_common = 0; + //一つもワークを置いていなければ入っていはいけない=1 + if(shootingbox[kFirstPutPlace].is_exist == 0) return 1; return counterpart_is_in_common; } - void CanRead() { CANMessage msg; @@ -70,7 +70,6 @@ #endif counterpart_is_in_common = msg.data[0]; break; - } } void CanSend()