[Etherlab-users] Distributed Clocks and Oversampling - slave configuration of the ELM3604-002

Richard Hacker ha at igh.de
Thu May 27 10:12:39 CEST 2021


Have a look at el1262.m for a good example of using oversampling; even
the output vector and PDO's are calculated dynamically based on the
oversampling factor. For example, to turn on oversampling rate 4,
choose:

rv.SlaveConfig.dc = [hex2dec('730'),0,-4,-10000,1,1,0,-1,0,0];

and you should be fine, instead of calculating and hard coding
CycleTimeSync1 manually! Notice how there is absolutely no reference to
the block's sampling time since it is implicitely calculated when using
factors.

Your calculation does not seem to be wrong though (the value of
CycleTimeSync1=150000 is correct), but rather let the block calculate
these values itself. It reduces your problem set by one ;)

Your problem may be related to your hardware as Gavin replies.

On a side note: notice that elm3604.m is a function, so you could
parameterize it using:
function rv=elm3604(osfac)

and then calling
elm3604(4)
from the generic slave's "EtherCAT Slave Configuration struct"
parameter field. Like this you do not have to edit elm3604.m manually
every time you want to change the oversampling factor. Just makes life
a little easier

Richard 

On Wed, 2021-05-26 at 12:59 +0000, Merkel, Amos wrote:
> Hi everyone!
>  
> I am trying to get an ELM3604-002 by Beckhoff to work in the etherlab
> environment using Simulink and the generic slave block of the
> etherlab_lib.  
> So far, I managed to get the slave operating and working for lower
> sample rates, but keep getting error states and “DC Invalid Sync
> Cycle Time” messages in dmesg for anything higher than 4kHz.
> Unfortunately, I do not really understand how the DC configuration
> works in detail, and the ELM3604-002 apparently does not support
> freerun mode, so I am stuck right now.
>  
> Does anyone have an idea how to fix this? I would be most grateful
> for any hint!
> You will find my Matlab function with the slave struct below.
>  
> Best regards,
>  
> Amos
>  
> %% ELM3604-0002 Generic Slave Struct
> % by Amos Merkel
> %% notes
> %    firmware does not support freerun mode
> %    Output Port 1..4: Value-Vector Channel 1..4,
> %                           -length depends on oversampling factor
> %                           -vector entry n correspondents to nth
> value of
> %                           timestep, taken at time timestep +
> %                           n*Timesteplength/oversampling factor
> %    Output Port 5..8: Status Output of Channel 1..4, if activated
> %                            -entries are: 1: error 2: Underrange 3:
> Overrange 4: Diag
> %                            5: TxPDOState
> %    configure osm (in 1..15) and t_sample to your need
> %    check SDO Configuration below and configure to your needs (see
> Beckhoff documentation for
> %    additional options)
> %% struct
> function rv=elm3604
> osm=3;                  % osm:          oversampling mode in range
> 1..15 for the resulting oversampling rates: 1 2 4 5 8 10 16 20 25 32
> 40 50 64 80 100
> tsample=1/5000;%tsample=1e-3;           % tsample:      sample time
> in s
> StatusOutput=true;      % StatusOutput: Add Status Outputs for each
> Channel
> osm=max(min(osm,15),1); % limit os to 1..100
> osf=[1 2 4 5 8 10 16 20 25 32 40 50 64 80 100]; %oversampling rates
> corresponding to oversampling mode
> os=osf(osm);            % actual oversampling factor
> CycleTimeSync1=double(uint32(tsample(1)*(1-1/os)*1e9));
> %% -------------Slave Configuration------------------
> rv.SlaveConfig.vendor=2;
> rv.SlaveConfig.product=hex2dec('50219349');
> rv.SlaveConfig.description='ELM3604-0002';
> if os>1
>     rv.SlaveConfig.dc=[hex2dec('0730') 0 -os -250000 1 1
> CycleTimeSync1 0 0 0 ]; % DC-Setup [Assign_Activate Cycle_Time_Sync0
> Cycle_Time_Sync0_Factor Shift_Time_Sync0 Shift_Time_Sync0_Factor
> Shift_Time_Sync0_Input Cycle_Time_Sync1 Cycle_Time_Sync1_Factor
> Shift_Time_Sync1 Shift_Time_Sync1_Factor]
> 



More information about the Etherlab-users mailing list