Ethercat EL5152 encoder reading

30 Oct 2019 02:57 - 30 Oct 2019 03:01 #149108 by Nico2017
Hi all,

I got my encoder with a lower pulse rate (100 pulse per rev). I no longer loose steps at my top revolution speed.

However this is what I obtain in the picture attached. You can see the channel A and B signals for a constant revolution speed of the encoder shaft at the top. At the bottom you can see the encoder component velocity output signal and the output of the same signal going through a low pass filter.

I would like to know if I can get ride of those oscillation in the encoder velocity signal and if so which parameter I should play with.

I have already tried to adjust the different thread, without much better results:

I have
SERVO_PERIOD =  100000
in my ini file in the EMCMOT section then
loadrt motmod base_period_nsec=[EMCMOT]BASE_PERIOD base_thread_fp=0 servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]JOINTS num_dio=20 num_aio=20
loadrt threads name1=very-fast-thread period1=50000 fp1=0 
addf encoder.update-counters very-fast-thread
addf encoder.capture-position servo-thread
In my hal file loading the threads and components.

My A and B channel comes from an EtherCAT card EL5152 without distributed clock defined in the ethercat xml file where appTimePeriod="1000000". I am not sure if it is the issue or if it is an expected behaviour from the encoder component which gives me those oscillations.

Thanks you for your help,

Last edit: 30 Oct 2019 03:01 by Nico2017.

Please Log in or Create an account to join the conversation.

30 Oct 2019 03:51 - 30 Oct 2019 03:53 #149113 by PCW
Replied by PCW on topic Ethercat EL5152 encoder reading
Why are you not using EL5152s built in encoder counters?
forwarding the raw A, B input pins to a software encoder counter seems somewhat crazy

if you used the built in hardware counter in the EL5152 you would:

1. Count up to 400 KHz
2. Work with a 1 ms servo thread, no base thread required
Last edit: 30 Oct 2019 03:53 by PCW.
The following user(s) said Thank You: Nico2017

Please Log in or Create an account to join the conversation.

30 Oct 2019 19:09 - 30 Oct 2019 20:04 #149205 by Nico2017
My goal is to get a position and velocity feedback from the encoder.

With my low pulse rate encoder, so without missing step at my highest speed, at this stage I can connect the
lcec.0.N.enc-0-ina to my encoder.0.phase-A
lcec.0.N.enc-0-ina to my encoder.0.phase-A
Then I can use the encoder.0.position fine with my low pulse rate (100pulse/revs) but the original encoder.0.velocity pin still shows those oscillations. Using a low pass filter is possible as a first approach.

The EL 5152 lcec component has a pos, pos-scale, count and period pins. So I guess I could scale the pos information, or somehow adjust the pos-scale, to obtain the position directly from it without using the hal encoder component.

However if I want the velocity, using DDT on the position I obtain something which oscillates between a value and 0 especially when there is no position change between two thread times but the encoder is actually moving. I think the key would maybe to use the lcec.0.10.enc-0-period and more precisely the lcec.0.10.enc-0-raw-period and lcec.0.10.enc-0-raw-count.
According to the EL5152 documentation, lcec.0.10.enc-0-raw-period seems to be the time between lcec.0.10.enc-0-raw-count identical edges on one of the channel over the measuring window. lcec.0.10.enc-0-raw-period is therefore maximum when the encoder is standing still, and the value reaches the 1.67s which is the measuring window defined in the CoE.

I could then compute f = lcec.0.10.enc-0-raw-count / lcec.0.10.enc-0-raw-period if lcec.0.10.enc-0-raw-period<measuring window to obtain directly a frequency or velocity information. Would be nice if the EL5152 ethercat hal had directly this frequency output.

I will give it a try to see what it does.

Thank you,


apparently the lcec.0.10.enc-0-raw-count is just the cumulated raw count which cannot be reset and not the number of counts per raw period. So I guess the frequency information can be obtain from the lcec.0.10.enc-0-raw-period if it is associated maybe to the time between two counts.
Last edit: 30 Oct 2019 20:04 by Nico2017.

Please Log in or Create an account to join the conversation.

30 Oct 2019 20:30 - 30 Oct 2019 21:01 #149214 by Nico2017
Hi all,
I tried to get something out of lcec.0.10.enc-0-raw-period. The signal seems to possibly do the job but is suffering time to time from a big change of the value. Attached is a halscope screenshot where scale.22.out is the lcec.0.10.enc-0-raw-period inverted then scaled to get a relevant speed reading in mm/s. As we can see, there is time to time a big increase of the value which looks close to twice the average speed value. Which means that time to time the lcec.0.10.enc-0-raw-period is divided by 2.

To get rid of this transient but repeated change in the raw period, I wonder if I am using the EL5152 in the good mode as at this stage I am not using the Distributed Clock EtherCAT feature. I got the basic idea behind this concept but I am not familiar enough about how to implement it on the linuxcnc etherCAT.

What mode would be recommended to get the most accurate information from the EL5152? I am happy to do CoE modifications with TwinCAT to try to improve the reading of the lcec.0.10.enc-0-raw-period.

At the moment the scale.22.out compares nicely with the encoder.0.velocity (based on channel A and B inputs) then filter by lowpass.0 but there is still a difference. This is a bit critical for my application as I want a precise feedback for the velocity. At this stage I am not sure which methods gives the most accurate velocity feedback: either the scaled invert of the raw period or the encoder component velocity put in a lowpass filter.

Thank you for your help

Last edit: 30 Oct 2019 21:01 by Nico2017. Reason: More precise information

Please Log in or Create an account to join the conversation.

Moderators: PCWjmelson
Time to create page: 0.077 seconds
Powered by Kunena Forum