OpenEtherCATsociety / SOEM

Simple Open Source EtherCAT Master
Other
1.36k stars 688 forks source link

Use three time for set output and get input #72

Closed starofsky closed 7 years ago

starofsky commented 7 years ago

Hi, I'm a beginner in EtherCAT. I used SOEM to test my slave. In slave code I put input = output. But I must use three time send and receive to get right input.

ec_send_processdata();
wkc = ec_receive_processdata(EC_TIMEOUTRET);

Do you have any idea?

nakarlsson commented 7 years ago

Get a wireshark log and you'll see, sounds like a slower cycle in the slave, One would expect 2 cycles if the slave cycle is at least as fast as the EtherCAT cycle. What type of slave is it?

  1. send output1, read inputs0, get the "old" input0
  2. send output1,read inputs1, now you would expect to se previous written output1 if the slave is fast enough to write it back.
waeltut commented 7 years ago

hi I m also having a problem with reading and writing some of the slaves. I m using the simple_test code. it writes and reads from some slaves but not all. do you have any idea?

nakarlsson commented 7 years ago

@waeltut I suggest you write your own issue, otherwise we'll hi-jack this and it will get mixed answers.

But for now.. Check the working counter, in OP it should be current working counter == expected working counter at all times. Otherwise you have slaves that for some reason have stepped down to SAFEOP. Then you need to find which one and read out its AlStatus and AlStatusCode

starofsky commented 7 years ago

Hi @nakarlsson thanks for your reply. My slave have type 2, i set output1 and read input1 but I need three time send and receive function to get expect value on input1 ( =output1 ).

starofsky commented 7 years ago

add more information, I sleep a time between cycles in master for sure my slave faster than master, but i also need three cycle to get right result.

mheden commented 7 years ago

@starofsky : Please provide a wireshark dump of your system.

starofsky commented 7 years ago

@mheden https://drive.google.com/open?id=0B1JrCW01p99sSk9tRWhQX1dRblU

mheden commented 7 years ago

@starofsky : thanks, could you also describe which data in the process image is being written/read (preferably with an output from slaveinfo with the -map option) as well as the expected behavior?

starofsky commented 7 years ago
  SM2 outputs
     addr b   index: sub bitl data_type    name
  [0x0035.0] 0x7030:0x01 0x10 UNSIGNED16   AO0
  SM3 inputs
     addr b   index: sub bitl data_type    name
  [0x008D.0] 0x6030:0x02 0x10 INTEGER16    AI0

I set AO0 and get AI0.

mheden commented 7 years ago

From your wireshark dump it looks like it takes the slave around 40ms to latch the analog inputs and provide it to the bus:

Excerpt:

354.   0.184371 01:01:01:01:01:01 [LWR:00000000]  DO: ['00', '00', '00', '00'] (       0) AO0: ['d7', '64'] (25815)  <-- set value
355.   0.185122 03:01:01:01:01:01 [LRD:00000055]  DI: ['00', '00', '00', '00'] (       0) AI0: ['15', '08'] ( 2069)
358.   0.202575 01:01:01:01:01:01 [LWR:00000000]  DO: ['00', '00', '00', '00'] (       0) AO0: ['d7', '64'] (25815)
359.   0.203299 03:01:01:01:01:01 [LRD:00000055]  DI: ['00', '00', '00', '00'] (       0) AI0: ['16', '08'] ( 2070)
362.   0.220647 01:01:01:01:01:01 [LWR:00000000]  DO: ['00', '00', '00', '00'] (       0) AO0: ['d7', '64'] (25815)
363.   0.221362 03:01:01:01:01:01 [LRD:00000055]  DI: ['00', '00', '00', '00'] (       0) AI0: ['88', '64'] (25736)  <-- slave responds

I would say that this does not have to do with SOEM but a property of the slave. What slave is it? Have you checked the specification?

starofsky commented 7 years ago

@mheden thank you for your help. I will test again on my slave.