LINUXCNC源程序原理说明(25页).doc

上传人:1595****071 文档编号:35372934 上传时间:2022-08-21 格式:DOC 页数:25 大小:270KB
返回 下载 相关 举报
LINUXCNC源程序原理说明(25页).doc_第1页
第1页 / 共25页
LINUXCNC源程序原理说明(25页).doc_第2页
第2页 / 共25页
点击查看更多>>
资源描述

《LINUXCNC源程序原理说明(25页).doc》由会员分享,可在线阅读,更多相关《LINUXCNC源程序原理说明(25页).doc(25页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、-LINUXCNC源程序原理说明-第 25 页opLINUXCNC源程序学习源程序的树结构如下: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)| |-

2、demo_step_cl (sample stepper 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 motio

3、n and IO)| |- stepper (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)| |- extras-Ubuntu-5.10 (extra files for

4、 Ubuntu 5.10)| | |- etc| | | |- udev| | | | - scripts| | | - xdg| | | - menus| | | - applications-merged| | - usr| | - share| | |- applications| | |- desktop-directories| | - pixmaps| |- extras-Ubuntu-6.06 (extra files for building on Ubuntu 6.06 Dapper Drake)| | |- etc| | | |- udev| | | | - scripts

5、| | | - xdg| | | - menus| | | - applications-merged| | - usr| | - share| | |- applications| | |- desktop-directories| | - pixmaps| |- extras-Ubuntu-7.10 (extra files for building on Ubuntu 7.10)| | |- etc| | | |- udev| | | - xdg| | | - menus| | | - applications-merged| | - usr| | - share| | |- appli

6、cations| | |- desktop-directories| | - pixmaps| |- extras-Ubuntu-8.04 (extra files for building on Ubuntu 8.04 Hardy Heron)| | |- etc| | | - xdg| | | - menus| | | - applications-merged| | - usr| | - share| | |- applications| | |- desktop-directories| | - pixmaps| |- extras-sim-Ubuntu-5.10 (extra fil

7、es for sim package for Ubuntu 5.10)| | |- etc| | | - xdg| | | - menus| | | - applications-merged| | - usr| | - share| | |- applications| | |- desktop-directories| | - pixmaps| - extras-sim-Ubuntu-6.06 (extra files for sim package for Ubuntu 6.06 Dapper Drake)| |- etc| | - xdg| | - menus| | - applica

8、tions-merged| - usr| - share| |- applications| |- desktop-directories| - pixmaps|- docs (All the important 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

9、.) (source for the handbooks) (top level .lyx files)| |- code| |- common (shared .lyx files and images, such 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.

10、for HAL documentation)| |- install| |- ladder| |- motion| - quickstart|- include (headers installed here - 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(ba

11、sh scripts like linuxcnc, realtime, rip-environment, etc.)|- share| |- axis| | |- images| | - tcl| |- emc| - locale| |- de| | - LC_MESSAGES| |- es| | - LC_MESSAGES| |- fr| | - LC_MESSAGES| |- hu| | - LC_MESSAGES| |- it| | - LC_MESSAGES| |- pt_BR| | - LC_MESSAGES| |- ro| | - LC_MESSAGES| |- ru| | - L

12、C_MESSAGES| |- se| | - LC_MESSAGES| |- sr| | - LC_MESSAGES| - zh_CN| - LC_MESSAGES|- src (source tree - configure script, top level makefile, Makefile.inc, etc)| |- depends (generated dependency tree)| |- emc (actual LinuxCNC code)| | |- canterp (interpreter for canonical commands)| | |- ini (inifil

13、e related operations)| | |- iotask (IO interface, lots of HAL pins)| | |- kinematics (trajectory planner and kinematics)| | |- 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

14、interpreter)| | |- sai| | |- task (core component in emc, dispatches actions to other parts)| | - usr_intf (interfaces for some GUIs, and other interfaces: AXIS, halui, stepconf)| | |- axis| | | |- etc| | | |- extensions| | | - scripts| | - stepconf| |- hal (the Hardware Abstraction Layer, provides

15、a unified interface across all hardware)| | |- classicladder| | | - projects_examples| | |- components| | |- drivers| | | |- m5i20| | | | |- bit| | | | - hostmot5_src| | | |- mesa-hostmot2| | | | |- doc| | | | - firmware| | | | |- 5i20| | | | | - SOURCE| | | | - 7i43| | | | |- CPLD| | | | | - SOURCE

