cembeddedcan-buscanopen

CANOPEN SYNC timeout after enable Operation


I am a newbie in CANOPEN. I wrote a program that read actual position via PDO1 (default is statusword + actual position).

void canopen_init() {
// code1 setup PDO mapping
nmtPreOperation();
disablePDO(PDO_TX1_CONFIG_COMM);
setTransmissionTypePDO(PDO_TX1_CONFIG_COMM, 1);
setInhibitTimePDO(PDO_TX1_CONFIG_COMM, 0);
setEventTimePDO(PDO_TX1_CONFIG_COMM, 0);
enablePDO(PDO_TX1_CONFIG_COMM);

setCyclePeriod(1000);
setSyncWindow(100);

//code 2: enable OPeration
readyToSwitchOn();
switchOn();
enableOperation();    
motionStart();

// code 3
nmtActiveNode();
}


int main (void) {
  canopen_init();   
  while {
    delay_ms(1);
    send_sync();
  }
} 

If I remove "code 2" (the servo is in Switch_on_disable status), i can read position each time sync send. But if i use "code 2", the driver has error "sync frame timeout". I dont know driver has problem or my code has problem. Does my code has problem? thank you!


Solution

  • Problem fixed. Due to much EMI from servo, that make my controller didn't work properly. After isolating, it worked very well :)!