[etherlab-users] writing sdo inside real time loop

paluan.luca at tiscali.it paluan.luca at tiscali.it
Mon Apr 22 16:00:37 CEST 2013


Hello everybody,
is there a definite way to read or write sdo inside 
real time loop?
I've checked the examples and made my own functions to 
do it, but after some time I get a SDO timeout upload or download error 
from ethercat master.

For example: EtherCAT ERROR 0-2: Timeout after 
1000 ms while> waiting for SDO 0x6060:0 upload response.

I'm wondering 
whether there is any chance to do it cleanly and how to recover from 
such an error.

I create the sdo objects I need at the beginning of the 
application using ecrt_slave_config_create_sdo_request(...) calls.
My 
functions to write sdo are write_sdo to write and sdo and 
write_sdo_success to check it is correctly written.
If 
write_sdo_success  doesn't return success state i go back to write_sdo 
again



bool SdoTask::write_sdo(Slave::sdo_config sdo_map,int32_t 
data)
{
    bool bRetVal = false;
    int8_t cData;
    uint8_t ucData;

    int16_t wData;
    uint16_t uwData;
    uint32_t udwData;

    
switch(ecrt_sdo_request_state(sdo_map.pSdo))
    {
    case 
EC_REQUEST_UNUSED:
    case EC_REQUEST_SUCCESS:
        switch(sdo_map.
size)
        {
        case 8:
            if (sdo_map.bSigned)

            {
                cData = (int8_t) data;
                
EC_WRITE_S8(ecrt_sdo_request_data(sdo_map.pSdo), cData);
            }

            else
            {
                ucData = (uint8_t) data;

                EC_WRITE_U8(ecrt_sdo_request_data(sdo_map.pSdo), 
ucData);
            }
            break;
        case 16:
            
if (sdo_map.bSigned)
            {
                wData = (int16_t) 
data;
                EC_WRITE_S16(ecrt_sdo_request_data(sdo_map.pSdo), 
wData);
            }
            else
            {
                
uwData = (uint16_t) data;
                EC_WRITE_U16
(ecrt_sdo_request_data(sdo_map.pSdo), uwData);
            }

            break;
        case 32:
            if (sdo_map.bSigned)

                EC_WRITE_S32(ecrt_sdo_request_data(sdo_map.pSdo), 
data);
            else
            {
                udwData = 
(uint32_t) data;
                EC_WRITE_U32(ecrt_sdo_request_data
(sdo_map.pSdo), udwData);
            }
            break;
        }

        bRetVal = true;
        break;
    case EC_REQUEST_ERROR:
    
case EC_REQUEST_BUSY:
        break;
    }

    if (bRetVal)
        
ecrt_sdo_request_write(sdo_map.pSdo);

    return bRetVal;

}

bool 
SdoTask::write_sdo_success(Slave::sdo_config sdo_map)
{
    bool 
bRetVal = false;

    switch(ecrt_sdo_request_state(sdo_map.pSdo))
    
{
    case EC_REQUEST_UNUSED:
    case EC_REQUEST_ERROR:
    case 
EC_REQUEST_BUSY:
        break;
    case EC_REQUEST_SUCCESS:
        
bRetVal = true;
        break;
    }

    return bRetVal;
}




Thanks 
in advance for your attention, every advice is well accepted.
Best 
Regards Luca Paluan


Invita i tuoi amici e Tiscali ti premia! Il consiglio di un amico vale più di uno spot in TV. Per ogni nuovo abbonato 30 € di premio per te e per lui! Un amico al mese e parli e navighi sempre gratis: http://freelosophy.tiscali.it/



More information about the Etherlab-users mailing list