16、| | | | - SOURCE| | | |- mesa7i43-firmware| | | | |- gpio| | | | | - source| | | | |- hostmot2| | | | | - src| | | | - source| | | |- mesa_5i2x| | | | - firmware| | | |- pluto_servo_firmware| | | - pluto_step_firmware| | |- user_comps| | | |- devices| | | - vcp| | - utils| | - halgui| |- libnml (a c

17、lean implementation of RCSLIB)| | |- buffer| | |- cms| | |- inifile| | |- linklist| | |- nml| | |- os_intf| | |- posemath| | - rcs| |- module_helper| |- objects| | |- emc| | | |- canterp| | | |- ini| | | |- iotask| | | |- motion| | | |- nml_intf| | | |- rs274ngc| | | |- sai| | | |- task| | | - usr_i

18、ntf| | | - axis| | | - extensions| | |- hal| | | |- classicladder| | | |- components| | | |- drivers| | | |- user_comps| | | | |- devices| | | | - vcp| | | - utils| | |- libnml| | | |- buffer| | | |- cms| | | |- inifile| | | |- linklist| | | |- nml| | | |- os_intf| | | |- posemath| | | - rcs| | |- r

19、tapi| | |- rtemc| | | |- kinematics| | | - motion| | |- rthal| | | |- classicladder| | | |- components| | | - utils| | |- rtlibnml| | | - posemath| | - rtobjects| | - hal| | - components| |- po (Translation files for i18n support)| |- rtapi (*.c and *.h for RTAPI) (unified RT API, wraps over RTLinux

20、, RTAI and sim)| | - examples (testing examples for the RTAPI)| | |- extint| | |- fifo| | |- semaphore| | |- shmem| | - timer| - tests|- tcl (tkemc.tcl, mini.tcl - the tcl GUIs)| |- bin| - scripts- tests |- basic |- ccomp | |- lathe-comp | |- mill-g90g91g92 | |- mill-line-arc-entry | - mill-zchanges

21、 |- interp | |- cam-nisley | - flowsnake |- overrun |- owordOverview of the emc2 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, file

22、s from EMC2/bin) | |- sbin/ (known as $sbindir, ) | |- 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 handbo

23、oks) | - 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文件夹中的各个文件,也是该数控系统的核心所在。我们再次列出linuxcnc-dev/

24、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 (motion controller, talks

25、 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, and other interfaces: AXI

26、S, halui, stepconf)| | |- axis| | | |- etc| | | |- extensions| | | - scripts| | - stepconf根据该结构树,我们一个一个的再一次进行分析:(1)canterp (interpreter for canonical commands,即规范命令的解释器)#include / FILE, fopen(), fclose()#include / strcpy()#include / isspace()#include #include #include config.h#include emc/nml_intf/i

27、nterp_return.hh#include emc/nml_intf/canon.hh#include emc/rs274ngc/interp_base.hh其中包括了语法解析,读取,执行等函数,对刀具信息、主轴转速、开始、停止等信息进行判断和执行工作。(2)ini (inifile related operations,初始化相关的文件)同样,列出该文件夹的结构树:| |- ini (inifile related operations)| | |- /hh | | |- /hh | | |- /hh | | |- /hh | | |- /hh (2.1) /hh #include /

28、M_PI.#include emcIniFile.hh该文件定义了一些INI文件中字符的赋值,包括 一个TURE或者FAULSE,单位mm ,m,角度,直线,旋转等等。(2.2) /hh #include #include / NULL#include / atol(), _itoa()#include / strcmp()#include / isdigit()#include #include #include emc.hh#include rcs_print.hh#include emcIniFile.hh#include iniaxis.hh/ these decls#include

29、emcglb.h/ EMC_DEBUG#include emccfg.h/ default values for globals#include inihal.hh该文件主要用到了两个函数:loadaxis以及iniaxis。前一个函数loadaixs是对INI文件中的轴类型,轴单元,最大最小位置限值,误差限值,最大速度,加速度,加加速度等初始化参数进行读取并存储在&axisIniFile中,这些参数对应于INI文件中AXIS一栏中的参数,并将部分参数赋值给old_inihal_data。除此之外,iniaxis函数主要是读取INI文件中TRAJ部分的AXIS轴数,然后调用loadaxis进行

30、初始化加载。除去两个主要函数,还有一个精度判断函数iniGetFloatPrec以及状态函数(可有可无)。()initraj.cc/hh该文件主要包含以下几个函数:loadTraj,用于加载INI文件中TRAJ中的配置参数,然后将读取的参数值进行保存,主要赋值给old_inihal_data以及traj_max_velocity等变量,供后续其他文件调用。同时该文件的后面还有一个坐标轴返回原点的判断程序,从而保证TRAJ中的原点坐标。其实,该文件类似于/hh。()inihal.cc/hh#include rcs_print.hh#include emc.hh#include #include

