⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtcomps.lyx

📁 CNC 的开放码,EMC2 V2.2.8版
💻 LYX
📖 第 1 页 / 共 3 页
字号:
dirdelay\family default  are all rounded up to a integer multiple of the thread periond in nanoseconds. The other two functions can be called at a much lower rate.\layout Standard\begin_inset ERTstatus Collapsed\layout Standard\backslash clearpage\end_inset \layout Section\begin_inset LatexCommand \label{sec:PWMgen}\end_inset PWMgen\begin_inset LatexCommand \index{pwmgen}\end_inset \layout StandardThis component provides software based generation of PWM (Pulse Width Modulation) and PDM (Pulse Density Modulation) waveforms. It is a realtime component only, and depending on CPU speed, etc, is capable of PWM frequencies from a few hundred Hertz at pretty good resolution, to perhaps 10KHz with limited resolution.\layout SubsectionInstalling\layout LyX-Codeemc2$ \series bold halcmd loadrt pwmgen output_type=<config-array>\layout Standard\family typewriter <config-array>\family default  is a series of comma separated decimal integers. Each number causes a single PWM generator to be loaded, the value of the number determines the output type. For example:\layout LyX-Codeemc2$ \series bold halcmd loadrt pwmgen step_type=0,1,2\layout Standardwill install three PWM generators. The first one will use output type '0' (PWM only), the next uses output type 1 (PWM and direction) and the last one uses output type 2 (UP and DOWN). There is no default value, if \family typewriter <config-array>\family default  is not specified, no PWM generators will be installed. The maximum number of frequency generators is 8 (as defined by MAX_CHAN in pwmgen.c). Each generator is independent, but all are updated by the same function(s) at the same time. In the following descriptions, \family typewriter <chan>\family default  is the number of a specific generator. The first generator is number 0.\layout SubsectionRemoving\layout LyX-Codeemc2$ \series bold halcmd unloadrt pwmgen\layout SubsectionPins\layout StandardEach PWM generator will have the following pins:\layout Itemize\family typewriter \noun on (float)\noun default  pwmgen.<chan>.value\family default  -- Command value, in arbitrary units. Will be scaled by the \family typewriter scale\family default  parameter (see below).\layout Itemize\family typewriter \noun on (bit)\noun default  pwmgen.<chan>.enable\family default  -- Enables or disables the PWM generator outputs.\layout StandardEach PWM generator will also have some of these pins, depending on the output type selected:\layout Itemize\family typewriter \noun on (bit)\noun default  pwmgen.<chan>.pwm\family default  -- PWM (or PDM) output, (output types 0 and 1 only).\layout Itemize\family typewriter \noun on (bit)\noun default  pwmgen.<chan>.dir\family default  -- Direction output (output type 1 only).\layout Itemize\family typewriter \noun on (bit) \noun default pwmgen.<chan>.up\family default  -- PWM/PDM output for positive input value (output type 2 only).\layout Itemize\family typewriter \noun on (bit) \noun default pwmgen.<chan>.down\family default  -- PWM/PDM output for negative input value (output type 2 only).\layout SubsectionParameters\layout Itemize\family typewriter \noun on (float)\noun default  pwmgen.<chan>.scale\family default  -- Scaling factor to convert \family typewriter value\family default  from arbitrary units to duty cycle.\layout Itemize\family typewriter \noun on (float)\noun default  pwmgen.<chan>.pwm-freq\family default  -- Desired PWM frequency, in Hz. If 0.0, generates PDM instead of PWM. If set higher than internal limits, next call of \family typewriter update_freq()\family default  will set it to the internal limit. If non-zero, and \family typewriter dither\family default  is false, next call of \family typewriter update_freq()\family default  will set it to the nearest integer multiple of the \family typewriter make_pulses()\family default  function period.\layout Itemize\family typewriter \noun on (bit)\noun default  pwmgen.<chan>.dither-pwm\family default  -- If true, enables dithering to achieve average PWM frequencies or duty cycles that are unobtainable with pure PWM. If false, both the PWM frequency and the duty cycle will be rounded to values that can be achieved exactly.\layout Itemize\family typewriter \noun on (float)\noun default  pwmgen.<chan>.min-dc\family default  -- Minimum duty cycle, between 0.0 and 1.0 (duty cycle will go to zero when disabled, regardless of this setting).\layout Itemize\family typewriter \noun on (float)\noun default  pwmgen.<chan>.max-dc\family default  -- Maximum duty cycle, between 0.0 and 1.0.\layout Itemize\family typewriter \noun on (float)\noun default  pwmgen.<chan>.curr-dc\family default  -- Current duty cycle - after all limiting and rounding (read only).\layout SubsectionOutput Types\layout StandardThe PWM generator supports three different \begin_inset Quotes eld\end_inset output types\begin_inset Quotes erd\end_inset . Type 0 has a single output pin. Only positive commands are accepted, negative values are treated as zero (and will be affected by\family typewriter  min-dc\family default  if it is non-zero). Type 1 has two output pins, one for the PWM/PDM signal and one to indicate direction. The duty cycle on the PWM pin is based on the absolute value of the command, so negative values are acceptable. The direction pin is false for positive commands, and true for negative commands. Finally, type 2 also has two outputs, called up and down. For positive commands, the PWM signal appears on the up output, and the down output remains false. For negative commands, the PWM signal appears on the down output, and the up output remains false. Output type 2 is suitable for driving most H-bridges.\layout SubsectionFunctions\layout StandardThe component exports two functions. Each function acts on all of the PWM generators - running different generators in different threads is not supported. \layout Itemize\family typewriter \noun on (funct)\noun default  pwmgen.make-pulses\family default  -- High speed function to generate PWM waveforms (no floating point).\layout Itemize\family typewriter \noun on (funct)\noun default  pwmgen.update\family default  -- Low speed function to scale and limit value and handle other paremeters.\layout StandardThe high speed function \family typewriter pwmgen.make-pulses\family default  should be run in a very fast thread, from 10 to 50uS depending on the capabilities of the computer. That thread's period determines the maximum PWM carrier frequency, as well as the resolution of the PWM or PDM signals. The other function can be called at a much lower rate.\layout Standard\begin_inset ERTstatus Collapsed\layout Standard\backslash clearpage\end_inset \layout Section\begin_inset LatexCommand \label{sec:Encoder}\end_inset Encoder\begin_inset LatexCommand \index{encoder}\end_inset \layout StandardThis component provides software based counting of signals from quadrature encoders. It is a realtime component only, and depending on CPU speed, etc, is capable of maximum count rates of 10kHz to perhaps 50kHz. Figure \begin_inset LatexCommand \ref{fig:Encoder-Block-Diag}\end_inset  is a block diagram of one channel of encoder counter.\layout Standard\begin_inset Float figurewide falsecollapsed false\layout Standard\align center \begin_inset Graphics	filename encoder-block-diag.eps	width 7in	height 6in	keepAspectRatio\end_inset \layout Caption\begin_inset LatexCommand \label{fig:Encoder-Block-Diag}\end_inset Encoder Counter Block Diagram\end_inset \layout SubsectionInstalling\layout LyX-Codeemc2$ \series bold halcmd loadrt encoder [num_chan=<counters>]\layout Standard\family typewriter <counters>\family default  is the number of encoder counters that you want to install. If \family typewriter numchan\family default  is not specified, three counters will be installed. The maximum number of counters is 8 (as defined by MAX_CHAN in encoder.c). Each counter is independent, but all are updated by the same function(s) at the same time. In the following descriptions, \family typewriter <chan>\family default  is the number of a specific counter. The first counter is number 0.\layout SubsectionRemoving\layout LyX-Codeemc2$ \series bold halcmd unloadrt encoder\layout SubsectionPins\layout Itemize\family typewriter \noun on (bit)\noun default  encoder.<chan>.phase-A\family default  -- Phase A of the quadrature encoder signal.\layout Itemize\family typewriter \noun on (bit)\noun default  encoder.<chan>.phase-B\family default  -- Phase B of the quadrature encoder signal.\layout Itemize\family typewriter \noun on (bit)\noun default  encoder.<chan>.phase-Z\family default  -- Phase Z (index pulse) of the quadrature encoder signal.\layout Itemize\family typewriter \noun on (bit) \noun default encoder.<chan>.reset\family default  -- See canonical encoder interface, section \begin_inset LatexCommand \ref{sec:CanonEncoder}\end_inset .\layout Itemize\family typewriter \noun on (bit) \noun default encoder.<chan>.velocity\family default  -- Estimated speed of the quadrature signal. \layout Itemize\family typewriter \noun on (bit) \noun default encoder.<chan>.index-enable\family default  -- See canonical encoder interface.\layout Itemize\family typewriter \noun on (s32) \noun default encoder.<chan>.count\family default  -- See canonical encoder interface.\layout Itemize\family typewriter \noun on (float) \noun default encoder.<chan>.position\family default  -- See canonical encoder interface.\layout SubsectionParameters\layout Itemize\family typewriter \noun on (s32)\noun default  encoder.<chan>.raw-count\family default  -- The raw count value, updated by \family typewriter update-counters()\family default . \layout Itemize\family typewriter (\noun on bit\noun default ) encoder.<chan>.x4-mode\family default  -- Sets encoder to 4x or 1x mode. The 1x mode is usefull for some jogwheels.\layout Itemize\family typewriter \noun on (float)\noun default  encoder.<chan>.position-scale\family default  -- See canonical encoder interface, section \begin_inset LatexCommand \ref{sec:CanonEncoder}\end_inset . \layout SubsectionFunctions\layout StandardThe component exports two functions. Each function acts on all of the encoder counters - running different counters in different threads is not supported. \layout Itemize\family typewriter \noun on (funct)\noun default  encoder.update-counters\family default  -- High speed function to count pulses (no floating point).\layout Itemize\family typewriter \noun on (funct)\noun default  encoder.capture-position\family default  -- Low speed function to update latches and scale position.\layout Standard\begin_inset ERTstatus Collapsed\layout Standard\backslash clearpage\end_inset \layout Section\begin_inset LatexCommand \label{sec:PID}\end_inset PID\begin_inset LatexCommand \index{pid}\end_inset \layout StandardThis component provides Proportional/Integeral/Derivative control loops. It is a realtime component only. For simplicity, this discussion assumes that we are talking about position loops, however this component can be used to implement other feedback loops such as speed, torch height, temperature, etc. Figure \begin_inset LatexCommand \ref{fig:PID-block-diag}\end_inset  is a block diagram of a single PID loop.\layout Standard\begin_inset Float figurewide falsecollapsed false\layout Standard\align center \begin_inset Graphics	filename pid-block-diag.eps	width 8in	height 10in	keepAspectRatio	rotateAngle 90	rotateOrigin center\end_inset \layout Caption\begin_inset LatexCommand \label{fig:PID-block-diag}\end_inset PID Loop Block Diagram\end_inset \layout SubsectionInstalling\layout LyX-Codeemc2$ \series bold halcmd loadrt pid [num_chan=<loops>] [debug=1]\layout Standard\family typewriter <loops>\family default  is the number of PID loops that you want to install. If \family typewriter numchan\family default  is not specified, one loop will be installed. The maximum number of loops is 16 (as defined by MAX_CHAN in pid.c). Each loop is completely independent. In the following descriptions, \family typewriter <loopnum>\family default  is the loop number of a specific loop. The first loop is number 0.\layout StandardIf \family typewriter debug=1\family default  is specified, the component will export a few extra parameters that may be useful during debugging and tuning. By default, the extra parameters are not exported, to save shared memory space and avoid cluttering the parameter list.\layout SubsectionRemoving\layout LyX-Codeemc2$ \series bold halcmd unloadrt pid\layout SubsectionPins\layout StandardThe three most important pins are \layout Itemize\family typewriter \noun on (float) \noun default pid.<loopnum>.command\family default  -- The desired position, as commanded by another system component.\layout Itemize\family typewriter \noun on (float) \noun default pid.<loopnum>.feedback\family default  -- The present position, as measured by a feedback device such as an encoder.\layout Itemize\family typewriter \noun on (float) \noun default pid.<loopnum>.output\family default  -- A velocity command that attempts to move from the present position to the desired position. \layout StandardFor a position loop, 'command' and 'feedback' are in position units. For a linear axis, this could be inches, mm, meters, or whatever is relevant. Likewise, for an angular axis, it could be degrees, radians, etc. The units of the 'output' pin represent the change needed to make the feedback match the command. As such, for a position loop 'Output' is a velocity, in inches/sec, mm/sec, degrees/sec, etc. Time units are always seconds, and the velocity units match the position units. If command and feedback are in meters, then output is in meters per second. \layout StandardEach loop has two other pins which are used to monitor or control the general operation of the component. \layout Itemize\family typewriter \noun on (float) \noun default pid.<loopnum>.error\family default  -- Equals \family typewriter .command\family default  minus \family typewriter .feedback\family default .\layout Itemize\family typewriter \noun on (bit) \noun default pid.<loopnum>.enable\family default  -- A bit that enables the loop. If \family typewriter .enable\family default  is false, all integrators are reset, and the output is forced to zero. If \family typewriter .enable\family default  is true, the loop operates normally.\layout SubsectionParameters\layout StandardThe PID gains, limits, and other 'tunable' features of the loop are implemented as parameters. \layout Itemize\family typewriter \noun on (float)\noun default  pid.<loopnum>.Pgain\family default  -- Proportional gain \layout Itemize\family typewriter \noun on (float)\noun default  pid.<loopnum>.Igain\family default  -- Integral gain \layout Itemize\family typewriter \noun on (float)\noun default  pid.<loopnum>.Dgain\family default  -- Derivative gain \layout Itemize\family typewriter \noun on (float)\noun default  pid.<loopnum>.bias\family default  -- Constant offset on output \layout Itemize

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -