const Error *Amp::RequestStatUpdt( void ) { // For secondary axis objects, do this through the primary axis if( primaryAmpRef ) { RefObjLocker<Amp> pri( primaryAmpRef ); if( !pri ) return &AmpError::NotInit; return pri->RequestStatUpdt(); } // Note that 8367 based products don't support remote // requests well, so we use an SDO to request the PDO if( (hwType & 0xFF00) != 0x0300 ) { RefObjLocker<Network> net( GetNetworkRef() ); if( !net ) return &NodeError::NetworkUnavailable; if( !statPDO ) return &AmpError::NotInit; return statPDO->Request(*net); } else return Dnld8( OBJID_PDOREQUEST, 0, (uint8)0 ); }
/* description: Initialize the motor,the motor can work in three diffrient mode posiotion,velocity,torque.this one is initialed to torque,modify the code if needed // function: void motor_init(void) // @param: //return value: */ void motor_init(void) { static char message[32]; uint8 err; sprintf(message, "velocity started:\r\n"); UART0_SendStr (message); //get initial position step:0 uint32 pos; err=GetPosition(&pos); if(err){showerr(err,0);} else{ sprintf(message, "initial pos: %4d\r\n",pos); UART0_SendStr (message); } // set homing mode step:1 err=SetHomeMode(1); if(err){showerr(err,1);} // set homing method step:2 // here the mean of homing is that // to use the current position as homing position err=Dnld8(OBJID_HOME_METHOD, 0, (uint8)35,2); if(err){showerr(err,2);} // shutdown step:3 err=Dnld16(OBJID_CONTROL, 0, (uint16)0x06,3); if(err){showerr(err,3);} //wait at least 3ms to avoid the Priority inversion sysDelayNS(3); // switch on step:4 err=Dnld16(OBJID_CONTROL, 0, (uint16)0x07,4); if(err){showerr(err,4);} // enable operation step:5 err=Dnld16(OBJID_CONTROL, 0, (uint16)0x0f,5); if(err){showerr(err,5);} // start home mode step:6 err=Dnld16(OBJID_CONTROL, 0, (uint16)0x1f,6); if(err){showerr(err,6);} // home mode active step:7 err=Dnld16(OBJID_CONTROL, 0, (uint16)0x1f,7); if(err){showerr(err,7);} sysDelayNS(10); //get current position step:8 err=GetPosition(&pos); if(err){showerr(err,8);} else{ sprintf(message, "current pos: %4d\r\n",pos); UART0_SendStr (message); } //=================================== // set position mode step:9 err=SetPositionMode(1); if(err){showerr(err,9);} // shutdown step:10 err=Dnld16(OBJID_CONTROL, 0, (uint16)0x06,2); if(err){showerr(err,10);} // switch on step:11 err=Dnld16(OBJID_CONTROL, 0, (uint16)0x07,3); if(err){showerr(err,11);} //wait at least 3ms to avoid the Priority inversion sysDelayNS(3); // enable operation step:12 err=Dnld16(OBJID_CONTROL, 0, (uint16)0x0f,4); if(err){showerr(err,12);} // while(1){;} //just for debug }