Ethercat HAL driver

More
12 years 6 months ago #45537 by narogon
Replied by narogon on topic Ethercat HAL driver
Roschi wrote a tutorial for IndraDrives. LINK

Maybe you can start on reading it ;)
The following user(s) said Thank You: Belerafon, Nico2017
More
12 years 6 months ago - 12 years 6 months ago #45566 by narogon
Replied by narogon on topic Ethercat HAL driver
First of all thank you for your replies. You are helping me a lot.

roschi wrote: Hello,
This is a normal/expected reaction of the drive. Because some parameters have to be configured druing change the states of the bus. I guess that you have to set the operation mode to value 8. --> ethercat download -t uint8 -p0 0x6060 0 8 (see the normed drive profile scheme CIA 402 and also the original XML at the end, also the 'startup' tab in TwinCAT)


It seems I can only change the state to OP in real time. I check that with TwinCAT and it gives an error if I try to change to OP in config mode.
Also in the manual they say that the operation mode (0x6060) must be changed in OP.

roschi wrote: EDIT:
ethercat download 0x6041 0x0 6 --> This does not work (see post #44649) because the drivecontrol word has address 0x6040!
Perhaps there is no need to put the bus state to OP for simple non cyclic testing (see Video for ESTUN drive)


EDIT

It was my mistake typing here, I mean 0x6040!!. For this drive I think it is needed to put the bus state to OP like I said before.

roschi wrote: Which source have you used? From github.com/sittner or from github.com/aschiffler. Right now I can not get on the problem. Just some ideas: Is the file lcec_el5101.c compiled during build. Perhaps there went somthing wrong with the makefile or the linker commands.

I use github.com/sittner. There is a mistake in the makefile, they forgot to include "hal/drivers/ethercat/lcec_el5101.o \". Now I can load lcec without problem.


Now I'm stuck with the real time functions. I see that it recognizes the slave (lcec.0.slaves-responding = 1 or lcec.0.state-op = true for example) but it doesn't update the pins (drivestatus lcec.0.0.drivestatus-0..., pos: lcec.0.0.pos)

What functions must be attached to the servo-thread?

How could I test the drive?

Could you explain me something about all of it?

Thanks again!
Last edit: 12 years 6 months ago by narogon.
More
12 years 6 months ago #45581 by roschi
Replied by roschi on topic Ethercat HAL driver
Hello narogon,

first of all I think you are not far away from success!

In the "original" OMRON XML File for TwinCAT there is a entry for the "Startup". That means this are the commands which are send/configured when you want to activate the state transition preop -> op. You see this in TwinCAT GUI under the Tab "startup"
For LinuxCNC and EtherCAT HAL setup this means to add this commands on the XML File.
Code:
.... <sdoConfig idx="6060" subIdx="0"> <sdoDataRaw data="08"/> </sdoConfig> ...
All data under the "sdoConfig" is send/configured during the state transition preop --> op via Mailbox protocol CoE (this will function for all drives which use the normed drive profil CIA 402 see here )

The state machine will change automaticlly from preop--> op if the HAL componente lcec is loaded and the slaves will acknodledge the state change (see LED/Display indicators of the drive). There is no button/value at HAL driver/pins to manually change the state.
---The next lines are just for details
Within the source of lcec.c component (as in every HAL component) there is the init function (called once) and during this function call the sdo, pdo, dc, watchdog is configured. At the end of the lcec init function the master is started ( ecrt_master_activate(master->master) see EtherLab doc fore more details ).

Additionally you have to add the functions
Code:
addf lcec.read-all servo-thread addf motion-command-handler servo-thread addf motion-controller servo-thread addf lcec.write-all servo-thread ....(some other needed)
in the HAL configuration. (Base Period is not needed set it to zero)

Alternativlly you can configure the operation mode (0x6060) within the cyclic data (=pdo)
Code:
... <pdoEntry idx="6060" subIdx="00" bitLen="8" halPin="opmode" halType="bit"/> ...
this enables you to change the operation mode during the machine is running. If the drive uses the CIA 402 this could be nessesary to change the op-mode to "homing".
(I have prorammed some PLC code in the classic ladder to switch to homing mode in the case homing sequence is requested--> axis.N.homing = 1)

If you want to configure other values during startup for the drive
Code:
-EXAMPLE- <sdoConfig idx="6099" subIdx="1"> <sdoDataRaw data="E8 03 00 00"/> </sdoConfig> <sdoConfig idx="6099" subIdx="2"> <sdoDataRaw data="64 A2 00 00"/> </sdoConfig>
Be prepared that for the example above 0x6099 subIdx 1 = 0x3E8 and 0x6099 subIdx 2 = 0xA264. You have to write the data from right to left byte-wise (!) and include all zeros correponding to the bit length of the register (0x6099 --> 32 bit, 0x6060 --> 8 bit)

I check that with TwinCAT and it gives an error if I try to change to OP in config mode.

Have you activated the "cylic-mode" in TwinCAT configurator? This is the button with the circle arrow.

Hope that will help. Please give some little report on success.
Up to now we (= community) know that: IndraDrive from Bosch Rexroth, ProNet-E drive from ESTUN and drives from Stoeber will function at LinuxCNC with EtherCAT.

Best Regards Andreas
The following user(s) said Thank You: Nico2017
More
12 years 6 months ago #45589 by Coyote
Replied by Coyote on topic Ethercat HAL driver

roschi wrote:
Additionally you have to add the functions

Code:
addf lcec.read-all servo-thread addf motion-command-handler servo-thread addf motion-controller servo-thread addf lcec.write-all servo-thread ....(some other needed)


Hi Andreas,

As you're the best expert of ethercat on linuxcnc I am not the one who can give better solution than you, so take it as suggestion or idea for everything I will write, that it could be also wrong:

What is begging me is the fact that you read inputs first, you process and then you output the new states. In some literature this is so called IPO cycle (input/process/output). From what I understood a single frame of ethercat consists of output that is sent from master and slave encodes the into the same frame on the fly its inputs.
If we look breifly:
1. at time t(n) master sends output that will be activated with delay at time t(n+1)
2. at time t(n) slave encodes a frame that has an information of inputs, latched at time t(n-1)
(This is only my understanding, not the fact)

From my point of view at time t(n) you should perform:
1. output actions that will execute at time t(n+1)
2. read latched inputs taken at time t(n-1)
3. compute outputs

No matter of jitter all drives will be scnchronized, the lag is always present and it is deterministic 2 cycles between input and output.

I gave a look in lcec.c, but I was not able to find such mechanism (I'm not a c++ expert), I would expect that write command sends outputs and receives data from slaves at the same time. I also looked at IgH manual, but I couldn't find anything to proove my hypotesis.

www.iebmedia.com/index.php?id=5794&paren...sdbdisi17g3lao0j06n7

www.vaeprosys.cz/dokumentace/ac500/Engli.../EtherCAT-Basics.htm

Regards, Marko.
More
12 years 6 months ago #45609 by Coyote
Replied by Coyote on topic Ethercat HAL driver
Second hypotesis:

1. lcec_write command sends outputs to queue
2. exit form servo thread
3. at pre-determined time datagram is sent and received, latched inputs are stored in a buffer
4. wait interrupt - servo thread
5. read latched inputs from buffer
6. compute output
back to step 1.

This is more likely what is happening and it's compatible to your model.
More
12 years 6 months ago #45628 by roschi
Replied by roschi on topic Ethercat HAL driver

Coyote wrote: ...
What is begging me is the fact that you read inputs first, you process and then you output the new states. In some literature this is so called IPO cycle (input/process/output). From what I understood a single frame of ethercat consists of output that is sent from master and slave encodes the into the same frame on the fly its inputs.
...

Code:
addf lcec.read-all servo-thread addf motion-command-handler servo-thread addf motion-controller servo-thread addf lcec.write-all servo-thread

I try to express the questions around the topic time delay in simple words and based on my experiences for LinuxCNC

The ethercat master makes the Ethernet Hardware send 'one' standard frame with a size of several bytes every 1000 µs.
The frame pass all slaves and the last slave sends the frame back to the master. This round trip of the frame takes
in general less than 10 µs.
The slaves read and/or write from/to this 'one' frame on the fly.

The function calls in the HAL configuration shown above do the following things in core. Times are approx. and should be seen as an EXAMPLE. Bus cycle time = servo thread = 1000 µs.

--- lcec.read-all --- start t=0 µs
ecrt_master_receive (ec_master_t *master)
--> receive frame from Ethernet Hardware (the frame is already there because the bus rate is much bigger than round trip time of the frame )
ecrt_domain_process (ec_domain_t *domain)
--> interpret the frame data
EC_READ_U32(DATA_feedback)
--> copy data e.g. to HAL pins (data_feedback was written to the frame by the slaves at t = -5µs)
--- lcec.read-all --- end t=20 µs

--- motion-* --- start t=20 µs
calculate new DATA_demand
--> write something to DATA_demand with or w/o depending on DATA_feedback
--- motion-* --- end t=40 µs


--- lcec.write-all --- start t=40 µs
EC_WRITE_U32(DATA_demand)
--> copy data to 'frame'
ecrt_domain_queue(ec_domain_t *domain)
--> mark frame as queued for sending
ecrt_master_send(ec_master_t *master)
--> make the Ethernet Hardware send the frame which are queued; The slaves read the data_demand from frame at t=65µs
--- lcec.write-all --- end t=60 µs

The next 940 µs nothing happens.
So in systems theory the sampling rate / control rate is 1 bus cycle time.

You could also see the test code for RTAI in the EtherLAB EtherCAT Master documentation/code. Where the nessesary function calls are shown in simple examples.

I'm not a expert in EtherCAT. I only make use of the great work from people at IgH (etherlab.org), S. Ittner (EtherCAT HAL Driver) and the development community of LinuxCNC.

Best Regards
Andreas
The following user(s) said Thank You: Nico2017
Time to create page: 0.183 seconds
Powered by Kunena Forum