SOES(EtherCAT中的sercos over EtherCAT)v1.0.0——tutorial.txt File Reference

tutorial.txt File Reference

Detailed Description

General

The SOES is a library that provides the Micro Controller user application with the means to access the EtherCAT fieldbus communication environment:

  • EtherCAT State Machine
  • Mailbox Interfaces
  • Protocols
    • CoE
    • FoE + bootstrap template

Support for mailbox and protocols are typical examples when you need a slave stack to control the Application Layer of EtherCAT. The PDI used for such applications is either SPI or some Micro Controller Interface

The following sections show some basic examples on how to get the SOES up and running, as well as a lightweight example on howto design your slave. Since all code is local to the application or global variables, it is possible to tweak and optimize when possible.

Our target Application:

  • Inputs 40bit
    • One button 8bit
    • One encoder value 32bit
  • Outputs 8bit
    • LED 8bit
  • Parameters
    • Encoder settings
  • Slave commands
    • Reset counter

Now to translate and implement on top of SOES.

First look on the start up code. This example shows how to add a main function that will be called by startup code. In this example main's only purpose is to spawn(产生) two new tasks. One that executes SOES and one that control the ERROR LED. Some ESCs provided a pin for the RUN LED, some even for the ERROR LED, if it don't you can control them from the slave Micro Controller. We'll focus on the "soes" task.主要关注soe任务

int main (void)
{
   rprintp ("SOES (Simple Open EtherCAT Slave)\nsoes test\n");

   /* task_spawn ("led_run", led_error, 15, 512, NULL); /
   task_spawn ("led_error", led_error, 15, 512, NULL);
   task_spawn ("soes", soes, 9, 1024, NULL);

   return (0);
}

Configuration

The function soes is our EtherCAT slave device and can be split in 3 parts. Hardware Init, Software Init and Application loop. We will start with the Hardware Init.包括硬件初始化,软件初始化,应用循环

  • Hardware Init
    • esc_reset, special function used for ESC reset if no Physical EEPROM used. This is local to the Application not part of the generic ESC handling.
    • ESC_init, initialise SPI communication or similar SPI初始化
    • Wait for ESC is started, waiting for SPI to be up and running, we'll query the ESC register DL status if EEPROM loaded OK and PDI operational, eg. SPI OK.等待ESC started up
void soes (void *arg)
{
   TXPDOsize = SM3_sml = sizeTXPDO ();
   RXPDOsize = SM2_sml = sizeRXPDO ();

   esc_reset ();
   ESC_init ((void *)spi_name);

   task_delay (tick_from_ms (200));

   // wait until ESC is started up
   while ((ESCvar.DLstatus & 0x0001) == 0)
   {
      ESC_read (ESCREG_DLSTATUS, (void *) &ESCvar.DLstatus,
                sizeof (ESCvar.DLstatus), (void *) &ESCvar.
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值