1、LINUXCNC源程序原理说明源程序的树结构如下:Overview of the emc2 directory (generated by tree -I .git -d) :.|- app-defaults|- bin (user mode binaries)|- configs| |- 5axis| |- boss| |- common| |- dallur-thc| |- demo_mazak (sample mazak config files)| |- demo_sim_cl (sample sim with ladder IO)| |- demo_step_cl (sample s
2、tepper with ladder IO)| |- etch-servo| |- halui_halvcp| |- hexapod-sim| |- lathe-pluto| |- m5i20 (sample servo using Mesa PCI)| |- max| |- motenc (sample servo using Vital PCI)| |- nist-lathe| |- plasma-thc| |- plasma-thc-sim| |- ppmc| |- puma| |- scara| |- sim (simulated motion and IO)| |- stepper
3、(parport stepper driver) | |- stepper-gantry| |- stepper-xyza| |- stg (sample servo using STG ISA)| |- univpwm (sample PICO servo generator)| |- univstep (sample PICO stepper generator)| - vti|- debian (files needed to build deb packages)| |- (extra files for Ubuntu | | |- etc| | | |- | | | |- udev|
4、 | | | |- | | | | - scripts| | | - xdg| | | - menus| | | - applications-merged| | - usr| | - share| | |- applications| | |- desktop-directories| | - pixmaps| |- (extra files for building on Ubuntu Dapper Drake)| | |- etc| | | |- | | | |- udev| | | | |- | | | | - scripts| | | - xdg| | | - menus| | |
5、- applications-merged| | - usr| | - share| | |- applications| | |- desktop-directories| | - pixmaps| |- (extra files for building on Ubuntu | | |- etc| | | |- | | | |- udev| | | | - | | | - xdg| | | - menus| | | - applications-merged| | - usr| | - share| | |- applications| | |- desktop-directories|
6、| - pixmaps| |- (extra files for building on Ubuntu Hardy Heron)| | |- etc| | | |- | | | - xdg| | | - menus| | | - applications-merged| | - usr| | - share| | |- applications| | |- desktop-directories| | - pixmaps| |- (extra files for sim package for Ubuntu | | |- etc| | | - xdg| | | - menus| | | - a
7、pplications-merged| | - usr| | - share| | |- applications| | |- desktop-directories| | - pixmaps| - (extra files for sim package for Ubuntu Dapper Drake)| |- etc| | - xdg| | - menus| | - applications-merged| - usr| - share| |- applications| |- desktop-directories| - pixmaps|- docs (All the important
8、 and relevant Docs.)| |- help| |- html (html version of docs - some generated from lyx)| |- man (man pages)| | |- man1| | |- man3| | - man9| - src (API and source notes should be in each src dir.) (source for the handbooks) (top level .lyx files)| |- code| |- common (shared .lyx files and images, su
9、ch as glossary, GPLD license)| |- config| |- gcode (.lyx files, images, etc. for G-Code documentation)| |- gui (.lyx files, images, etc. for GUI documentation)| |- hal (.lyx files, images, etc. for HAL documentation)| |- install| |- ladder| |- motion| - quickstart|- include (headers installed here -
10、 originals in src/xxx/)|- lib (user mode object files)| - python| |- rs274| - yapps|- nc_files (Sample NC files)|- rtlib (kernel mode object files, only after a successfull compile)|- scripts(bash scripts like linuxcnc, realtime, rip-environment, etc.)|- share| |- axis| | |- images| | - tcl| |- emc|
11、 - locale| |- de| | - LC_MESSAGES| |- es| | - LC_MESSAGES| |- fr| | - LC_MESSAGES| |- hu| | - LC_MESSAGES| |- it| | - LC_MESSAGES| |- pt_BR| | - LC_MESSAGES| |- ro| | - LC_MESSAGES| |- ru| | - LC_MESSAGES| |- se| | - LC_MESSAGES| |- sr| | - LC_MESSAGES| - zh_CN| - LC_MESSAGES|- src (source tree - co
12、nfigure script, top level makefile, , etc)| | |- depends (generated dependency tree)| | |- emc (actual LinuxCNC code)| | |- canterp (interpreter for canonical commands)| | |- ini (inifile related operations)| | |- iotask (IO interface, lots of HAL pins)| | |- kinematics (trajectory planner and kinem
13、atics)| | |- motion (motion controller, talks through SHM to the rest of EMC)| | |- nml_intf (emc specific NML implementation, all messages sent in emc)| | |- rs274ngc (the rs274 g-code interpreter)| | |- sai| | |- task (core component in emc, dispatches actions to other parts)| | - usr_intf (interf
14、aces for some GUIs, and other interfaces: AXIS, halui, stepconf)| | |- axis| | | |- etc| | | |- extensions| | | - scripts| | - stepconf| |- hal (the Hardware Abstraction Layer, provides a unified interface across all hardware)| | |- classicladder| | | - projects_examples| | |- components| | |- drive
15、rs| | | |- m5i20| | | | |- bit| | | | - hostmot5_src| | | |- mesa-hostmot2| | | | |- doc| | | | - firmware| | | | |- 5i20| | | | | - SOURCE| | | | - 7i43| | | | |- CPLD| | | | | - SOURCE| | | | - SOURCE| | | |- mesa7i43-firmware| | | | |- gpio| | | | | - source| | | | |- hostmot2| | | | | - src| | |
16、 | - source| | | |- mesa_5i2x| | | | - firmware| | | |- pluto_servo_firmware| | | - pluto_step_firmware| | |- user_comps| | | |- devices| | | - vcp| | - utils| | - halgui| |- libnml (a clean implementation of RCSLIB)| | |- buffer| | |- cms| | |- inifile| | |- linklist| | |- nml| | |- os_intf| | |- p
17、osemath| | - rcs| |- module_helper| |- objects| | |- emc| | | |- canterp| | | |- ini| | | |- iotask| | | |- motion| | | |- nml_intf| | | |- rs274ngc| | | |- sai| | | |- task| | | - usr_intf| | | - axis| | | - extensions| | |- hal| | | |- classicladder| | | |- components| | | |- drivers| | | |- user_
18、comps| | | | |- devices| | | | - vcp| | | - utils| | |- libnml| | | |- buffer| | | |- cms| | | |- inifile| | | |- linklist| | | |- nml| | | |- os_intf| | | |- posemath| | | - rcs| | |- rtapi| | |- rtemc| | | |- kinematics| | | - motion| | |- rthal| | | |- classicladder| | | |- components| | | - util
19、s| | |- rtlibnml| | | - posemath| | - rtobjects| | - hal| | - components| |- po (Translation files for i18n support)| |- rtapi (*.c and *.h for RTAPI) (unified RT API, wraps over RTLinux, RTAI and sim)| | - examples (testing examples for the RTAPI)| | |- extint| | |- fifo| | |- semaphore| | |- shmem
20、| | - timer| - tests|- tcl , - the tcl GUIs)| |- bin| - scripts- tests |- |- |- basic |- ccomp | |- lathe-comp | |- mill-g90g91g92 | |- mill-line-arc-entry | - mill-zchanges |- |- |- interp | |- cam-nisley | - flowsnake |- |- |- |- |- overrun |- oword | - |- |- |- |- |- |- |- - Overview of the emc2
21、install dirs: / (file system root) | | |- etc/ | | | - | | | - realtime (realtime start/stop script) | | |- $(prefix) (default: /usr/local) | | (all the following $xxxxdir are configurable through autoconf | | | |- bin/ (known as $bindir, files from EMC2/bin) | | | |- sbin/ (known as $sbindir, ) | |
22、 | |- etc/ (known as $sysconfdir, config files and subdirs from configs/) | | | |- lib/ (known as $libdir, lib files *.so from libs/) | | | - share/ | | | - emc/ | | | | | |- docs/ | | | | | - (All the important and relevant Docs.) | | | |- handbooks/ | | | | | - (PDF versions of handbooks) | | | -
23、nc_files/ | | | - (Sample NC files) | |- $MAN_DIR/ (default: /usr/local/man) | | | |- man1/ | | | | | | | | - man3/ | | | | - $moduledir/ (based on where ./configure finds the RTOS modules)根据这个结构树,我们可以清楚的知道每一个文件夹,每一个子文件的作用,包括了接口,硬件抽象层,实时内核等等部分。当然,在这里面我们需要深入研究的是linuxcnc-dev/src/emc文件夹中的各个文件,也是该数控系统的核
24、心所在。我们再次列出linuxcnc-dev/src/emc中的子结构树:linuxcnc-dev/src/emc中的子结构树:| |- emc (actual LinuxCNC code)| | |- canterp (interpreter for canonical commands)| | |- ini (inifile related operations)| | |- iotask (IO interface, lots of HAL pins)| | |- kinematics (trajectory planner and kinematics)| | |- motion (m
25、otion controller, talks through SHM to the rest of EMC)| | |- nml_intf (emc specific NML implementation, all messages sent in emc)| | |- rs274ngc (the rs274 g-code interpreter)| | |- sai| | |- task (core component in emc, dispatches actions to other parts)| | - usr_intf (interfaces for some GUIs, an
26、d other interfaces: AXIS, halui, stepconf)| | |- axis| | | |- etc| | | |- extensions| | | - scripts| | - stepconf根据该结构树,我们一个一个的再一次进行分析:(1)canterp (interpreter for canonical commands,即规范命令的解释器)#include #include 该文件定义了一些INI文件中字符的赋值,包括 一个TURE或者FAULSE,单位mm ,m,角度,直线,旋转等等。 hh #include #include .) do while
27、(0)#else/motion/#include #include ./motion/#include (1)tpCreate()创建队列,供后续调用。(2)tpClearDIOs() 如果需要改变的数字IO的存放队列,该函数将会清除之前的IO触发器队列供下次使用。(3)tpClear() 某种程度而言,该函数属于“软件初始化”,结构体TP_STRUCT中的参数将会被保留下来,而队列将会被清空。(4)tpInit(),初始化TP结构体中的参数值。(5)tpSetCycleTime(),设置程序循环时间。(6)tpSetVmax()设置最大速度。(7)tpSetVlimit()/ tpSetAm
28、ax() 同上,设置速度限制以及最大速度。(8)tpSetId()/tpGetExecId() 分别设置下一个运行周期的ID号,或获取当前的ID号。(9)pSetTermCond(tp, cond) 设置后续运动队列移动的终止条件,返回终止条件和公差。(10)tpSetPos()设置当前位置以及目标位置。备注:(4-10)所返回的参数值都是TP结构的成员,可以理解为TP中都是当前运动模式下的参数值。(11)tpAddRigidTap()/ tpAddLine()/tpAddCircle() 这三个函数是用于判断在原有的运动上所需要加入的新的运动模式,根据下一步的运动模式不同,设置不同的参数保存在结构体TC中,可以理解为TC结构体中存入了下一个运动模式时的参数值。(12)tcRunCycle() 该函数通过传入结构体参数TP以及TC,进行运动段的速度控制,源程序用到的是T形速度控制。根据判断速度和加速度的状态控制速度变化。最后返回新的速度,以及最终速度变化量(以当前的速度与最大限速进行比较,得到需要加速或者减速的多少)。(13)tpToggleDIOs() 控制数字或者模拟IO口的开或者断,保证下一次输入或者输出正确。(14)tpRunCycle() 该函数是运动控制的核心部分。首先进行emcmotStatus的初始化;判断TC
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1