I use the EL7041 often. He’s a quick copy/paste of how I make it move to position. The code snippet below writes to EtherLAB through a library I wrote, but the tasks required should be pretty obvious.
Thanks! ============ static int stateIdle(void* lp) { EL7041StepperInterface* p; EL7041_ENTER(p, lp); if (p->doMove) { p->doMove = false; if ( !lcxReadPdoBit(p->pdoOffset + IX_READY) ) { PRINT( "EL7041.%s not ready for motion. Cancelling.\n", __FUNCTION__ ); return StateMachineRunning; } lcxWritePdoUInt16(p->pdoOffset + QW_SETACCEL, p->targetAccel ); lcxWritePdoUInt16(p->pdoOffset + QW_SETDECEL, p->targetDecel ); lcxWritePdoUInt16(p->pdoOffset + QW_SETVELOCITY, p->targetVelocity ); p->fsm = &stateWaitWriteMotionParameters; return StateMachineTransition; } } static int stateWaitWriteMotionParameters(void* lp) { EL7041StepperInterface* p; EL7041_ENTER(p, lp); p->fsm = &stateWriteStartType; return StateMachineTransition; } static int stateWriteStartType(void* lp) { EL7041StepperInterface* p; EL7041_ENTER(p, lp); lcxWritePdoUInt32(p->pdoOffset + QW_SETTARGETPOSITION, p->setTargetPosition ); lcxWritePdoUInt32(p->pdoOffset + QW_SETSTARTTYPE, p->setStartType ); p->ton = TON_ENDTIME(100); p->fsm = &stateWaitWriteStartType; return StateMachineTransition; } static int stateWaitWriteStartType(void* lp) { EL7041StepperInterface* p; EL7041_ENTER(p, lp); if (TON_ISDONE(p->ton)) { /* * ALERT! * This command should start motion on the axis. */ lcxWritePdoBit(p->pdoOffset + QX_CONTROLEXECUTE, true); p->ton = TON_ENDTIME(500); p->fsm = &stateWaitExecute; return StateMachineTransition; } return StateMachineRunning; } Thomas C. Bitsky Jr. | Lead Developer ADC | automateddesign.com <http://automateddesign.com/> Follow ADC news and media: Facebook <https://facebook.com/automateddesigncorp> | Twitter <https://twitter.com/ADCSportsLogic> | YouTube <https://www.youtube.com/user/ADCSportsLogic> From: etherlab-users <etherlab-users-boun...@etherlab.org> on behalf of Paul Mulligan <mulligan...@yahoo.ie> Reply-To: Paul Mulligan <mulligan...@yahoo.ie> Date: Tuesday, January 19, 2016 at 7:49 AM To: "etherlab-users@etherlab.org" <etherlab-users@etherlab.org> Subject: [etherlab-users] Controlling motor drivers Hi, (Formatting was wrong on previous post) We bought various Beckoff modules for Digital in , Digital out, Analogue in and Stepper Motor control. I am able to communicate with with the digital I/O and analogue input slave modules from Ethercat master IGH 1.5.2 without problems, but the stepper motor controller (EL7031) is more complicated. Below is a list of the PDO entries for the motor controller retrieved from the Ethercat bus using the command line tool with the cstruct option. I am only able to set the velocity and then set the enable bit to start the motor running. I have no idea how to command the motor to just turn a certain amount of steps and change direction etc. I have tried to set a counter value but it doesn't make a difference. Also, if I set the bits to move positive or move negative, it doesn't change direction as I would expect. I can't seem to find any documentation or examples on how to control motors with this module EL7031. If anyone has any information or knowledge , I would really appreciate your help. Thanks ec_pdo_entry_info_t slave_6_pdo_entries[] = { {0x0000, 0x00, 1}, /* Gap */ {0x7000, 0x02, 1}, /* Enable latch extern on positive edge */ {0x7000, 0x03, 1}, /* Set counter */ {0x7000, 0x04, 1}, /* Enable latch extern on negative edge */ {0x0000, 0x00, 4}, /* Gap */ {0x0000, 0x00, 8}, /* Gap */ {0x7000, 0x11, 16}, /* Set counter value */ {0x7010, 0x01, 1}, /* Enable */ {0x7010, 0x02, 1}, /* Reset */ {0x7010, 0x03, 1}, /* Reduce torque */ {0x0000, 0x00, 5}, /* Gap */ {0x0000, 0x00, 8}, /* Gap */ {0x7010, 0x21, 16}, /* Velocity */ {0x0000, 0x00, 1}, /* Gap */ {0x6000, 0x02, 1}, /* Latch extern valid */ {0x6000, 0x03, 1}, /* Set counter done */ {0x6000, 0x04, 1}, /* Counter underflow */ {0x6000, 0x05, 1}, /* Counter overflow */ {0x0000, 0x00, 3}, /* Gap */ {0x0000, 0x00, 4}, /* Gap */ {0x6000, 0x0d, 1}, /* Status of extern latch */ {0x6000, 0x0e, 1}, /* Sync error */ {0x0000, 0x00, 1}, /* Gap */ {0x6000, 0x10, 1}, /* TxPDO Toggle */ {0x6000, 0x11, 16}, /* Counter value */ {0x6000, 0x12, 16}, /* Latch value */ {0x6010, 0x01, 1}, /* Ready to enable */ {0x6010, 0x02, 1}, /* Ready */ {0x6010, 0x03, 1}, /* Warning */ {0x6010, 0x04, 1}, /* Error */ {0x6010, 0x05, 1}, /* Moving positive */ {0x6010, 0x06, 1}, /* Moving negative */ {0x6010, 0x07, 1}, /* Torque reduced */ {0x0000, 0x00, 1}, /* Gap */ {0x0000, 0x00, 3}, /* Gap */ {0x6010, 0x0c, 1}, /* Digital input 1 */ {0x6010, 0x0d, 1}, /* Digital input 2 */ {0x6010, 0x0e, 1}, /* Sync error */ {0x0000, 0x00, 1}, /* Gap */ {0x6010, 0x10, 1}, /* TxPDO Toggle */ }; _______________________________________________ etherlab-users mailing list etherlab-users@etherlab.org http://lists.etherlab.org/mailman/listinfo/etherlab-users