LINUXCNC源程序原理说明.docx

上传人:b****5 文档编号:8403923 上传时间:2023-01-31 格式:DOCX 页数:38 大小:73.31KB
下载 相关 举报
LINUXCNC源程序原理说明.docx_第1页
第1页 / 共38页
LINUXCNC源程序原理说明.docx_第2页
第2页 / 共38页
LINUXCNC源程序原理说明.docx_第3页
第3页 / 共38页
LINUXCNC源程序原理说明.docx_第4页
第4页 / 共38页
LINUXCNC源程序原理说明.docx_第5页
第5页 / 共38页
点击查看更多>>
下载资源
资源描述

LINUXCNC源程序原理说明.docx

《LINUXCNC源程序原理说明.docx》由会员分享,可在线阅读,更多相关《LINUXCNC源程序原理说明.docx(38页珍藏版)》请在冰豆网上搜索。

LINUXCNC源程序原理说明.docx

LINUXCNC源程序原理说明

LINUXCNC源程序原理说明

opLINUXCNC源程序学习

源程序的树结构如下:

Overviewoftheemc2directory(generatedbytree-I.git-d):

.

|--app-defaults

|--bin(usermodebinaries)

|--configs

||--5axis

||--boss

||--common

||--dallur-thc

||--demo_mazak(samplemazakconfigfiles)

||--demo_sim_cl(samplesimwithladderIO)

||--demo_step_cl(samplestepperwithladderIO)

||--etch-servo

||--halui_halvcp

||--hexapod-sim

||--lathe-pluto

||--m5i20(sampleservousingMesaPCI)

||--max

||--motenc(sampleservousingVitalPCI)

||--nist-lathe

||--plasma-thc

||--plasma-thc-sim

||--ppmc

||--puma

||--scara

||--sim(simulatedmotionandIO)

||--stepper(parportstepperdriver)

||--stepper-gantry

||--stepper-xyza

||--stg(sampleservousingSTGISA)

||--univpwm(samplePICOservogenerator)

||--univstep(samplePICOsteppergenerator)

|`--vti

|--debian(filesneededtobuilddebpackages)

||--extras-Ubuntu-5.10(extrafilesforUbuntu5.10)

|||--etc

||||--modprobe.d

||||--udev

|||||--rules.d

||||`--scripts

|||`--xdg

|||`--menus

|||`--applications-merged

||`--usr

||`--share

|||--applications

|||--desktop-directories

||`--pixmaps

||--extras-Ubuntu-6.06(extrafilesforbuildingonUbuntu6.06DapperDrake)

|||--etc

||||--modprobe.d

||||--udev

|||||--rules.d

||||`--scripts

|||`--xdg

|||`--menus

|||`--applications-merged

||`--usr

||`--share

|||--applications

|||--desktop-directories

||`--pixmaps

||--extras-Ubuntu-7.10(extrafilesforbuildingonUbuntu7.10)

|||--etc

||||--modprobe.d

||||--udev

||||`--rules.d

|||`--xdg

|||`--menus

|||`--applications-merged

||`--usr

||`--share

|||--applications

|||--desktop-directories

||`--pixmaps

||--extras-Ubuntu-8.04(extrafilesforbuildingonUbuntu8.04HardyHeron)

|||--etc

||||--modprobe.d

|||`--xdg

|||`--menus

|||`--applications-merged

||`--usr

||`--share

|||--applications

|||--desktop-directories

||`--pixmaps

||--extras-sim-Ubuntu-5.10(extrafilesforsimpackageforUbuntu5.10)

|||--etc

|||`--xdg

|||`--menus

|||`--applications-merged

||`--usr

||||--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(acleanimplementationofRCSLIB)

|||--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(Translationfilesfori18nsupport)

||--rtapi(*.cand*.hforRTAPI)(unifiedRTAPI,wrapsoverRTLinux,RTAIandsim)

||`--examples(testingexamplesfortheRTAPI)

|||--extint

|||--fifo

|||--semaphore

|||--shmem

||`--timer

|`--tests

|--tcl(tkemc.tcl,mini.tcl-thetclGUI'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.0

 

Overviewoftheemc2installdirs:

/(filesystemroot)

|

|

|---etc/

||

|\---init.d/

||

|\---realtime(realtimestart/stopscript)

|

|

|---$(prefix)(default:

/usr/local)

||(allthefollowing$xxxxdirareconfigurablethroughautoconf

||

||---bin/(knownas$bindir,filesfromEMC2/bin)

||

||---sbin/(knownas$sbindir,)

||

||---etc/(knownas$sysconfdir,configfilesandsubdirsfromconfigs/)

||

||---lib/(knownas$libdir,libfiles*.sofromlibs/)

||

|\---share/

||

|\---emc/

||

||

||---docs/

|||

||\---(AlltheimportantandrelevantDocs.)

||

||---handbooks/

|||

||\---(PDFversionsofhandbooks)

||

|\---nc_files/

||

|\---(SampleNCfiles)

|

|---$MAN_DIR/(default:

/usr/local/man)

||

||---man1/

|||

||

||

|\---man3/

||

|

|

\---$moduledir/(basedonwhere./configurefindstheRTOSmodules)

 

根据这个结构树,我们可以清楚的知道每一个文件夹,每一个子文件的作用,包括了接口,硬件抽象层,实时内核等等部分。

当然,在这里面我们需要深入研究的是linuxcnc-dev/src/emc文件夹中的各个文件,也是该数控系统的核心所在。

我们再次列出linuxcnc-dev/src/emc中的子结构树:

linuxcnc-dev/src/emc中的子结构树:

||--emc(actualLinuxCNCcode)

|||--canterp(interpreterforcanonicalcommands)

|||--ini(inifilerelatedoperations)

|||--iotask(IOinterface,lotsofHALpins)

|||--kinematics(trajectoryplannerandkinematics)

|||--motion(motioncontroller,talksthroughSHMtotherestofEMC)

|||--nml_intf(emcspecificNMLimplementation,allmessagessentinemc)

|||--rs274ngc(thers274g-codeinterpreter)

|||--sai

|||--task(corecomponentinemc,dispatchesactionstootherparts)

||`--usr_intf(interfacesforsomeGUIs,andotherinterfaces:

AXIS,halui,stepconf)

|||--axis

||||--etc

||||--extensions

|||`--scripts

||`--stepconf

根据该结构树,我们一个一个的再一次进行分析:

(1)canterp(interpreterforcanonicalcommands,即规范命令的解释器)

#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(inifilerelatedoperations,初始化相关的文件)

同样,列出该文件夹的结构树:

||--ini(inifilerelatedoperations)

|||--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"//thesedecls

#include"emcglb.h"//EMC_DEBUG

#include"emccfg.h"//defaultvaluesforglobals

#include"inihal.hh"

该文件主要用到了两个函数:

loadaxis以及iniaxis。

前一个函数loadaixs是对INI文件中的轴类型,轴单元,最大最小位置限值,误差限值,最大速度,加速度,加加速度等初始化参数进行读取并存储在&axisIniFile中,这些参数对应于INI文件中[AXIS]一栏中的参数,并将部分参数赋值给old_inihal_data。

除此之外,iniaxis函数主要是读取INI文件中[TRAJ]部分的AXIS轴数,然后调用loadaxis进行初始化加载。

除去两个主要函数,还有一个精度判断函数iniGetFloatPrec以及状态函数(可有可无)。

 

(2.3)initraj.cc/hh

该文件主要包含以下几个函数:

loadTraj,用于加载INI文件中[TRAJ]中的配置参数,然后将读取的参数值进行保存,主要赋值给old_inihal_data以及traj_max_velocity等变量,供后续其他文件调用。

同时该文件的后面还有一个坐标轴返回原点的判断程序,从而保证[TRAJ]中的原点坐标。

其实,该文件类似于iniaxis.cc/hh。

(2.4)inihal.cc/hh

#include"rcs_print.hh"

#include"emc.hh"

#include

#include"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中的值都是在iniaxis.cc以及initraj.cc中赋值了的。

(3)iotask

该文件在这里不做详细介绍,主要是创建“iocontrol”组件,并对一些接口文件进行配置。

 

(4)Kinamitcs

该文件夹中包含了不同的运动控制模块,例如五轴、三轴、六轴等等。

除此之外,还包含了插补以及速度控制的轨迹规划文件。

(4.1)运动控制模块

(4.2)轨迹规划模块

TC.C文件——主要是基于轨迹规划的简单判别文件,由TP.C调用。

下面我们分别说明该文件中的一些函数。

#include"rtapi.h"/*rtapi_print_msg*/

#include"posemath.h"

#include"emcpos.h"

#include"tc.h"

(1)tcGetStartingUnitVector主要是获取运动轨迹的起始点的起始单位向量,如果是直线或者攻丝,那么直接计算起始与终止点的位移大小。

如果不是,那么就是圆形运动,计算曲率,半径,起始点等等。

(2)tcGetEndingUnitVector主要是获取运动轨迹的终止点的终止单位向量,如果是直线,那么直接计算终点坐标减去起点坐标的大小。

如果是攻丝,那么计算起点坐标减去终点坐标的大小。

对于其他运动,即曲线运动,则根据转过的角度,计算终点坐标,然后计算曲率半径,并将数据保存到指定位置V中。

(3)tcGetPos/tcGetEndpoint两个都是通过调用函数tcGetPosReal从而得到位置信息。

(4)tcGetPosReal根据传入的参数判断是计算当前位移值还是目标位移值;其次判断运动类型,如果是攻丝,判断是正转还是反转的,再进行坐标值计算(具体算法先省略)。

如果是直线运动,因为只是涉及到了xyz,其他轴uvw,abc等只需要进行配合运动即可,或者是XYZ不动,或者只有ABC再动等等。

如果是曲线运动,同样配合计算其他各轴位移。

判断完毕之后,返回各个轴的位移。

(5)tcqCreate()建立TC结构体的新队列。

(6)tcqDelete()删除TC结构体的队列。

(7)tcqInit

(8)tcqPut()/tcqRemove()/tcqLen()/tcqItem()数据存放,先入先出;tcqLen()数据队列的大小;tcqItem()读取数据队列的第N的元素。

(9)tcqFull()判断堆栈是否已满,或者快要满了。

TP.C文件——主要实现轨迹规划。

#ifdefRTAPI

#defineassert(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"

#

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 初中教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1