📄 intro.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:Introduction}\end_inset Introduction\layout Section\begin_inset LatexCommand \label{sec:What-is-HAL?}\end_inset What is HAL?\layout StandardHAL\begin_inset LatexCommand \index{HAL}\end_inset stands for Hardware Abstraction Layer. At the highest level, it is simply a way to allow a number of \begin_inset Quotes eld\end_inset building blocks\begin_inset Quotes erd\end_inset to be loaded and interconnected to assemble a complex system. The \begin_inset Quotes eld\end_inset Hardware\begin_inset Quotes erd\end_inset part is because HAL was originally designed to make it easier to configure EMC for a wide variety of hardware devices. Many of the building blocks are drivers for hardware devices. However, HAL can do more than just configure hardware drivers.\layout SubsectionHAL is based on traditional system design techniques\layout StandardHAL is based on the same principles that are used to design hardware circuits and systems, so it is useful to examine those principles first.\layout StandardAny system (including a CNC\begin_inset LatexCommand \index{CNC}\end_inset machine), consists of interconnected components. For the CNC machine, those components might be the main controller, servo amps or stepper drives, motors, encoders, limit switches, pushbutton pendants, perhaps a VFD for the spindle drive, a PLC to run a toolchanger, etc. The machine builder must select, mount and wire these pieces together to make a complete system.\layout SubsubsectionPart Selection\layout StandardThe machine builder does not need to worry about how each individual part works. He treats them as black boxes. During the design stage, he decides which parts he is going to use - steppers or servos, which brand of servo amp, what kind of limit switches and how many, etc. The integrator's decisions about which specific components to use is based on what that component does and the specifications supplied by the manufacturer of the device. The size of a motor and the load it must drive will affect the choice of amplifier needed to run it. The choice of amplifier may affect the kinds of feedback needed by the amp and the velocity or position signals that must be sent to the amp from a control. \layout StandardIn the HAL world, the integrator must decide what HAL components are needed. Usually every interface card will require a driver. Additional components may be needed for software generation of step pulses, PLC functionality, and a wide variety of other tasks.\layout SubsubsectionInterconnection Design\layout StandardThe designer of a hardware system not only selects the parts, he also decides how those parts will be interconnected. Each black box has terminals, perhaps only two for a simple switch, or dozens for a servo drive or PLC. They need to be wired together. The motors connect to the servo amps, the limit switches connect to the controller, and so on. As the machine builder works on the design, he creates a large wiring diagram that shows how all the parts should be interconnected.\layout StandardWhen using HAL, components are interconnected by signals. The designer must decide which signals are needed, and what they should connect.\layout SubsubsectionImplementation\layout StandardOnce the wiring diagram is complete it is time to build the machine. The pieces need to be acquired and mounted, and then they are interconnected according to the wiring diagram. In a physical system, each interconnection is a piece of wire that needs to be cut and connected to the appropriate terminals.\layout StandardHAL provides a number of tools to help \begin_inset Quotes eld\end_inset build\begin_inset Quotes erd\end_inset a HAL system. Some of the tools allow you to \begin_inset Quotes eld\end_inset connect\begin_inset Quotes erd\end_inset (or disconnect) a single \begin_inset Quotes eld\end_inset wire\begin_inset Quotes erd\end_inset . Other tools allow you to save a complete list of all the parts, wires, and other information about the system, so that it can be \begin_inset Quotes eld\end_inset rebuilt\begin_inset Quotes erd\end_inset with a single command.\layout SubsubsectionTesting\layout StandardVery few machines work right the first time. While testing, the builder may use a meter to see whether a limit switch is working or to measure the DC voltage going to a servo motor. He may hook up an oscilloscope to check the tuning of a drive, or to look for electrical noise. He may find a problem that requires the wiring diagram to be changed; perhaps a part needs to be connected differently or replaced with something completely different.\layout StandardHAL provides the software equivalents of a voltmeter, oscilloscope, signal generator, and other tools needed for testing and tuning a system. The same commands used to build the system can be used to make changes as needed.\layout SubsectionSummary\layout StandardThis document is aimed at people who already know how to do this kind of hardware system integration, but who do not know how to connect the hardware to EMC.\layout StandardThe traditional hardware design as described above ends at the edge of the main control. Outside the control are a bunch of relatively simple boxes, connected together to do whatever is needed. Inside, the control is a big mystery -- one huge black box that we hope works.\layout StandardHAL extends this traditional hardware design method to the inside of the big black box. It makes device drivers and even some internal parts of the controller into smaller black boxes that can be interconnected and even replaced just like the external hardware. It allows the \begin_inset Quotes eld\end_inset system wiring diagram\begin_inset Quotes erd\end_inset to show part of the internal controller, rather than just a big black box. And most importantly it allows the integrator to test and modify the controller using the same methods he would use on the rest of the hardware.\layout StandardTerms like motors, amps, and encoders are familiar to most machine integrators. When we talk about using extra flexible eight conductor shielded cable to connect an encoder to the servo input board in the computer, the reader immediately understands what it is and is led to the question, \begin_inset Quotes eld\end_inset what kinds of connectors will I need to make up each end.\begin_inset Quotes erd\end_inset The same sort of thinking is essential for the HAL but the specific train of thought may take a bit to get on track. Using HAL words may seem a bit strange at first, but the concept of working from one connection to the next is the same.\layout StandardThis idea of extending the wiring diagram to the inside of the controller is what HAL is all about. If you are comfortable with the idea of interconnecting hardware black boxes, you will probably have little trouble using HAL to interconnect software black boxes.\layout Section\begin_inset LatexCommand \label{sec:HAL-Concepts}\end_inset HAL Concepts\layout StandardThis section is a glossary that defines key HAL terms but it is a bit different than a traditional glossary because these terms are not arranged in alphabetical order. They are arranged by their relationship or flow in the HAL way of things. \layout DescriptionComponent\begin_inset LatexCommand \index{HAL Component}\end_inset : When we talked about hardware design, we referred to the individual pieces as "parts", "building blocks", "black boxes", etc. The HAL equivalent is a "component" or "HAL component". (This document uses "HAL component" when there is likely to be confusion with other kinds of components, but normally just uses "component".) A HAL component is a piece of software with well-defined inputs, outputs, and behavior, that can be installed and interconnected as needed. \layout DescriptionParameter\begin_inset LatexCommand \index{HAL Parameter}\end_inset : Many hardware components have adjustments that are not connected to any other components but still need to be accessed. For example, servo amps often have trim pots to allow for tuning adjustments, and test points where a meter or scope can be attached to view the tuning results. HAL components also can have such items, which are referred to as "parameters". There are two types of parameters: Input parameters are equivalent to trim pots - they are values that can be adjusted by the user, and remain fixed once they are set. Output parameters cannot be adjusted by the user - they are equivalent to test points that allow internal signals to be monitored.\layout DescriptionPin\begin_inset LatexCommand \index{HAL Pin}\end_inset : Hardware components have terminals which are used to interconnect them. The HAL equivalent is a "pin" or "HAL pin". ("HAL pin" is used when needed to avoid confusion.) All HAL pins are named, and the pin names are used when interconnecting them. HAL pins are software entities that exist only inside the computer. \layout DescriptionPhysical_Pin\begin_inset LatexCommand \index{HAL Physical-Pin}\end_inset : Many I/O devices have real physical pins or terminals that connect to external hardware, for example the pins of a parallel port connector. To avoid confusion, these are referred to as "physical pins". These are the things that \begin_inset Quotes eld\end_inset stick out\begin_inset Quotes erd\end_inset into the real world.\begin_inset Notecollapsed true\layout StandardMight need some explanation how HAL_pins and Physical pin relates to something like an encoder chip or an stg card. We are dealing in data type interface and data type translation/conversion here. \end_inset \layout DescriptionSignal\begin_inset LatexCommand \index{HAL Signal}\end_inset : In a physical machine, the terminals of real hardware components are interconnected by wires. The HAL equivalent of a wire is a "signal" or "HAL signal". HAL signals connect HAL pins together as required by the machine builder. HAL signals can be disconnected and reconnected at will (even while the machine is running).\layout DescriptionType\begin_inset LatexCommand \index{HAL Type}\end_inset : When using real hardware, you would not connect a 24 volt relay output to the +/-10V analog input of a servo amp. HAL pins have the same restrictions, which are based upon their type. Both pins and signals have types, and signals can only be connected to pins of the same type. Currently there are 4 types, as follows:\layout Itemize\noun on bit\noun default - a single TRUE/FALSE or ON/OFF value\layout Itemize\noun on float\noun default - a 32 bit floating point value, with approximately 24 bits of resolution and over 200 bits of dynamic range.\layout Itemize\noun on u32\noun default - a 32 bit unsigned integer, legal values are 0 to +4294967295\layout Itemize\noun on s32\noun default - a 32 bit signed integer, legal values are -2147483648 to +2147483647\layout Description\begin_inset LatexCommand \label{des:Function}\end_inset Function\begin_inset LatexCommand \index{HAL Function}\end_inset : Real hardware components tend to act immediately on their inputs. For example, if the input voltage to a servo amp changes, the output also changes automatically. However software components cannot act "automatically". Each component has specific code that must be executed to do whatever that component is supposed to do. In some cases, that code simply runs as part of the component. However in most cases, especially in realtime components, the code must run in a specific sequence and at specific intervals. For example, inputs should be read before calculations are performed on the input data, and outputs should not be written until the calculations are done. In these cases, the code is made available to the system in the form of one or more "functions". Each function is a block of code that performs a specific action. The system integrator can use "threads" to schedule a series of functions to be executed in a particular order and at specific time intervals.\layout Description\begin_inset LatexCommand \label{des:Thread}\end_inset Thread\begin_inset LatexCommand \index{HAL Thread}\end_inset : A "thread" is a list of functions that runs at specific intervals as part of a realtime task. When a thread is first created, it has a specific time interval (period), but no functions. Functions can be added to the thread, and will be executed in order every time the thread runs.\layout StandardAs an example, suppose we have a parport component named hal_parport. That component defines one or more HAL pins for each physical pin. The pins are described in that component's doc section: their names, how each pin relates to the physical pin, are they inverted, can you change polarity, etc. But that alone doesn't get the data from the HAL pins to the physical pins. It takes code to do that, and that is where functions come into the picture. The parport component needs at least two functions: one to read the physical input pins and update the HAL pins, the other to take data from the HAL pins and write it to the physical output pins. Both of these functions are part of the parport driver. \layout Section\begin_inset LatexCommand \label{sec:Intro-HAL-components}\end_inset HAL components\layout StandardEach HAL component is a piece of software with well-defined inputs, outputs, and behavior, that can be installed and interconnected as needed. This section lists some of the available components and a brief description of what each does. Complete details for each component are available later in this document.\layout Subsection\begin_inset LatexCommand \label{sub:ExternalPrograms}\end_inset External Programs with HAL hooks\layout Descriptionmotion\begin_inset LatexCommand \index{motion}\end_inset A realtime module that accepts NML motion commands and interacts with HAL \layout Description
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -