📄 rtcomps.lyx
字号:
#LyX 1.3 created this file. For more info see http://www.lyx.org/\lyxformat 221\textclass book\begin_preamble\usepackage[plainpages=false,pdfpagelabels,colorlinks=true,linkcolor=blue]{hyperref}\end_preamble\language english\inputencoding default\fontscheme bookman\graphics default\float_placement !htbp\paperfontsize default\spacing single \papersize letterpaper\paperpackage a4\use_geometry 1\use_amsmath 0\use_natbib 0\use_numerical_citations 0\paperorientation portrait\leftmargin 1in\topmargin 1in\rightmargin 0.8in\bottommargin 0.8in\secnumdepth 1\tocdepth 5\paragraph_separation skip\defskip smallskip\quotes_language english\quotes_times 2\papercolumns 1\papersides 1\paperpagestyle default\layout Chapter\begin_inset LatexCommand \label{cha:Internal-Components}\end_inset Internal Components\layout StandardMost components have unix-style manual pages. To view manual pages for real-time components, type \begin_inset Quotes eld\end_inset man 9 \emph on componentname\emph default \begin_inset Quotes erd\end_inset at the terminal prompt.\layout StandardThis document focuses on more complicated components which have figures which are hard to reproduce in the manual page format.\layout Section\begin_inset LatexCommand \label{sec:Stepgen}\end_inset Stepgen\begin_inset LatexCommand \index{stepgen}\end_inset \layout StandardThis component provides software based generation of step pulses in response to position or velocity commands. In position mode, it has a built in pre-tuned position loop, so PID tuning is not required. In velocity mode, it drives a motor at the commanded speed, while obeying velocity and acceleration limits. It is a realtime component only, and depending on CPU speed, etc, is capable of maximum step rates of 10kHz to perhaps 50kHz. Figure \begin_inset LatexCommand \ref{fig:Stepgen-Block-Diag}\end_inset shows three block diagrams, each is a single step pulse generator. The first diagram is for step type '0', (step and direction). The second is for step type '1' (up/down, or pseudo-PWM), and the third is for step types 2 through 14 (various stepping patterns). The first two diagrams show position mode control, and the third one shows velocity mode. Control mode and step type are set independently, and any combination can be selected.\layout Standard\begin_inset Float figurewide falsecollapsed false\layout Standard\align center \begin_inset Graphics filename stepgen-block-diag.eps width 7.5in height 8.5in keepAspectRatio clip\end_inset \layout Caption\begin_inset LatexCommand \label{fig:Stepgen-Block-Diag}\end_inset Step Pulse Generator Block Diagram (position mode)\end_inset \layout Standard\begin_inset Float figurewide falsecollapsed false\layout Standard\align center \begin_inset Graphics filename freqgen-block-diag.eps width 7.5in height 8.5in keepAspectRatio clip\end_inset \layout Caption\begin_inset LatexCommand \label{fig:Freqgen-Block-Diag}\end_inset Step Pulse Generator Block Diagram (velocity mode)\end_inset \layout SubsectionInstalling\layout LyX-Codeemc2$ \series bold halcmd loadrt stepgen step_type=<type-array> [ctrl_type=<ctrl_array>]\layout Standard\family typewriter <type-array>\family default is a series of comma separated decimal integers. Each number causes a single step pulse generator to be loaded, the value of the number determines the stepping type. \family typewriter <ctrl_array>\family default is a comma separated series of \begin_inset Quotes eld\end_inset \family typewriter \series bold p\family default \series default \begin_inset Quotes erd\end_inset or \begin_inset Quotes eld\end_inset \family typewriter \series bold v\family default \series default \begin_inset Quotes erd\end_inset characters, to specify position or velocity mode. \family typewriter \series bold ctrl_type\family default \series default is optional, if ommitted, all of the step generators will be position mode. For example:\layout LyX-Codeemc2# \series bold halcmd loadrt stepgen.o step_type=0,0,2 ctrl_type=p,p,v\layout Standardwill install three step generators. The first two use step type '0' (step and direction) and run in position mode. The last one uses step type '2' (quadrature) and runs in velocity mode. The default value for \family typewriter <config-array>\family default is \family typewriter \begin_inset Quotes eld\end_inset 0,0,0\begin_inset Quotes erd\end_inset \family default which will install three type '0' (step/dir) generators. The maximum number of step generators is 8 (as defined by MAX_CHAN in stepgen.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 stepgen\layout SubsectionPins\layout StandardEach step pulse generator will have only some of these pins, depending on the step type and control type selected.\layout Itemize\family typewriter \noun on (float)\noun default stepgen.<chan>.position-cmd\family default -- Desired motor position, in position units (position mode only).\layout Itemize\family typewriter \noun on (float)\noun default stepgen.<chan>.velocity-cmd\family default -- Desired motor velocity, in position units per second (velocity mode only).\layout Itemize\family typewriter \noun on (s32) \noun default stepgen.<chan>.counts\family default -- Feedback position in counts, updated by \family typewriter capture_position()\family default .\layout Itemize\family typewriter \noun on (float) \noun default stepgen.<chan>.position-fb\family default -- Feedback position in position units, updated by \family typewriter capture_position()\family default .\layout Itemize\family typewriter \noun on (bit)\noun default stepgen.<chan>.step\family default -- Step pulse output (step type 0 only).\layout Itemize\family typewriter \noun on (bit)\noun default stepgen.<chan>.dir\family default -- Direction output (step type 0 only).\layout Itemize\family typewriter \noun on (bit) \noun default stepgen.<chan>.up\family default -- UP pseudo-PWM output (step type 1 only).\layout Itemize\family typewriter \noun on (bit) \noun default stepgen.<chan>.down\family default -- DOWN pseudo-PWM output (step type 1 only).\layout Itemize\family typewriter \noun on (bit) \noun default stepgen.<chan>.phase-A\family default -- Phase A output (step types 2-14 only).\layout Itemize\family typewriter \noun on (bit) \noun default stepgen.<chan>.phase-B\family default -- Phase B output (step types 2-14 only).\layout Itemize\family typewriter \noun on (bit) \noun default stepgen.<chan>.phase-C\family default -- Phase C output (step types 3-14 only).\layout Itemize\family typewriter \noun on (bit) \noun default stepgen.<chan>.phase-D\family default -- Phase D output (step types 5-14 only).\layout Itemize\family typewriter \noun on (bit) \noun default stepgen.<chan>.phase-E\family default -- Phase E output (step types 11-14 only).\layout SubsectionParameters\layout Itemize\family typewriter \noun on (float)\noun default stepgen.<chan>.position-scale\family default -- Steps per position unit. This parameter is used for both output and feedback.\layout Itemize\family typewriter \noun on (float)\noun default stepgen.<chan>.maxvel\family default -- Maximum velocity, in position units per second. If 0.0, has no effect.\layout Itemize\family typewriter \noun on (float)\noun default stepgen.<chan>.maxaccel\family default -- Maximum accel/decel rate, in positions units per second squared. If 0.0, has no effect.\layout Itemize\family typewriter \noun on (float)\noun default stepgen.<chan>.frequency\family default -- The current step rate, in steps per second.\layout Itemize\family typewriter \noun on (float)\noun default stepgen.<chan>.steplen\family default -- Length of a step pulse (step type 0 and 1) or minimum time in a given state (step types 2-14), in nano-seconds.\layout Itemize\family typewriter \noun on (float)\noun default stepgen.<chan>.stepspace\family default -- Minimum spacing between two step pulses (step types 0 and 1 only), in nano-seconds.\layout Itemize\family typewriter \noun on (float)\noun default stepgen.<chan>.dirsetup\family default -- Minimum time from a direction change to the beginning of the next step pulse (step type 0 only), in nanoseconds.\layout Itemize\family typewriter \noun on (float)\noun default stepgen.<chan>.dirhold\family default -- Minmum time from the end of a step pulse to a direction change (step type 0 only), in nanoseconds.\layout Itemize\family typewriter \noun on (float)\noun default stepgen.<chan>.dirdelay\family default -- Minmum time any step to a step in the opposite direction (step types 1-14 only), in nano-seconds.\layout Itemize\family typewriter \noun on (s32)\noun default stepgen.<chan>.rawcounts\family default -- The raw feedback count, updated by \family typewriter make_pulses()\family default . \layout StandardIn position mode, the values of maxvel and maxaccel are used by the internal position loop to avoid generating step pulse trains that the motor cannot follow. When set to values that are appropriate for the motor, even a large instantaneous change in commanded position will result in a smooth trapezoidal move to the new location. The algorithm works by measuring both position error and velocity error, and calculating an acceleration that attempts to reduce both to zero at the same time. For more details, including the contents of the \begin_inset Quotes eld\end_inset control equation\begin_inset Quotes erd\end_inset box, consult the code.\layout StandardIn velocity mode, maxvel is a simple limit that is applied to the commanded velocity, and maxaccel is used to ramp the actual frequency if the commanded velocity changes abruptly. As in position mode, proper values for these parameters ensure that the motor can follow the generated pulse train.\layout Subsection\begin_inset LatexCommand \label{sub:Stepgen-Step-Types}\end_inset Step Types\layout StandardThe step generator supports 15 different \begin_inset Quotes eld\end_inset step types\begin_inset Quotes erd\end_inset . Step type 0 is the most familiar, standard step and direction. When configured for step type 0, there are four extra parameters that determine the exact timing of the step and direction signals. See figure \begin_inset LatexCommand \ref{fig:StepDir-timing}\end_inset for the meaning of these parameters. The parameters are in nanoseconds, but will be rounded up to an integer multiple of the thread period for the threaed that calls \family typewriter make_pulses()\family default . For example, if \family typewriter make_pulses()\family default is called every 16uS, and steplen is 20000, then the step pulses will be 2 x 16 = 32uS long. The default value for all four of the parameters is 1nS, but the automatic rounding takes effect the first time the code runs. Since one step requires \family typewriter steplen\family default nS high and \family typewriter stepspace\family default nS low, the maximum frequency is 1,000,000,000 divided by \family typewriter (steplen+stepspace)\family default . If \family typewriter maxfreq\family default is set higher than that limit, it will be lowered automatically. If maxfreq is zero, it will remain zero, but the output frequency will still be limited.\layout Standard\begin_inset Float figurewide falsecollapsed false\layout Standard\align center \begin_inset Graphics filename stepgen-type0.eps width 7in height 4in keepAspectRatio\end_inset \layout Caption\begin_inset LatexCommand \label{fig:StepDir-timing}\end_inset Step and Direction Timing\end_inset \layout StandardStep type 1 has two outputs, up and down. Pulses appear on one or the other, depending on the direction of travel. Each pulse is \family typewriter steplen\family default nS long, and the pulses are separated by at least \family typewriter stepspace\family default nS. The maximum frequency is the same as for step type 0. If \family typewriter maxfreq\family default is set higher than the limit it will be lowered. If \family typewriter maxfreq\family default is zero, it will remain zero but the output frequency will still be limited. \layout StandardStep types 2 through 14 are state based, and have from two to five outputs. On each step, a state counter is incremented or decremented. Figures \begin_inset LatexCommand \ref{fig:Quad-Three-Phase}\end_inset , \begin_inset LatexCommand \ref{fig:Four-Phase}\end_inset , and \begin_inset LatexCommand \ref{fig:Five-Phase}\end_inset show the output patterns as a function of the state counter. The maximum frequency is 1,000,000,000 divided by \family typewriter steplen\family default , and as in the other modes, \family typewriter maxfreq\family default will be lowered if it is above the limit.\layout Standard\begin_inset Float figurewide falsecollapsed false\layout Standard\align center \begin_inset Graphics filename stepgen-type2-4.eps width 7.5in height 8.5in keepAspectRatio rotateAngle 90\end_inset \layout CaptionThree-Phase step types\begin_inset LatexCommand \label{fig:Quad-Three-Phase}\end_inset \end_inset \layout Standard\begin_inset Float figurewide falsecollapsed false\layout Standard\align center \begin_inset Graphics filename stepgen-type5-10.eps width 7.5in height 8.5in keepAspectRatio rotateAngle 90\end_inset \layout Caption\begin_inset LatexCommand \label{fig:Four-Phase}\end_inset Four-Phase Step Types\end_inset \layout Standard\begin_inset Float figurewide falsecollapsed false\layout Standard\align center \begin_inset Graphics filename stepgen-type11-14.eps width 7.5in height 8.5in keepAspectRatio\end_inset \layout Caption\begin_inset LatexCommand \label{fig:Five-Phase}\end_inset Five-Phase Step Types\end_inset \layout SubsectionFunctions\layout StandardThe component exports three functions. Each function acts on all of the step pulse generators - running different generators in different threads is not supported. \layout Itemize\family typewriter \noun on (funct)\noun default stepgen.make-pulses\family default -- High speed function to generate and count pulses (no floating point).\layout Itemize\family typewriter \noun on (funct)\noun default stepgen.update-freq\family default -- Low speed function does position to velocity conversion, scaling and limiting.\layout Itemize\family typewriter \noun on (funct)\noun default stepgen.capture-position\family default -- Low speed function for feedback, updates latches and scales position.\layout StandardThe high speed function \family typewriter stepgen.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 step frequency, since \family typewriter steplen\family default , \family typewriter stepspace\family default , \family typewriter dirsetup\family default , \family typewriter dirhold\family default , and \family typewriter
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -