[etherlab-users] ecrt_master_deactivate_slaves

Graeme Foot Graeme.Foot at touchcut.com
Mon Jan 13 22:28:11 CET 2014


Hi,

I go through a shutdown sequence while continuing my realtime loop with the ecrt_master_receive() and ecrt_master_send().

The guts of my main RT thread looks like:

  // main loop
  while (!g_app.shutdown)
  {
    // run scan logic
    sysMain_scanRT(&sysMainData);

    // polling hard sleep
    sysMain_waitPeriod();
  }

  // shutdown loop
  while (!sysMainData.allModulesStopped)
  {
    // run scan logic and shutdown logic
    sysMain_scanRT(&sysMainData);
    sysMain_stopRT(&sysMainData);

    // polling hard sleep
    sysMain_waitPeriod();
  }


So when I want to shut down the second loop is entered which adds the sysMain_stopRT() function call.

The sysMain_stopRT() function goes through all my modules telling them to stop.  Each module uses a state machine to shut itself down.  When all modules are stopped the allModulesStopped flag is set.

For my EtherCAT module it goes through the following states:
- Stop Devices: get all devices to stop what they are doing (eg axes come to a controlled stop and set themselves to disabled)
- Wait until all devices are stopped
- Call ecrt_master_deactivate_slaves()
- Wait for (masterState.al_states == 0x02)
- Stopped


So the guts of it is you need to maintain a realtime send/receive loop; call ecrt_master_deactivate_slaves() once; then wait for all the slaves to be set to PREOP before exiting the RT loop.


Hope this helps,

Graeme.


________________________________
From: Jun Yuan [mailto:j.yuan at rtleaders.com]
Sent: Monday, 13 January 2014 23:38
To: Graeme Foot
Subject: ecrt_master_deactivate_slaves

Hi Graeme,

in your fix http://lists.etherlab.org/pipermail/etherlab-users/2013/002162.html, there's a new function ecrt_master_deactivate_slaves() that would deactivate the DC slaves in time to avoid Sync watchdog error on the slave.
I would like to have this function in my application. My first trial is to put the function ecrt_master_deactivate_slaves() after my loop in the realtime thread. My realtime thread is like this:
while (running) {
    wait_period();
    ecrt_master_receive(master);
    ...
    sync_distributed_clocks();
    ecrt_master_send(master);
}
ecrt_master_deactivate_slaves(master);
The test failed as sync watchdog error comes out after the master is stopped by 'running = false'.

Now I realize that ecrt_master_send(master) must be called to sent the deactivate messages out to the slaves after the ecrt_master_deactivate_slaves() call. But I still don't have a clear idea about how to make things right.
How would you put this function ecrt_master_deactivate_slaves in your application?
Regards,
Jun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20140113/b45b0317/attachment-0002.htm>


More information about the Etherlab-users mailing list