CoDeSys v3 and EtherCat : library ETC_CO_SdoWrite

aurelien
2009-09-28
2009-10-14
  • aurelien - 2009-09-28

    Hi everybody,

    I'm tring to use Codesys v3 with a CoE device.

    And with the library ETC_CO_SdoWrite, I want to send some SDOs.

    The objects with size lower than 5 bytes work's perfectly but with the others (more than 4), I get an error. In fact, I don't know why, CoDeSys is supposed to send a segmented object, the first SDO is correct, he send an "initiate download protocol" and then after he should send a "segmented" one but he send again the same "initiate download protocol" .

    What I made wrong ?

    thank you in advance

    in the following, my function ETC_CO_SdoWrite and a capture of what is sent :

    IMG: Bild

     
  • Ralph Holz - 2009-09-29

    Hi Aurelien,

    thats just a guess but maybee it helps:

    Try the ETC_CO_SEGMENTED mode maybee this helps

    regards

    Ralph

     
  • aurelien - 2009-09-29

    thanks Ralf, with ETC_CO_SEGMENTED, still don't work

     
  • spfeif - 2009-10-10

    Another thing to make sure of at least from V2.3 days and since I can't see all your code. You should make sure that only one SDO is active at a time by monitoring the Done Busy outputs.

    case sdoState
    case 0:
    (* Wait for program *)
    execute := false;
    if initSDO then
    sdoState := sdoState + 1;
    end_if
    case 1:
    (* ask type *)
    index := 16#1000;
    subIndex :=0;
    data[0] := 0; 
    data[1] := 0; 
    data[2] := 0; 
    data[3] := 0;
    execute := true;
    case 2:
    (* set heartbeat to 100msec*)
    index := 16#1017;
    subIndex :=0;
    data[0] := 64; 
    data[1] := 0; 
    data[2] := 0; 
    data[3] := 0;
    execute := true;
    else
    sdoState := 0;
    end_Case
    ETC_CO_sdoWrite(Execute :=Β  execute );
    if ETC_CO_sdoWrite.Done then
    Β sdoState := sdoState +1;
    end_if
    if ETC_CO_sdoWrite.Error then
    sdoState := 0;
    end_if
    
     
  • aurelien - 2009-10-12

    Hi spfeif, in my program, there is only this FB TC_CO_sdoWrite, nothing else.

    The variable xDone, never change to TRUE. The FB is started by xExecute = TRUE then at the next PLC cycle, eError = TRUE;

    With a task cycle of 10ms, the first "sdo" is sent and the other one arround 4ms later.

    Is anybody who already used this function ?

    Thank you

     
  • spfeif - 2009-10-13

    With CANopen it is understandable because you get the response code back from the SDO write. If it failed the SDO fail code is included in the returned value. I missed this the first time. Do you have a list of the SDO abort codes?

    The code 05040001xh returned is:

    Zitat:
    Client/Server command specifier not valid or unknown

    What is the usiChannel? What device profile is the SDO targeting ds401? Also I noticed that the szSize = 6? I'm not sure what size is but it may be relating to the size of data in the SDO since you can have two types standard transferring 4 bytes or block download transferring as many as 889 bytes. Since the SDO is in the MFG index area my guess is it is suppose to be a 4 byte download in the form Index,SubIndex,Data. Try using 4 as the szSize.

     
  • aurelien - 2009-10-14

    Thank you for your help spfeif,

    I got the same abort code, which is correct because the 2nd sdo is not correct, it should be a segmented one

    Regarding to the codesys doc, UsiChannel is "Reserved for future extensions. Currently not used."

    The device profile is dsp402 (drive) and it doesn't support sdo block transfer. That's why as far I know, you must use SDO normal for data more than 4 bytes. With 4 bytes, it's work fine

    For example, actualy, with size = 9 bytes,

    Zitat:
    The PC send : 21 10 64 01 09 00 00 00
    device answer : 60 10 64 01 00 00 00 00
    The PC send : 21 10 64 01 09 00 00 00
    device answer : 80 10 64 01 01 00 04 05

    a correct sequence could be this :

    Zitat:
    The PC send : 21 10 64 01 09 00 00 00
    device answer : 60 10 64 01 00 00 00 00
    The PC send : 00 xx xx xx xx xx xx xx
    device answer : 20 00 00 00 00 00 00 00
    The PC send : 1B xx xx 00 00 00 00 00
    device answer : 30 00 00 00 00 00 00 00

    and everyone will be happy !

    Is someone can tell me if I su*k and normaly it's working ?

    Thanks

    (I'm using codesys v3.3 patch 1)

     

Log in to post a comment.