LinuxCNC 入門簡介

Post on 29-Nov-2014

3.166 views 12 download

description

 

Transcript of LinuxCNC 入門簡介

LinuxCNC Overview

DMP Electronics INC

2

Simple LinuxCNC Controlled Machine

3

OutLine

About the LinuxCNC

Linux / RTAI

LinuxCNC software

LinuxCNC Hierarchical

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

5

Linux / RTAI

User Space

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

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.

8

LinuxCNC - Axis GUI

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.

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

11

LinuxCNC Hierarchical

EMCTASK

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

12

LinuxCNC Hierarchical

EMCMOT

13

LinuxCNC Hierarchical

EMCIO Be used to control

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

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.

15

Configuring LinuxCNC

The INI File Components

Comments

Sections

Variables

Custom Sections and Variables

Sections

Variables

Comments

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

17

Configuring LinuxCNC

Hardware Abstraction Layer (HAL) Component

Parameter

Pin

Physical_Pin

Signal

Type

Function

Thread

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

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.

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

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.

22

Configuring 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

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.

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.

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.

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.

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.

29

Configuring LinuxCNC

Example :

core_stepper.hal

standard_pinout.hal

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.

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.

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.

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.

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.

35

Installing LinuxCNC

DMP Electronics INC

36

LinuxCNC

Installing Ubuntu and LinuxCNC from the LinuxCNC Live-CD

Ubuntu 8.04 "Hardy Heron" LTS

Ubuntu 10.04 "Lucid Lynx" LTS

37

Download

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

38

LinuxCNC

39

LinuxCNC Start

40

Stepping Start

41

Install build-dev

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

42

Install build-dev & Git

43

Get Source

存放的目的地

44

Building LinuxCNC

45

Building LinuxCNC

46

Building LinuxCNC

47

Building LinuxCNC

48

Building LinuxCNC

49

Building LinuxCNC

50

LinuxCNC

51

LinuxCNC

52

LinuxCNC

Python Virtual Control Panel

53

54

55

56

57

58

59

PyVCP

Python based virtual control panel

Can be added to the Axis GUI

Be stand alone.

60

PyVCP

Customize interface

Test or monitor

61

Panel Construction

Specify with an XML file

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

62

Panel Construction

Connect HAL signals to and from the PyVCP pins

Example

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

64

AXIS

65

AXIS

Create an .xml

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

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.

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

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

70

Widgets -- General Notes

tag-based and attribute-based syntax

<led halpin="my-led"/>

<led>

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

</led>

Comments

<!-- My Comment -->

71

Widgets

Label

<label>

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

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

</label>

72

Widgets

LEDs (bit)

Round LED

Rectangle LED

73

Widgets

Buttons (bit)

Text Button

Checkbutton

74

Widgets

Buttons (bit)

Radiobutton

75

Widgets

Number Displays (number)

Number

s32 Number / u32 Number

76

Widgets

Number Displays (number)

Bar

Meter

77

Widgets

Number Inputs (number)

Spinbox

Dial

78

Widgets

Number Inputs (number) Scale

79

Widgets

Number Inputs (number) Jogwheel

80

Widgets

Images

Image Bit

Image u32

81

Widgets

Containers

Borders

82

Widgets

Containers

Hbox

Vbox

83

Widgets

Containers

Table

84

Widgets

Containers

Tabs

85

Widgets

Containers

Labelframe

86

Example

With AXIS interface

87

Example – Jog Buttons

custompanel.xml file

88

Example – Jog Buttons

custom_postgui.hal file

89

Example -- Port Tester

ptest.xml file

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

91

Thanks.