基于 PIC24HJ128GP306 的 EtherCAT 从站的设计

1.Design Slave structure
EtherCAT 从站不仅要处理通信网络数据,还要完成一些对其他任务的控制工作 从站的硬件主要是由 PIC 单片机 FB1111- 0142 板卡 输入输出模块,供电电源及时钟模块 接口设计模块组成,其构成如图1 所示 从站微处理器主要是管理通信过程和控制任务,而 ESC 主要是处理通信数据 除此之外,物理层芯片 PHY 能够实现数据编码 译码和收发,介质访问控制则通过通信控制器完成,他们之间通过一个介质无关接口 ( Media Independent Interface,MII)交互数据MII 接口可以把物理层和以太网数据链,路层完全隔离开,这样以太网可以使用各种传输介质 ,最后隔离变压器可以实现信号的隔离,提高系统的稳定性.
2.configure realtime
version :Twincat 3
I’ve highted the importan nodes,under system->tasks,there is new task called plc task.A task is what gets scheduled to run on the TwinCAT3 runtime(is that,you can not run a program directly,you have to creat a task, and then run it)
You can double -click on the plc task node under the SYSTEM > Task node.now,you can see this properties page for the task
picture ignore
Maybe we will see our program called MAIN in PLC erery 10 ms.
OK!
We know that all of the editing we have doing in Twincat3 XAE is a normal windows program,and windows is a gereral-purpose system,not a real-time operating system. The runtime component of twincat 3 (call XAR) has to run under real-time conditions so that it won’t be pre-empted by other tasks on the computer while it is busy executing machine control logic.
原理:
TwinCAT 3运行环境通过在“ring 0”执行模式下运行,抢先正常的Windows程序。在Windows中,只有两种执行模式:ring0和ring3.ring0是“内核”模式,这是所有驱动程序和一些内部窗口代码运行的地方,ring3是“用户”模式,这是正常的Windows程序跑。
运行时注册一个定时器中断,以强制执行运行时间间隔(called clock tick)。中断例程在ring0或内核模式下运行,因此运行时可以访问计算机的全部资源。运行时然后执行任务,每个任务都可以执行诸如运行PLC程序,运动控制,与EtherCAT I / O总线接口或管理与HMI的通信。这些中断优先于ring3(用户模式)程序,因此运行时总是优先于普通的Windows程序,如TwinCAT 3编辑器或HMI。
要配置TwinCAT 3的实时行为,请双击解决方案资源管理器中的SYSTEM> Real-Time节点(突出显示):
Date:2018-1-02

猜你喜欢

转载自blog.csdn.net/pi_sunyang/article/details/78952156