欢迎来到得力文库 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
得力文库 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    LINUXCNC源程序原理说明.doc

    • 资源ID:809258       资源大小:77.79KB        全文页数:30页
    • 资源格式: DOC        下载积分:8金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要8金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    LINUXCNC源程序原理说明.doc

    ''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) | |- 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 motion 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 Ubuntu 5.10) | | |- etc | | | |- modprobe.d | | | |- udev | | | | |- rules.d | | | | - 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 | | | |- modprobe.d | | | |- udev | | | | |- rules.d | | | | - scripts | | | - xdg | | | - menus | | | - applications-merged | | - usr | | - share | | |- applications | | |- desktop-directories | | - pixmaps | |- extras-Ubuntu-7.10 (extra files for building on Ubuntu 7.10) | | |- etc | | | |- modprobe.d | | | |- udev | | | | - rules.d | | | - xdg | | | - menus | | | - applications-merged | | - usr | | - share | | |- applications | | |- desktop-directories | | - pixmaps | |- extras-Ubuntu-8.04 (extra files for building on Ubuntu 8.04 Hardy Heron) | | |- etc | | | |- modprobe.d | | | - xdg | | | - menus | | | - applications-merged | | - usr | | - share | | |- applications | | |- desktop-directories | | - pixmaps | |- extras-sim-Ubuntu-5.10 (extra files 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 | | - applications-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.) (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. 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(bash 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 | | - LC_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 (inifile 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 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 a unified interface across all hardware) | | |- classicladder | | | - projects_examples | | |- components | | |- drivers | | | |- m5i20 | | | | |- bit | | | | - hostmot5_src | | | |- mesa-hostmot2 | | | | |- doc | | | | - firmware | | | | |- 5i20 | | | | | - SOURCE | | | | - 7i43 | | | | |- CPLD | | | | | - SOURCE | | | | - 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 clean 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_intf | | | - axis | | | - extensions | | |- hal | | | |- classicladder | | | |- components | | | |- drivers | | | |- user_comps | | | | |- devices | | | | - vcp | | | - utils | | |- libnml | | | |- buffer | | | |- cms | | | |- inifile | | | |- linklist | | | |- nml | | | |- os_intf | | | |- posemath | | | - rcs | | |- rtapi | | |- 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, RTAI and sim) | | - examples (testing examples for the RTAPI) | | |- extint | | |- fifo | | |- semaphore | | |- shmem'' | | - timer | - tests |- tcl (tkemc.tcl, mini.tcl - the tcl GUI's) | |- bin | - scripts - tests|- abs.0|- and-or-not-mux.0|- basic|- ccomp| |- lathe-comp| |- mill-g90g91g92| |- mill-line-arc-entry| - mill-zchanges|- counter-encoder.0|- flipflop.0|- interp| |- cam-nisley| - flowsnake|- limit3.0|- limit3.1|- limit3.2|- modparam.0|- overrun|- oword| - sub.0|- save.0|- save.1|- source.0|- stepgen.0|- stepgen.1|- stepgen.2|- threads.0- timedelay.0Overview of the emc2 install dirs:/ (file system root)|- etc/| | - init.d/| | - 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, )| | |- 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)| | - 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/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 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: AXIS, 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/interp_return.hh“ #include “emc/nml_intf/canon.hh“ #include “emc/rs274ngc/interp_base.hh“ 其中包括了语法解析,读取,执行等函数,对刀具信息、主轴转速、开始、停止等信息进行判断和执行工作。(2)ini (inifile related operations,初始化相关的文件)同样,列出该文件夹的结构树: | |- ini (inifile related operations) | | |- emcIniFile.cc/hh | | |- iniaxis.cc/hh | | |- inihal.cc/hh | | |- initraj.cc/hh | | |- initool.cc /hh (2.1) emcIniFile.cc/hh '' #include / M_PI. #include “emcIniFile.hh“ 该文件定义了一些 INI 文件中字符的赋值,包括 一个 TURE 或者 FAULSE,单位 mm ,m,角度,直线,旋 转等等。 (2.2) iniaxis.cc/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 “emcglb.h“/ EMC_DEBUG #include “emccfg.h“/ default values for globals#include “inihal.hh“ 该文件主要用到了两个函数:loadaxis 以及 iniaxis。前一个函数 loadaixs 是对 INI 文件中的轴类型,轴单元, 最大最小位置限值,误差限值,最大速度,加速度,加加速度等初始化参数进行读取并存储在tcRunCycle(tp, tc, primary_after = tcGetPos(tc);pmCartCartSub(primary_after.tran, primary_before.tran, primary_displacement.a = primary_after.a - primary_before.a;primary_displacement.b = primary_after.b - primary_before.b;primary_displacement.c = primary_after.c - primary_before.c;primary_displacement.u = primary_after.u - primary_before.u;primary_displacement.v = primary_after.v - primary_before.v;primary_displacement.w = primary_after.w - primary_before.w; 调用之前的函数,计算当前值,然后运行一个周期,再次获取新的位置,然后分别计算各轴位移量。 下一步计算属于混合模式下(即将几段相似的程序进行合并)的运动控制:同样进行条件判断,之后计 算前后两段运动的速度,位移等等,最后输出前后两端的位移大小,实现合并。 (15)最后对一些错误信息进行判断和验证。保证正确输出。备注:在 tp.c 中轨迹规划是如何完成的: (1)解释调用tpAddLine还是tpAddCircle?主要是依据 MDI 或者 G 代码的输入; (2)tpRunCycle 在每一个 TRAJ_PERIOD 周期内进行调用,从而更新 currentPos; (3)currentPos 最终反馈回 HAL 对应的是 axis.X.motor-pos-cmd HAL pins。在 tpruncycle 中: 判断 tc 队列是否为空,if(!tc);运动队列为空就表示已经到了程序的终点或者说队列处于饥饿状态, 需要存入数据: 此时,采取以下动作:(1)初始化一个空的运动队列;(2)通过 tp->goalPos = tp->currentPos and tp->done = 1 来终止机器的动作;(3)调用 tpResume(tp)然后等待队列 tc 中写入东西。 判断是否有异常终止信息 if(tp->aborting); 此时,采取以下动作:(1) 将当前的速度设置为 0;(2)通过 tp->goalPos = tp->currentPos and tp- >done = 1 来终止机器的动作; 判断是否当前命令行执行完毕 if (tc->target = tc->progress): 此时,采取以下动作:(1) 将当前的命令行从队列中删除;(2)将下一个命令载入到队列中。(4.3)cubic.c 三次样条插值(5)MotionMotion 部分主要是(5.1)command.c'' #include #include #include “posemath.h“ #include “rtapi.h“ #include “hal.h“ #include “motion.h“ #include “motion_debug.h“ #include “motion_struct.h“ #include “emcmotglb.h“ #include “mot_priv.h“ #include “rtapi_math.h“ #include “motion_types.h“ 该函数主要是通过用户空间获取命令,执行不同的动作,这些命令结构体为 emcmotCommand- >command,而全部动作值都保存为 EMCMOT_COMMAND 在 motion.h 中。 如果想要进行添加新的信号参数,你就需要做以下的工作: (1)在 motion.h 中添加新的配置或者轴参数'foo'。 (2)在 motion.h 中添加'EMCMOT_SET_FOO“命令,在 cmd_code_t 中。 (3)在 command_t struct 中添加一个类 a field (4)在 command.c 中加一个大的选择开关从而控制'EMCMOT_SET_FOO' command。 (5)添加一个函数 emcSetFoo()在 taskintf.cc 中。 (6)在 emc.hh 中添加规范 emcSetFoo()。 (7)iniaxis.cc 或者 inixxx.cc 中加入代码从而获取 INI file 中的值,以及调用 emcSetFoo().注意,参量一 定不要重复。 (8)在 iniaxis.cc 中写入新值。 这说明你可以在 INI 文件中读取数据保存到共享内存,然后在运动控制器中调用。如果你想通过 NML 实现数据操作,还应该做以下: (9)定义#define EMC_SET_FOO_TYPE 在 emc.hh 中。 (10)定义一个类 EMC_SET_FOO 枣 emc.hh 中。 (11)在 emctaskmain.cc 中添加一个大的状态控制开关,从而在接收到 NML 信息之后调用 emcSetFoo()。(12)在 emc.cc,中添加两个与查找和设计新的命令相关的大的状态开关控制。好的,说完这些我们进行逐一介绍该函数的主程序。 (1)checkAllHomed(void) 根据名字就很好猜到,这是检查各轴是否处于原点。 (2)limits_ok()/jog_ok() 检查限位以及各轴是否准备好。 (3)refresh_jog_limits() 重新检查限位;如果是从原点开始的,则直接重新给限位赋值,如果不是, 则在原有位置信息的基础上加上限位大小; (4)inRange() 检查轴是否在限定范围内运行。如果是,返回非零值,如果超过,返回零。 (5)clearHomes() 清零回位标志位; (6)emcmotDioWrite()/emcmotAioWrite 用于管脚写入值,对于数字 IO,写入 0 或者 1;对于模拟 IO, 输出实际值。 (7)i

    注意事项

    本文(LINUXCNC源程序原理说明.doc)为本站会员(一***)主动上传,得力文库 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知得力文库 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于得利文库 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档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  

    收起
    展开