Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple example #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

flosse
Copy link
Contributor

@flosse flosse commented Mar 4, 2020

@birkenfeld I try to make a simple example working but it doesn't work :(

Could you have look at this example?
Do I miss something?

The aim is simple: Toggle output 3

Bildschirmfoto_2020-03-04_20-40-09

@flosse flosse requested a review from birkenfeld March 4, 2020 19:43
@birkenfeld
Copy link
Member

I'm sorry, didn't see this before now. Will review during the weekend...

@birkenfeld
Copy link
Member

The al_states: 2 looks suspicious. When the slaves are working normally, they should be in state 8 (OP) instead of 2 (PREOP). This field is an OR of the state flags, so it seems like all slaves are in PREOP.

It may be that this is because the configured slaves don't match the actual slaves, but you have the check that I though was the right one (leading to the "Unable to configure slave" panic).

It might also be possible that the Weidmüller hardware wants to be put into the OP state explicitly, while Beckhoff does it automatically while activating the master? (I think; I don't have a coupler with me to test ATM. I can do some tests tomorrow.)

I assume you know about the ethercat executable provided by the IgH master? You can access a lot of functionality there, including ioctls that are not wrapped by the original C library (and therefore not in Rust, at the moment). One of those is EC_IOCTL_SLAVE_STATE which is used by the ethercat states FOO command. Maybe you can try that?

master.domain(domain_handle).queue()?;
master.send()?;

thread::sleep(Duration::from_millis(500));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I adapted the PDOs and IDs to my Beckhoff EK1100 test system. I first thought this didn't work either, but then let it run for longer once and saw that the al_states did go to OP at some point.

For that system, it needs about 35 communication cycles to do this here; if you lower the sleep you'll get to state 8 sooner. I don't know where the delay comes from :(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to reduce the cycle time but no matter how long I'm waiting, it stays at al_states: 2 :(

@flosse
Copy link
Contributor Author

flosse commented Apr 16, 2020

It may be that this is because the configured slaves don't match the actual slaves,

Ok, I'll check the whole config again.
Is there a simple way to receive some debug/error info?

I assume you know about the ethercat executable provided by the IgH master? You can access a lot of functionality there, including ioctls that are not wrapped by the original C library (and therefore not in Rust, at the moment). One of those is EC_IOCTL_SLAVE_STATE which is used by the ethercat states FOO command. Maybe you can try that?

Yes I tried it. Running ethercat states PO does not help :-\

@birkenfeld
Copy link
Member

Can you post the result of ethercat pdos, ethercat slaves -v and ethercat config -v while the example is running?

@flosse
Copy link
Contributor Author

flosse commented Apr 17, 2020

sudo /opt/etherlab/bin/ethercat pdos
SM0: PhysAddr 0x1000, DefaultSize  512, ControlRegister 0x26, Enable 1
SM1: PhysAddr 0x1400, DefaultSize  512, ControlRegister 0x22, Enable 1
SM2: PhysAddr 0x1800, DefaultSize    0, ControlRegister 0x64, Enable 0
  RxPDO 0x16ff ""
    PDO entry 0xf200:01,  1 bit, ""
    PDO entry 0xf200:02,  1 bit, ""
    PDO entry 0xf200:03,  1 bit, ""
    PDO entry 0xf200:04,  1 bit, ""
    PDO entry 0xf200:05,  1 bit, ""
    PDO entry 0xf200:06,  1 bit, ""
    PDO entry 0xf200:07,  1 bit, ""
    PDO entry 0xf200:08,  1 bit, ""
    PDO entry 0xf200:09,  1 bit, ""
    PDO entry 0xf200:0a,  1 bit, ""
    PDO entry 0xf200:0b,  1 bit, ""
    PDO entry 0xf200:0c,  1 bit, ""
    PDO entry 0xf200:0d,  1 bit, ""
    PDO entry 0xf200:0e,  1 bit, ""
    PDO entry 0xf200:0f,  1 bit, ""
    PDO entry 0xf200:10,  1 bit, ""
  RxPDO 0x1600 ""
    PDO entry 0x7000:01,  1 bit, ""
    PDO entry 0x7000:02,  1 bit, ""
    PDO entry 0x7000:03,  1 bit, ""
    PDO entry 0x7000:04,  1 bit, ""
    PDO entry 0x0000:00,  4 bit, "Gap"
  RxPDO 0x1601 ""
    PDO entry 0x7010:01,  1 bit, ""
    PDO entry 0x7010:02,  1 bit, ""
    PDO entry 0x7010:03,  1 bit, ""
    PDO entry 0x7010:04,  1 bit, ""
    PDO entry 0x7010:05,  1 bit, ""
    PDO entry 0x7010:06,  1 bit, ""
    PDO entry 0x7010:07,  1 bit, ""
    PDO entry 0x7010:08,  1 bit, ""
    PDO entry 0x7010:09,  1 bit, ""
    PDO entry 0x7010:0a,  1 bit, ""
    PDO entry 0x7010:0b,  1 bit, ""
    PDO entry 0x7010:0c,  1 bit, ""
    PDO entry 0x7010:0d,  1 bit, ""
    PDO entry 0x7010:0e,  1 bit, ""
    PDO entry 0x7010:0f,  1 bit, ""
    PDO entry 0x7010:10,  1 bit, ""
SM3: PhysAddr 0x2400, DefaultSize    0, ControlRegister 0x20, Enable 0
  TxPDO 0x1aff ""
    PDO entry 0xf100:01,  1 bit, ""
    PDO entry 0xf100:02,  1 bit, ""
    PDO entry 0xf100:03,  1 bit, ""
    PDO entry 0xf100:04,  1 bit, ""
    PDO entry 0xf100:05,  1 bit, ""
    PDO entry 0xf100:06,  1 bit, ""
    PDO entry 0xf100:07,  1 bit, ""
    PDO entry 0xf100:08,  1 bit, ""
    PDO entry 0xf100:09,  1 bit, ""
    PDO entry 0xf100:0a,  1 bit, ""
    PDO entry 0xf100:0b,  1 bit, ""
    PDO entry 0xf100:0c,  1 bit, ""
    PDO entry 0xf100:0d,  1 bit, ""
    PDO entry 0xf100:0e,  1 bit, ""
    PDO entry 0xf100:0f,  1 bit, ""
    PDO entry 0xf100:10,  1 bit, ""
  TxPDO 0x1a00 ""
    PDO entry 0x6000:01,  8 bit, ""
  TxPDO 0x1a01 ""
    PDO entry 0x6010:01,  8 bit, ""
sudo /opt/etherlab/bin/ethercat slaves -v
=== Master 0, Slave 0 ===
Device: Main
State: PREOP
Flag: E
Identity:
  Vendor Id:       0x00000230
  Product code:    0x4f911c30
  Revision number: 0x00011100
  Serial number:   0x5021d6b0
DL information:
  FMMU bit operation: no
  Distributed clocks: yes, 64 bit
  DC system time transmission delay: 0 ns
Port  Type  Link  Loop    Signal  NextSlave  RxTime [ns]  Diff [ns]   NextDc [ns]
   0  MII   up    open    yes             -   1845499234           0           0
   1  MII   down  closed  no              -            -           -           -
   2  N/A   down  closed  no              -            -           -           -
   3  N/A   down  closed  no              -            -           -           -
Mailboxes:
  Bootstrap RX: 0x1200/532, TX: 0x1500/532
  Standard  RX: 0x1000/512, TX: 0x1400/512
  Supported protocols: EoE, CoE, FoE
General:
  Group: Coupler
  Image name: 
  Order number: UR20-FBC-EC
  Device name: UR20-FBC-EC / 1334910000
  CoE details:
    Enable SDO: yes
    Enable SDO Info: yes
    Enable PDO Assign: no
    Enable PDO Configuration: yes
    Enable Upload at startup: no
    Enable SDO complete access: yes
  Flags:
    Enable SafeOp: no
    Enable notLRW: no
  Current consumption: 0 mA
sudo /opt/etherlab/bin/ethercat config -v
Alias: 0
Position: 0
Vendor Id: 0x00000230
Product code: 0x4f911c30
Attached slave: 0 (PREOP)
Watchdog divider: (Default)
Watchdog intervals: (Default)
SM2, Dir: Output, Watchdog: Default
  PDO 0x1600
    PDO entry 0x7000:01,  1 bit
    PDO entry 0x7000:04,  1 bit
SM3, Dir: Input, Watchdog: Default
  PDO 0x1a00
    PDO entry 0x6000:01,  8 bit
SDO configuration:
  None.
IDN configuration:
  None.

@birkenfeld
Copy link
Member

Well, I'm a bit at a loss. You might also look in the dmesg for errors/warnings, maybe after calling ethercat debug 1?

Googling suggests that you may need to configure the DC feature before activating the master (calling config_dc on the SlaveConfig. I didn't need this for the Beckhoff coupler.

@flosse
Copy link
Contributor Author

flosse commented Apr 17, 2020

Well, I'm a bit at a loss. You might also look in the dmesg for errors/warnings, maybe after calling ethercat debug 1?

That's actually a good idea!

There are some errors and warnings, e.g.:

[Fr Apr 17 13:06:15 2020] EtherCAT ERROR 0-0: SDO download 0x1600:00 (1 bytes) aborted.
[Fr Apr 17 13:06:15 2020] EtherCAT ERROR 0-0: SDO abort message 0x06010002: "Attempt to write a read-only object".
[Fr Apr 17 13:06:15 2020] EtherCAT WARNING 0-0: Failed to clear PDO mapping.
[Fr Apr 17 13:06:15 2020] EtherCAT WARNING 0-0: Failed to configure mapping of PDO 0x1600.
[Fr Apr 17 13:06:15 2020] EtherCAT WARNING 0-0: Slave does not support assigning PDOs!
[Fr Apr 17 13:06:15 2020] EtherCAT ERROR 0-0: SDO download 0x1A00:00 (1 bytes) aborted.
[Fr Apr 17 13:06:15 2020] EtherCAT ERROR 0-0: SDO abort message 0x06010002: "Attempt to write a read-only object".
[Fr Apr 17 13:06:15 2020] EtherCAT WARNING 0-0: Failed to clear PDO mapping.
[Fr Apr 17 13:06:15 2020] EtherCAT ERROR 0-0: Failed to set SAFEOP state, slave refused state change (PREOP + ERROR).
[Fr Apr 17 13:06:15 2020] EtherCAT ERROR 0-0: AL status message 0x001E: "Invalid input configuration".

So it seems that I can't define my own custom mapping (Slave does not support assigning PDOs!).
So what else can I do?

I tried to run an example with the SOEM-rs stack where I did not configure PDOs ... and it worked.

@birkenfeld
Copy link
Member

Ah, then you probably have to configure the complete PDO (e.g. all 8 bits of 0x1600) for use in the domain.

It might be enough to configure just index 0x7000:1 with a bit_length of 8; at least that has been the case with Beckhoff input terminals.

@flosse
Copy link
Contributor Author

flosse commented Apr 17, 2020

Ah, then you probably have to configure the complete PDO (e.g. all 8 bits of 0x1600) for use in the domain.

that doesn't change anything :(

It might be enough to configure just index 0x7000:1 with a bit_length of 8; at least that has been the case with Beckhoff input terminals.

I'll try to configure all PDOs exactly like they are offered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants