Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

LinuxCNC 入門簡介

7,486 views

Published on

Published in: Technology

LinuxCNC 入門簡介

  1. 1. LinuxCNC Overview DMP Electronics INC
  2. 2. Simple LinuxCNC Controlled Machine 2
  3. 3. OutLine      About the LinuxCNC Linux / RTAI LinuxCNC software LinuxCNC Hierarchical Configuring LinuxCNC 3
  4. 4. About the LinuxCNC    LinuxCNC is a descendent of the original NIST(The National Institutes of Standards and Technology) Enhanced Machine Controller software. LinuxCNC is precompiled with Ubuntu LTS (long term support) versions for ease of installation and longevity. LinuxCNC runs on Linux using real time extensions. 4
  5. 5. Linux / RTAI User Space 5
  6. 6. LinuxCNC software  System Requirements      700 MHz x86 processor (1.2 GHz x86 processor recommended). 384 MB of RAM (512 MB up to 1 GB recommended). 8 GB hard disk. Graphics card capable of at least 1024x768 resolution. A network or Internet connection (not strictly needed, but very useful for updates and for communicating with the LinuxCNC community). 6
  7. 7. LinuxCNC software  LinuxCNC provides:        a graphical user interface (actually several interfaces to choose from). an interpreter for G-code (the RS-274 machine tool programming language). a realtime motion planning system with look-ahead. operation of low-level machine electronics such as sensors and motor drives. an easy to use breadboard layer for quickly creating a unique configuration for your machine. a software PLC programmable with ladder diagrams easy installation with a Live-CD. 7
  8. 8. LinuxCNC - Axis GUI 8
  9. 9. LinuxCNC Hierarchical  Four main components to the LinuxCNC software:      a motion controller (EMCMOT) a discrete IO controller (EMCIO) a task executor which coordinates them (EMCTASK) and one of several graphical user interfaces In addition there is a layer called HAL (Hardware Abstraction Layer) which allows configuration of LinuxCNC without the need of recompiling. 9
  10. 10. GUI NML EMCTASK RS274 (G code) SEQUENCING INTERPRETER LOGIC NML Share memory Real time EMCMOT EMCIO HAL pins HAL pins Hardware Abstraction Layer (HAL) HAL pins HAL pins Real-time HWD Non-Real-time HWD 10
  11. 11. LinuxCNC Hierarchical  EMCTASK 基於EMC2的數控系統軟件架構及通信機制分析(2010) 11
  12. 12. LinuxCNC Hierarchical  EMCMOT 12
  13. 13. LinuxCNC Hierarchical  EMCIO  Be used to control some machine actions like lube, coolant, and spindle direction and speed 13
  14. 14. Configuring LinuxCNC      INI : The ini file overrides defaults that are compiled into the LinuxCNC code. HAL : The HAL files start up process modules and provide linkages between LinuxCNC signals and specific hardware pins. VAR : The var file is a way for the interpreter to save some values from one run to the next. These values are saved from one run to another but not always saved immediately. TBL : The tbl file saves tool information. NML : The nml file configures the communication channels used by the LinuxCNC. It is normally setup to run all of the communication within a single computer but can be modified to communicate between several computers. 14
  15. 15. Configuring LinuxCNC  The INI File Components     Comments Sections Variables Custom Sections and Variables Sections Comments Variables 15
  16. 16. Configuring LinuxCNC  Sections            [EMC] general information [DISPLAY] settings related to the graphical user interface [FILTER] settings input filter programs [RS274NGC] settings used by the g-code interpreter [EMCMOT] settings used by the real time motion controller [TASK] settings used by the task controller [HAL] specifies .hal files [HALUI] MDI commands used by HALUI [TRAJ] additional settings used by the real time motion controller [AXIS_n] individual axis variables [EMCIO] settings used by the I/O Controller Example 16
  17. 17. Configuring LinuxCNC  Hardware Abstraction Layer (HAL)         Component Parameter Pin Physical_Pin Signal Type Function Thread 17
  18. 18. Configuring LinuxCNC  Hardware Abstraction Layer (HAL)   Component  A HAL component is a piece of software with well-defined inputs, outputs, and behavior, that can be installed and interconnected as needed. Parameter  Many hardware components have adjustments that are not connected to any other components but still need to be accessed. There are two types of parameters: input & Output 18
  19. 19. Configuring LinuxCNC  Hardware Abstraction Layer (HAL)   Pin  Hardware components have terminals which are used to interconnect them. The HAL equivalent is a pin or HAL pin. HAL pins are software entities that exist only inside the computer. Physical_Pin  Many I/O devices have real physical pins or terminals that connect to external hardware. To avoid confusion, these are referred to as physical pins. These are the things that stick out into the real world. 19
  20. 20. Configuring LinuxCNC  Hardware Abstraction Layer (HAL)  Signal   In a physical machine, the terminals of real hardware components are interconnected by wires. Type  Bit - a single TRUE/FALSE or ON/OFF value     float - a 64 bit floating point value, with approximately 53 bits of resolution and over 1000 bits of dynamic range. u32 - a 32 bit unsigned integer, legal values are 0 to 4,294,967,295 s32 - a 32 bit signed integer, legal values are 2,147,483,647 to +2,147,483,647 Both pins and signals have types, and signals can only be connected to pins of the same type 20
  21. 21. Configuring LinuxCNC  Hardware Abstraction Layer (HAL)   Function  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. Thread  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. 21
  22. 22. Configuring LinuxCNC 22
  23. 23. Configuring LinuxCNC  HAL Commands  loadrt  The command loadrt loads a real time HAL component. Real time component functions need to be added to a thread to be updated at the rate of the thread 23
  24. 24. Configuring LinuxCNC  HAL Commands  addf  The command addf adds a real time component function to a thread. You have to add a function from a HAL real time component to a thread to get the function to update at the rate of the thread. 24
  25. 25. Configuring LinuxCNC  HAL Commands  loadusr  The command loadusr loads a user space HAL component. User space programs are their own separate processes, which optionally talk to other HAL components via pins and parameters. You cannot load real time components into user space. 25
  26. 26. Configuring LinuxCNC  HAL Commands  net  The command net creates a connection between a signal and and one or more pins. If the signal does not exist net creates the new signal. 26
  27. 27. Configuring LinuxCNC  HAL Commands  setp  The command setp sets the value of a pin or parameter. The valid values will depend on the type of the pin or parameter. 27
  28. 28. Configuring LinuxCNC  HAL Commands  unlinkp  The command unlinkp unlinks a pin from the connected signal. If no signal was connected to the pin prior running the command, nothing happens. 28
  29. 29. Configuring LinuxCNC  Example :   core_stepper.hal standard_pinout.hal 29
  30. 30. Appendix  Parallel Port Driver  installing   Pins     loadrt hal_parport cfg="<config-string>" parport.<p>.pin-<n>-out (bit) Drives a physical output pin. parport.<p>.pin-<n>-in (bit) Tracks a physical input pin. parport.<p>.pin-<n>-in-not (bit)Tracks a physical input pin, but inverted. Parameters    parport.<p>.pin-<n>-out-invert (bit) Inverts an output pin. parport.<p>.pin-<n>-out-reset (bit) (only for out pins) TRUE if this pin should be reset when the -reset function is executed. parport.<p>.reset-time' (U32) The time (in nanoseconds) between a pin is set by write and reset by the reset function if it is enabled. 30
  31. 31. Appendix  Parallel Port Driver  Functions      parport.<p>.read (funct) Reads physical input pins of port <portnum> and updates HAL -in and -innot pins. parport.read-all (funct) Reads physical input pins of all ports and updates HAL -in and -in-not pins. parport.<p>.write (funct) Reads HAL -out pins of port <p> and updates that port’s physical output pins. parport.write-all (funct) Reads HAL -out pins of all ports and updates all physical output pins. parport.<p>.reset (funct) Waits until reset-time has elapsed since the associated write, then resets pins to values indicated by -out-invert and -outinvert settings. 31
  32. 32. Appendix  software step pulse generation  installing   loadrt stepgen step_type=type0[,type1...] [ctrl_type=type0[,type1...]] [user_step_type=#,#...] FUNCTIONS    stepgen.make-pulses (no floating-point) Generates the step pulses, using information computed by update-freq. Must be called as frequently as possible, to maximize the attainable step rate and minimize jitter. Operates on all channels at once. stepgen.capture-position (uses floating point) Captures position feedback value from the high speed code and makes it available on a pin for use elsewhere in the system. Operates on all channels at once. stepgen.update-freq (uses floating point) Accepts a velocity or position command and converts it into a form usable by make-pulses for step generation. Operates on all channels at once. 32
  33. 33. Appendix  software step pulse generation  PINS        stepgen.N.counts s32 out The current position, in counts, for channel N. Updated by captureposition. stepgen.N.position-fb float out The current position, in length units (see parameter position-scale). Updated by capture-position. stepgen.N.enable bit in Enables output steps - when false, no steps are generated. stepgen.N.velocity-cmd float in (velocity mode only) Commanded velocity, in length units per second (see parameter position-scale). stepgen.N.position-cmd float in (position mode only) Commanded position, in length units (see parameter position-scale). stepgen.N.step bit out Step pulse output. stepgen.N.dir bit out Direction output: low for forward, high for reverse. 33
  34. 34. Appendix  software step pulse generation  PARAMETERS  stepgen.N.frequency float ro The current step rate, in steps per second, for channel N.  stepgen.N.maxaccel float rw The acceleration/deceleration limit, in length units per second squared.  stepgen.N.maxvel float rw The maximum allowable velocity, in length units per second. If the requested maximum velocity cannot be reached with the current combination of scaling andmake-pulses thread period, it will be reset to the highest attainable value.  stepgen.N.position-scale float rw The scaling for position feedback, position command, and velocity command, in steps per length unit.  stepgen.N.rawcounts s32 ro The position in counts, as updated by make-pulses. (Note: this is updated more frequently than the counts pin.)  stepgen.N.steplen u32 rw The length of the step pulses, in nanoseconds. Measured from rising edge to falling edge.  stepgen.N.stepspace u32 rw The minimum space between step pulses, in nanoseconds. Measured from falling edge to rising edge.  stepgen.N.dirsetup u32 rw The minimum setup time from direction to step, in nanoseconds periods. Measured from change of direction to rising edge of step.  stepgen.N.dirhold u32 rw The minimum hold time of direction after step, in nanoseconds. Measured from falling edge of step to change of direction. 34
  35. 35. Installing LinuxCNC DMP Electronics INC 35
  36. 36. LinuxCNC  Installing Ubuntu and LinuxCNC from the LinuxCNC Live-CD   Ubuntu 8.04 "Hardy Heron" LTS Ubuntu 10.04 "Lucid Lynx" LTS 36
  37. 37. Download  http://www.linuxcnc.org/index.php/english/downl oad 37
  38. 38. LinuxCNC 38
  39. 39. LinuxCNC Start 39
  40. 40. Stepping Start 40
  41. 41. Install build-dev  http://www.linuxcnc.org/hardy/dists/hardy/linuxcnc 2.5/source/linuxcnc_2.5.3.dsc 41
  42. 42. Install build-dev & Git 42
  43. 43. Get Source 存放的目的地 43
  44. 44. Building LinuxCNC 44
  45. 45. Building LinuxCNC 45
  46. 46. Building LinuxCNC 46
  47. 47. Building LinuxCNC 47
  48. 48. Building LinuxCNC 48
  49. 49. Building LinuxCNC 49
  50. 50. LinuxCNC 50
  51. 51. LinuxCNC 51
  52. 52. LinuxCNC Python Virtual Control Panel 52
  53. 53. 53
  54. 54. 54
  55. 55. 55
  56. 56. 56
  57. 57. 57
  58. 58. 58
  59. 59. PyVCP    Python based virtual control panel Can be added to the Axis GUI Be stand alone. 59
  60. 60. PyVCP   Customize interface Test or monitor 60
  61. 61. Panel Construction   Specify with an XML file Widget tags are placed between <pyvcp> and </pyvcp> 61
  62. 62. Panel Construction   Connect HAL signals to and from the PyVCP pins Example 62
  63. 63. AXIS 1. 2. 3. 4. Create an .xml file that contains your panel description and put it in your config directory. Add the PyVCP entry to the [DISPLAY] section of the ini file with your .xml file name. Add the POSTGUI_HALFILE entry to the [HAL] section of the ini file with the name of your postgui HAL file name. Add the links to HAL pins for your panel in the postgui.hal file to connect your PyVCP panel to LinuxCNC 63
  64. 64. AXIS 64
  65. 65. AXIS  Create an .xml 65
  66. 66. AXIS  [DISPLAY] section (.ini file)   [HAL] section (.ini file)   PYVCP = spindle.xml POSTGUI_HALFILE = spindle_to_pyvcp.hal links to HAL pins (.hal file)  net spindle-rpm-filtered => pyvcp.spindle-speed 66
  67. 67. Stand Alone 1. 2. 3. Create an .xml file that contains your panel description and put it in your config directory Add a loadusr line to your .hal file to load each panel. Add the links to HAL pins for your panel in the postgui.hal file to connect your PyVCP panel to LinuxCNC. 67
  68. 68. Stand Alone  load a stand alone PyVCP panel   loadusr -Wn mypanel pyvcp -g WxH+X+Y -c mypanel <path/>panel_file.xml  -Wn panelname  pyvcp < -g> < -c> panel.xml  -g <WxH><+X+Y>  -c panelname Example   loadusr -Wn mypanel pyvcp -g 250x500+800+0 -c mypanel mypanel.xml loadusr pyvcp mypanel.xml 68
  69. 69. Widgets   Bits are off/on signals Numbers can be float, s32 or u32 1. 2. 3. 4. 5. indicate bit signals: led, rectled control bit signals: button, checkbutton, radiobutton indicate number signals: number, s32, u32, bar, meter control number signals: spinbox, scale, jogwheel Helper widgets: hbox, vbox, table, label, labelframe 69
  70. 70. Widgets -- General Notes  tag-based and attribute-based syntax    <led halpin="my-led"/> <led> <halpin>"my-led"</halpin> </led> Comments  <!-- My Comment --> 70
  71. 71. Widgets  Label  <label> <text>"This is a Label:"</text> <font>("Helvetica",20)</font> </label> 71
  72. 72. Widgets  LEDs (bit)  Round LED  Rectangle LED 72
  73. 73. Widgets  Buttons (bit)  Text Button  Checkbutton 73
  74. 74. Widgets  Buttons (bit)  Radiobutton 74
  75. 75. Widgets  Number Displays (number)  Number  s32 Number / u32 Number 75
  76. 76. Widgets  Number Displays (number)  Bar  Meter 76
  77. 77. Widgets  Number Inputs (number)  Spinbox  Dial 77
  78. 78. Widgets  Number Inputs (number)  Scale 78
  79. 79. Widgets  Number Inputs (number)  Jogwheel 79
  80. 80. Widgets  Images  Image Bit  Image u32 80
  81. 81. Widgets  Containers  Borders 81
  82. 82. Widgets  Containers  Hbox  Vbox 82
  83. 83. Widgets  Containers  Table 83
  84. 84. Widgets  Containers  Tabs 84
  85. 85. Widgets  Containers  Labelframe 85
  86. 86. Example  With AXIS interface 86
  87. 87. Example – Jog Buttons  custompanel.xml file 87
  88. 88. Example – Jog Buttons  custom_postgui.hal file 88
  89. 89. Example -- Port Tester  ptest.xml file 89
  90. 90. Example -- Port Tester   ptest.hal file To run the HAL file we use the following command from a terminal window.  halrun -I -f ptest.hal 90
  91. 91. Thanks. 91

×