31、hal.h#include rtapi.h#include inihal.hh该文件中主要包含以下几个函数:ini_hal_init,用于定义HAL中的新的管脚,包括了各轴中的INI参数管脚,以及TRAJ中的INI参数管脚;ini_hal_init_pins,用于对之前定义好的新管脚进行赋值,主要是将old_inihal_data中的参数值存储到*(the_inihal_data-NAME)中去。check_ini_hal_items(),用于对各个管脚的值进行更新检查。备注:old_inihal_data中的值都是在以及中赋值了的。(3) iotask该文件在这里不做详细介绍,主要是创建“i

32、ocontrol”组件,并对一些接口文件进行配置。(4)Kinamitcs该文件夹中包含了不同的运动控制模块,例如五轴、三轴、六轴等等。除此之外,还包含了插补以及速度控制的轨迹规划文件。()运动控制模块()轨迹规划模块文件主要是基于轨迹规划的简单判别文件,由调用。下面我们分别说明该文件中的一些函数。#include rtapi.h/* rtapi_print_msg */#include posemath.h#include emcpos.h#include tc.h(1)tcGetStartingUnitVector 主要是获取运动轨迹的起始点的起始单位向量,如果是直线或者攻丝,那么直接计算

33、起始与终止点的位移大小。如果不是,那么就是圆形运动,计算曲率,半径,起始点等等。(2)tcGetEndingUnitVector 主要是获取运动轨迹的终止点的终止单位向量,如果是直线,那么直接计算终点坐标减去起点坐标的大小。如果是攻丝,那么计算起点坐标减去终点坐标的大小。对于其他运动,即曲线运动,则根据转过的角度,计算终点坐标,然后计算曲率半径,并将数据保存到指定位置V中。(3)tcGetPos/tcGetEndpoint 两个都是通过调用函数tcGetPosReal从而得到位置信息。(4) tcGetPosReal 根据传入的参数判断是计算当前位移值还是目标位移值;其次判断运动类型,如果是攻

34、丝,判断是正转还是反转的,再进行坐标值计算(具体算法先省略)。如果是直线运动,因为只是涉及到了xyz,其他轴uvw,abc等只需要进行配合运动即可,或者是XYZ不动,或者只有ABC再动等等。如果是曲线运动,同样配合计算其他各轴位移。判断完毕之后,返回各个轴的位移。(5)tcqCreate() 建立TC结构体的新队列。(6)tcqDelete() 删除TC结构体的队列。(7)tcqInit (8)tcqPut()/tcqRemove()/tcqLen()/tcqItem() 数据存放,先入先出;tcqLen()数据队列的大小;tcqItem()读取数据队列的第N的元素。(9)tcqFull()

35、判断堆栈是否已满,或者快要满了。文件主要实现轨迹规划。#ifdef RTAPI#define assert(args.) do while(0)#else/ SIM#include #include #include #include #endif#include rtapi.h/* rtapi_print_msg */#include rtapi_string.h /* NULL */#include posemath.h#include tc.h#include tp.h#include rtapi_math.h#include ./motion/motion.h#include hal.

36、h#include ./motion/mot_priv.h#include motion_debug.h(1)tpCreate()创建队列,供后续调用。(2)tpClearDIOs() 如果需要改变的数字IO的存放队列,该函数将会清除之前的IO触发器队列供下次使用。(3)tpClear() 某种程度而言,该函数属于“软件初始化”,结构体TP_STRUCT中的参数将会被保留下来,而队列将会被清空。(4)tpInit(),初始化TP结构体中的参数值。(5)tpSetCycleTime(),设置程序循环时间。(6)tpSetVmax()设置最大速度。(7)tpSetVlimit()/ tpSetAmax() 同上,设置速度限制以及最大速度。(8)tpSetId()/tpGetExecId() 分别设置下一个运行周期的ID号,或获取当前的ID号。(9)pSetTermCond(tp, cond) 设置后续运动队列移动的终止条件,返回终止条件和公差。(10)tpSetPos()设置当前位置以及目标位置。备注:(4-10)所返回的参数值都是TP结构的成员,可以理解为TP中都是当前运动模式下的参数值。(11)tpAddRigidTap()/ tpAddLine()/tpAddCircle() 这三个函数是用于判断在原有

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 单元课程

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com