当前位置:网站首页>EcRT of EtherCAT igh source code_ slave_ config_ Understanding of dc() function.
EcRT of EtherCAT igh source code_ slave_ config_ Understanding of dc() function.
2022-06-22 04:10:00 【Marathon】
To sum up my understanding of igh Of ecrt_slave_config_dc() The understanding of function . Refer to the igh Of example Inside “dc_user routine ”.
There is such a code in the routine :
// configure SYNC signals for this slave
ecrt_slave_config_dc(sc, 0x0700, PERIOD_NS, 4400000, 0, 0);
stay slave_config.c The function definition can be found in the file :
/** Configure distributed clocks. * * Sets the AssignActivate word and the cycle and shift times for the sync * signals. * * The AssignActivate word is vendor-specific and can be taken from the XML * device description file (Device -> Dc -> AssignActivate). Set this to zero, * if the slave shall be operated without distributed clocks (default). * * This method has to be called in non-realtime context before * ecrt_master_activate(). * * \attention The \a sync1_shift time is ignored. */
void ecrt_slave_config_dc(
ec_slave_config_t *sc, /**< Slave configuration. */
uint16_t assign_activate, /**< AssignActivate word. */
uint32_t sync0_cycle, /**< SYNC0 cycle time [ns]. */
int32_t sync0_shift, /**< SYNC0 shift time [ns]. */
uint32_t sync1_cycle, /**< SYNC1 cycle time [ns]. */
int32_t sync1_shift /**< SYNC1 shift time [ns]. */
);
void ecrt_slave_config_dc(ec_slave_config_t *sc, uint16_t assign_activate,
uint32_t sync0_cycle_time, int32_t sync0_shift_time,
uint32_t sync1_cycle_time, int32_t sync1_shift_time)
{
ec_ioctl_config_t data;
int ret;
data.config_index = sc->index;
data.dc_assign_activate = assign_activate;
data.dc_sync[0].cycle_time = sync0_cycle_time;
data.dc_sync[0].shift_time = sync0_shift_time;
data.dc_sync[1].cycle_time = sync1_cycle_time;
data.dc_sync[1].shift_time = sync1_shift_time;
ret = ioctl(sc->master->fd, EC_IOCTL_SC_DC, &data);
if (EC_IOCTL_IS_ERROR(ret)) {
fprintf(stderr, "Failed to set DC parameters: %s\n",
strerror(EC_IOCTL_ERRNO(ret)));
}
}
1. First of all, let's talk about assign_activate Variables are 0x0700
according to igh The explanation given ,assign_activate The value of the variable can be in the slave station xml Found in the file :
Open one xml file , The relevant parameters can be found according to the prompts :
But here is 0x0300, instead of 0x0700. I have verified , Most slave stations xml Of AssignActivate The value is 0x0300.
What is the relationship between these two values ? Why is it set like this ?
The next section is my reasoning analysis with a little friend , It could be wrong , Please correct !!!
2. analysis 0x0700 and 0x0300
In this section, I refer to this elder brother's article https://blog.csdn.net/ethercat_i7/article/details/77890740, I benefited a lot .
igh/ethercat-hg/master/fsm_slave_config.c
/** Slave configuration state: DC START. */
void ec_fsm_slave_config_state_dc_start(
ec_fsm_slave_config_t *fsm /**< slave state machine */
)
{
ec_datagram_t *datagram = fsm->datagram;
ec_slave_t *slave = fsm->slave;
ec_slave_config_t *config = slave->config;
......
EC_SLAVE_DBG(slave, 1, "Setting DC AssignActivate to 0x%04x.\n",
config->dc_assign_activate);
// assign sync unit to EtherCAT or PDI
ec_datagram_fpwr(datagram, slave->station_address, 0x0980, 2);
EC_WRITE_U16(datagram->data, config->dc_assign_activate);
fsm->retries = EC_FSM_RETRIES;
fsm->state = ec_fsm_slave_config_state_dc_assign;
}
The code here finds AssignActivate And 0x0980 Linked together , and 0x0980 It is DC Control related registers , see lan9252 perhaps ET1100 You can find the relevant settings in the data book of the chip . Recommend here 《 Industrial Ethernet fieldbus EtherCAT Driver design and application 》 This blue book , A new version has just been released this year . There is also an explanation of relevant registers in the book . The following figure shows the contents of the book .
0x0981 and 0x0980 The two registers add up to 16 position .0x0981 Take up high 8 position ,0x0980 Low occupancy 8 position .0x0700 and 0x0300 That is, the setting of these two registers .
Refer to the register manual :
0x0981 Of 0、1 Location 1、 Other locations 0 It indicates that the “ Activate the operating cycle , Activate SYNC0”, namely 0x0300;
0x0981 Of 0、1、2 Location 1、 Other locations 0 It indicates that the “ Activate the operating cycle , Activate SYNC0, Activate SYNC1”, namely 0x0700;
3.ecrt_slave_config_dc() After 4 Parameters
sync0_cycle_time, sync0_shift_time, sync1_cycle_time, sync1_shift_time this 4 The parameters are set separately SYNC0、1 Period and offset of .
Recommended reference 《EtherCAT_Communication_EN-》 and 《 Industrial Ethernet fieldbus EtherCAT Driver design and application 》.





DC I still don't understand a lot about the relevant content , After that, through continuous learning 、 practice 、 Ask the big man , To improve your cognition .
reference
【1】https://blog.csdn.net/ethercat_i7/article/details/77890740
【2】https://blog.csdn.net/GW569453350game/article/details/51612802
【3】http://lists.etherlab.org/pipermail/etherlab-users/2016/003013.html
【4】https://blog.csdn.net/PI_sunyang/article/details/95601486
【5】《EtherCAT_Communication_EN-》
【6】《 Industrial Ethernet fieldbus EtherCAT Driver design and application 》
边栏推荐
- How far is the memory computing integrated chip from popularization? Listen to what practitioners say | collision school x post friction intelligence
- Empty, isset and is of PHP_ Null difference
- 天阳科技-宁波银行面试题【杭州多测师】【杭州多测师_王sir】
- Join waits for synchronization results from multiple threads
- Solutions pour l'écran bleu idea
- 利用PuTTY配置端口映射,实现外网对服务器的访问
- Multithread interrupt usage
- How does twitter decentralize? Look at these ten socialfi projects
- 如何快速定位bug和编写测试用例?
- TCL Huaxing released the world's first 0.016hz ultra-low frequency OLED wearable device screen
猜你喜欢

順序錶的基本操作

Some journals of C51

Insert sort

Interviewer: do you know the life cycle of flutter?

Huffman tree

Seven thousand word explanation of Alibaba cloud's new generation cloud computing architecture cipu

低功耗雷达感应模组,智能锁雷达感应方案应用,智能雷达传感器技术

Sequential implementation of queues

BFs of figure

Online text batch inversion by line tool
随机推荐
Window common shortcut keys
kubernetes集群中工作节点Noready故障处理
嵌入式软件测试的经验经历和总结
FaceShifter. ipynb
Tianyang technology - Bank of Ningbo interview question [Hangzhou multi tester] [Hangzhou multi tester \wang Sir]
SSM based blog system [with background management]
How to implement dart asynchrony
How far is the memory computing integrated chip from popularization? Listen to what practitioners say | collision school x post friction intelligence
A solution to the conflict between the keywords of DM data and the fields of the table
Quickly master asp Net authentication framework identity - user registration
顺序表的基本操作
Multithread interrupt usage
Ora-48132 ora-48170 appears in the alarm log
快速排序
Raspberry pie preliminary use
Yum command
天阳科技-宁波银行面试题【杭州多测师】【杭州多测师_王sir】
Internet of things UWB technology scheme, intelligent UWB precise positioning, centimeter level positioning accuracy
Low power radar sensing module, application of smart lock radar sensing scheme, smart radar sensor technology
read stream 特别注意