LinuxCNC 入門簡介

91
LinuxCNC Overview DMP Electronics INC

description

 

Transcript of LinuxCNC 入門簡介

Page 1: LinuxCNC 入門簡介

LinuxCNC Overview

DMP Electronics INC

Page 2: LinuxCNC 入門簡介

2

Simple LinuxCNC Controlled Machine

Page 3: LinuxCNC 入門簡介

3

OutLine

About the LinuxCNC

Linux / RTAI

LinuxCNC software

LinuxCNC Hierarchical

Configuring LinuxCNC

Page 4: LinuxCNC 入門簡介

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.

Page 5: LinuxCNC 入門簡介

5

Linux / RTAI

User Space

Page 6: LinuxCNC 入門簡介

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).

Page 7: LinuxCNC 入門簡介

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.

Page 8: LinuxCNC 入門簡介

8

LinuxCNC - Axis GUI

Page 9: LinuxCNC 入門簡介

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.

Page 10: LinuxCNC 入門簡介

10

GUI

EMCTASK

RS274 (G code)

INTERPRETER

SEQUENCING

LOGIC

NM

L

Share memory

EMCMOT

NM

L

EMCIO

HA

L p

ins

HA

L p

ins

Real-time HWD Non-Real-time HWD

HA

L p

ins

HA

L p

ins

Hardware Abstraction Layer (HAL)

Real time

Page 11: LinuxCNC 入門簡介

11

LinuxCNC Hierarchical

EMCTASK

基於EMC2的數控系統軟件架構及通信機制分析(2010)

Page 12: LinuxCNC 入門簡介

12

LinuxCNC Hierarchical

EMCMOT

Page 13: LinuxCNC 入門簡介

13

LinuxCNC Hierarchical

EMCIO Be used to control

some machine actions like lube, coolant, and spindle direction and speed

Page 14: LinuxCNC 入門簡介

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.

Page 15: LinuxCNC 入門簡介

15

Configuring LinuxCNC

The INI File Components

Comments

Sections

Variables

Custom Sections and Variables

Sections

Variables

Comments

Page 16: LinuxCNC 入門簡介

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

Page 17: LinuxCNC 入門簡介

17

Configuring LinuxCNC

Hardware Abstraction Layer (HAL) Component

Parameter

Pin

Physical_Pin

Signal

Type

Function

Thread

Page 18: LinuxCNC 入門簡介

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

Page 19: LinuxCNC 入門簡介

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.

Page 20: LinuxCNC 入門簡介

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

Page 21: LinuxCNC 入門簡介

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.

Page 22: LinuxCNC 入門簡介

22

Configuring LinuxCNC

Page 23: LinuxCNC 入門簡介

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

Page 24: LinuxCNC 入門簡介

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.

Page 25: LinuxCNC 入門簡介

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.

Page 26: LinuxCNC 入門簡介

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.

Page 27: LinuxCNC 入門簡介

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.

Page 28: LinuxCNC 入門簡介

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.

Page 29: LinuxCNC 入門簡介

29

Configuring LinuxCNC

Example :

core_stepper.hal

standard_pinout.hal

Page 30: LinuxCNC 入門簡介

30

Appendix

Parallel Port Driver installing

loadrt hal_parport cfg="<config-string>"

Pins 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.

Page 31: LinuxCNC 入門簡介

31

Appendix

Parallel Port Driver Functions

parport.<p>.read (funct) Reads physical input pins of port <portnum> and updates HAL -in and -in-not 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 -out-invert settings.

Page 32: LinuxCNC 入門簡介

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.

Page 33: LinuxCNC 入門簡介

33

Appendix

software step pulse generation PINS

stepgen.N.counts s32 out The current position, in counts, for channel N. Updated by capture-

position. 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.

Page 34: LinuxCNC 入門簡介

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.

Page 35: LinuxCNC 入門簡介

35

Installing LinuxCNC

DMP Electronics INC

Page 36: LinuxCNC 入門簡介

36

LinuxCNC

Installing Ubuntu and LinuxCNC from the LinuxCNC Live-CD

Ubuntu 8.04 "Hardy Heron" LTS

Ubuntu 10.04 "Lucid Lynx" LTS

Page 37: LinuxCNC 入門簡介

37

Download

http://www.linuxcnc.org/index.php/english/download

Page 38: LinuxCNC 入門簡介

38

LinuxCNC

Page 39: LinuxCNC 入門簡介

39

LinuxCNC Start

Page 40: LinuxCNC 入門簡介

40

Stepping Start

Page 41: LinuxCNC 入門簡介

41

Install build-dev

http://www.linuxcnc.org/hardy/dists/hardy/linuxcnc2.5/source/linuxcnc_2.5.3.dsc

Page 42: LinuxCNC 入門簡介

42

Install build-dev & Git

Page 43: LinuxCNC 入門簡介

43

Get Source

存放的目的地

Page 44: LinuxCNC 入門簡介

44

Building LinuxCNC

Page 45: LinuxCNC 入門簡介

45

Building LinuxCNC

Page 46: LinuxCNC 入門簡介

46

Building LinuxCNC

Page 47: LinuxCNC 入門簡介

47

Building LinuxCNC

Page 48: LinuxCNC 入門簡介

48

Building LinuxCNC

Page 49: LinuxCNC 入門簡介

49

Building LinuxCNC

Page 50: LinuxCNC 入門簡介

50

LinuxCNC

Page 51: LinuxCNC 入門簡介

51

LinuxCNC

Page 52: LinuxCNC 入門簡介

52

LinuxCNC

Python Virtual Control Panel

Page 53: LinuxCNC 入門簡介

53

Page 54: LinuxCNC 入門簡介

54

Page 55: LinuxCNC 入門簡介

55

Page 56: LinuxCNC 入門簡介

56

Page 57: LinuxCNC 入門簡介

57

Page 58: LinuxCNC 入門簡介

58

Page 59: LinuxCNC 入門簡介

59

PyVCP

Python based virtual control panel

Can be added to the Axis GUI

Be stand alone.

Page 60: LinuxCNC 入門簡介

60

PyVCP

Customize interface

Test or monitor

Page 61: LinuxCNC 入門簡介

61

Panel Construction

Specify with an XML file

Widget tags are placed between <pyvcp> and </pyvcp>

Page 62: LinuxCNC 入門簡介

62

Panel Construction

Connect HAL signals to and from the PyVCP pins

Example

Page 63: LinuxCNC 入門簡介

63

AXIS

1. Create an .xml file that contains your panel description and put it in your config directory.

2. Add the PyVCP entry to the [DISPLAY] section of the ini file with your .xml file name.

3. Add the POSTGUI_HALFILE entry to the [HAL] section of the ini file with the name of your postgui HAL file name.

4. Add the links to HAL pins for your panel in the postgui.hal file to connect your PyVCP panel to LinuxCNC

Page 64: LinuxCNC 入門簡介

64

AXIS

Page 65: LinuxCNC 入門簡介

65

AXIS

Create an .xml

Page 66: LinuxCNC 入門簡介

66

AXIS

[DISPLAY] section (.ini file)

PYVCP = spindle.xml

[HAL] section (.ini file)

POSTGUI_HALFILE = spindle_to_pyvcp.hal

links to HAL pins (.hal file)

net spindle-rpm-filtered => pyvcp.spindle-speed

Page 67: LinuxCNC 入門簡介

67

Stand Alone

1. Create an .xml file that contains your panel description and put it in your config directory

2. Add a loadusr line to your .hal file to load each panel.

3. Add the links to HAL pins for your panel in the postgui.hal file to connect your PyVCP panel to LinuxCNC.

Page 68: LinuxCNC 入門簡介

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

Page 69: LinuxCNC 入門簡介

69

Widgets

Bits are off/on signals

Numbers can be float, s32 or u32 1. indicate bit signals: led, rectled

2. control bit signals: button, checkbutton, radiobutton

3. indicate number signals: number, s32, u32, bar, meter

4. control number signals: spinbox, scale, jogwheel

5. Helper widgets: hbox, vbox, table, label, labelframe

Page 70: LinuxCNC 入門簡介

70

Widgets -- General Notes

tag-based and attribute-based syntax

<led halpin="my-led"/>

<led>

<halpin>"my-led"</halpin>

</led>

Comments

<!-- My Comment -->

Page 71: LinuxCNC 入門簡介

71

Widgets

Label

<label>

<text>"This is a Label:"</text>

<font>("Helvetica",20)</font>

</label>

Page 72: LinuxCNC 入門簡介

72

Widgets

LEDs (bit)

Round LED

Rectangle LED

Page 73: LinuxCNC 入門簡介

73

Widgets

Buttons (bit)

Text Button

Checkbutton

Page 74: LinuxCNC 入門簡介

74

Widgets

Buttons (bit)

Radiobutton

Page 75: LinuxCNC 入門簡介

75

Widgets

Number Displays (number)

Number

s32 Number / u32 Number

Page 76: LinuxCNC 入門簡介

76

Widgets

Number Displays (number)

Bar

Meter

Page 77: LinuxCNC 入門簡介

77

Widgets

Number Inputs (number)

Spinbox

Dial

Page 78: LinuxCNC 入門簡介

78

Widgets

Number Inputs (number) Scale

Page 79: LinuxCNC 入門簡介

79

Widgets

Number Inputs (number) Jogwheel

Page 80: LinuxCNC 入門簡介

80

Widgets

Images

Image Bit

Image u32

Page 81: LinuxCNC 入門簡介

81

Widgets

Containers

Borders

Page 82: LinuxCNC 入門簡介

82

Widgets

Containers

Hbox

Vbox

Page 83: LinuxCNC 入門簡介

83

Widgets

Containers

Table

Page 84: LinuxCNC 入門簡介

84

Widgets

Containers

Tabs

Page 85: LinuxCNC 入門簡介

85

Widgets

Containers

Labelframe

Page 86: LinuxCNC 入門簡介

86

Example

With AXIS interface

Page 87: LinuxCNC 入門簡介

87

Example – Jog Buttons

custompanel.xml file

Page 88: LinuxCNC 入門簡介

88

Example – Jog Buttons

custom_postgui.hal file

Page 89: LinuxCNC 入門簡介

89

Example -- Port Tester

ptest.xml file

Page 90: LinuxCNC 入門簡介

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

Page 91: LinuxCNC 入門簡介

91

Thanks.