OpenEtherCATsociety / SOEM

Simple Open Source EtherCAT Master
Other
1.23k stars 653 forks source link

LAN9252 slave cannot go OP under DC sync #824

Open jingjm opened 2 weeks ago

jingjm commented 2 weeks ago

Hello everyone!

I have read following issues carefully, but maybe I still missed sth. https://github.com/OpenEtherCATsociety/SOEM/issues/520 https://github.com/OpenEtherCATsociety/SOEM/issues/487

My slave is using LAN9252 (on a self made dev board), it can go SM-sync without any problem. But when I tried to use DC-sync, it only stay on SAFE_OP, can not goto OP state. My question is whether my understanding of master side process is right (see code below) or I should check the slave side?

I was trying strategy b) (described in issue 520) as a) seems not work for LAN9252. b) Do slave configuration and synchronisation both in pre-OP and work around some details.

My code flow as below (modified based on red_test.c): image

The output just show as below.

Slave:1
 Name:SSC-Device
 Output size: 752bits
 Input size: 2bits
 State: 4
 Delay: 0[ns]
 Has DC: 1  DCactive: 1
 DCParentport:0
...
Not all slaves reached operational state.
Slave 1 State=0x04 StatusCode=0x0000 : No error

I print out the 0x1c32 and 0x1c33, the "Synchronization Type" seems right for DC sync.

0x1c32      "SM output parameter"                         [RECORD  maxsub(0x20 / 32)]
    0x00      "SubIndex 000"                                [UNSIGNED8        R_R_R_]      0x20 / 32
    0x01      "Synchronization Type"                        [UNSIGNED16       RWR_R_]      0x0002 / 2
    0x02      "Cycle Time"                                  [UNSIGNED32       R_R_R_]      0x000f4240 / 1000000
    0x04      "Synchronization Types supported"             [UNSIGNED16       R_R_R_]      0x401f / 16415
    0x05      "Minimum Cycle Time"                          [UNSIGNED32       R_R_R_]      0x0007a120 / 500000
    0x06      "Calc and Copy Time"                          [UNSIGNED32       R_R_R_]      0x00000000 / 0
    0x08      "Get Cycle Time"                              [UNSIGNED16       RWRWRW]      0x0000 / 0
    0x09      "Delay Time"                                  [UNSIGNED32       R_R_R_]      0x00000000 / 0
    0x0a      "Sync0 Cycle Time"                            [UNSIGNED32       RWRWRW]      0x000f4240 / 1000000
    0x0b      "SM-Event Missed"                             [UNSIGNED16       R_R_R_]      0x0006 / 6
    0x0c      "Cycle Time Too Small"                        [UNSIGNED16       R_R_R_]      0x0000 / 0
    0x20      "Sync Error"                                  [BOOLEAN          R_R_R_]      TRUE

0x1c33      "SM input parameter"                          [RECORD  maxsub(0x20 / 32)]
    0x00      "SubIndex 000"                                [UNSIGNED8        R_R_R_]      0x20 / 32
    0x01      "Synchronization Type"                        [UNSIGNED16       RWR_R_]      0x0002 / 2
    0x02      "Cycle Time"                                  [UNSIGNED32       R_R_R_]      0x000f4240 / 1000000
    0x04      "Synchronization Types supported"             [UNSIGNED16       R_R_R_]      0x401f / 16415
    0x05      "Minimum Cycle Time"                          [UNSIGNED32       R_R_R_]      0x0007a120 / 500000
    0x06      "Calc and Copy Time"                          [UNSIGNED32       R_R_R_]      0x00000000 / 0
    0x08      "Get Cycle Time"                              [UNSIGNED16       RWRWRW]      0x0000 / 0
    0x09      "Delay Time"                                  [UNSIGNED32       R_R_R_]      0x00000000 / 0
    0x0a      "Sync0 Cycle Time"                            [UNSIGNED32       RWRWRW]      0x000f4240 / 1000000
    0x0b      "SM-Event Missed"                             [UNSIGNED16       R_R_R_]      0x0000 / 0
    0x0c      "Cycle Time Too Small"                        [UNSIGNED16       R_R_R_]      0x0000 / 0
    0x20      "Sync Error"                                  [BOOLEAN          R_R_R_]      FALSE
nakarlsson commented 2 weeks ago

A Wireshark of the start-up might help.

And if you wait a while longer the slave will probably present some SAFEOP + Error that might guide you, since it is a SSC Device you can seelk help in that documentation?

ArthurKetels commented 2 weeks ago

And it helps when you actually enable sync0. Now the slave is waiting for the first sync pulse that never comes.

jingjm commented 2 weeks ago

Thank for reply. After I wait longer, it really goes to SAFE_OP + Error state.