From 47fc54647d748af67225277e4f5561d7866e15f0 Mon Sep 17 00:00:00 2001 From: bartool Date: Fri, 5 Jun 2026 17:55:39 +0200 Subject: [PATCH] dokumentacja linuxcnc --- hal_motion.md | 30 ++++ mb2hal.md | 424 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 454 insertions(+) create mode 100644 hal_motion.md create mode 100644 mb2hal.md diff --git a/hal_motion.md b/hal_motion.md new file mode 100644 index 0000000..6fb7fc7 --- /dev/null +++ b/hal_motion.md @@ -0,0 +1,30 @@ +pełna instrukcja -> [MOTMOD](https://linuxcnc.org/docs/stable/html/man/man9/motion.9.html#SPINDLE%20PINS) + +## SPINDLE PINS + +(M is the spindle number (0 ... num_spindles-1)) + +| name | dir | format | description | +|:-----|:---:|:------:|:------------| +| spindle.M.amp-fault-in | IN | BIT | Should be driven TRUE if an external fault is detected with the amplifier for this spindle. | +| spindle.M.at-speed | IN | BIT | Motion will pause until this pin is TRUE, under the following conditions: before the first feed move after each spindle start or speed change; before the start of every chain of spindle-synchronized moves; and if in CSS mode, at every rapid->feed transition. | +| spindle.M.brake | OUT | BIT | TRUE when the spindle brake should be applied. | +| spindle.M.forward | OUT | BIT | TRUE when the spindle should rotate forward. | +| spindle.M.index-enable | I/O | BIT | For correct operation of spindle synchronized moves, this signal must be hooked to the index-enable pin of the spindle encoder. | +| spindle.M.inhibit | IN | BIT | When TRUE, the spindle speed is set and held to 0. | +| spindle.M.is-oriented | IN | BIT | Acknowledge pin for spindle-orient. Completes orient cycle. If spindle-orient was true when spindle-is-oriented was asserted, the spindle-orient pin is cleared and the spindle-locked pin is asserted. Also, the spindle-brake pin is asserted. | +| spindle.M.locked | OUT | BIT | Spindle orient complete pin. Cleared by any of M3,M4,M5. | +| spindle.M.on | OUT | BIT | TRUE when spindle should rotate. | +| spindle.M.orient | OUT | BIT | Indicates start of spindle orient cycle. Set by M19. Cleared by any of M3,M4,M5.
If spindle-orient-fault is not zero during spindle-orient true, the M19 command fails with an error message. | +| spindle.M.orient-angle | OUT | FLOAT | Desired spindle orientation for M19. Value of the M19 R word parameter plus the value of the [RS274NGC]ORIENT_OFFSET INI parameter. | +| spindle.M.orient-fault | IN | S32 | Fault code input for orient cycle. Any value other than zero will cause the orient cycle to abort. | +| spindle.M.orient-mode | OUT | BIT | Desired spindle rotation mode. Reflects M19 P parameter word. | +| spindle.M.reverse | OUT | BIT | TRUE when the spindle should rotate backward. | +| spindle.M.revs | IN | FLOAT | For correct operation of spindle synchronized moves, this signal must be hooked to the position pin of the spindle encoder. | +| spindle.M.speed-cmd-rps | FLOAT | OUT | Commanded spindle speed in units of revolutions per second. | +| spindle.M.speed-in | IN | FLOAT | Actual spindle speed feedback in revolutions per second; used for G96 (constant surface speed) and G95 (feed per revolution) modes. | +| spindle.M.speed-out | OUT | FLOAT | Desired spindle speed in rotations per minute. | +| spindle.M.speed-out-abs | OUT | FLOAT | Desired spindle speed in rotations per minute, always positive regardless of spindle direction. | +| spindle.M.speed-out-rps | OUT | FLOAT | Desired spindle speed in rotations per second. | +| spindle.M.speed-out-rps-abs | OUT | FLOAT | Desired spindle speed in rotations per second, always positive regardless of spindle direction. | + diff --git a/mb2hal.md b/mb2hal.md new file mode 100644 index 0000000..88302a4 --- /dev/null +++ b/mb2hal.md @@ -0,0 +1,424 @@ + +## 1. Introduction + +MB2HAL is a generic non-realtime HAL component to communicate with one or more Modbus devices. So far, there are two options to communicate with a Modbus device: + +1. One option is to create a HAL component as a driver see VFD Modbus. +2. Another option is to use Classic Ladder which has Modbus built in, see ClassicLadder. +3. Now there is a third option that consists of a "generic" driver configured by text file, this is called MB2HAL. + +Why MB2HAL? Consider using MB2HAL if: + +1. You have to write a new driver and you don’t know anything about programming. +2. You need to use Classic Ladder "only" to manage the Modbus connections. +3. You have to discover and configure first time the Modbus transactions. MB2HAL have debug levels to facilitate the low level protocol debug. +4. You have more than one device to connect. MB2HAL is very efficiently managing multiple devices, transactions and links. Currently I am monitoring two axis drivers using a Rs232 port, a VFD driver using another Rs232 port, and a remote I/O using TCP/IP. +5. You want a protocol to connect your Arduino to HAL. Look the included sample configuration file, sketch and library for Arduino Modbus. + +## 2. Usage + +1. Create a config file from the example below + + - Set component name (optional) + + Set HAL_MODULE_NAME=mymodule (default HAL_MODULE_NAME=mb2hal) + + - Load the modbus HAL non-realtime component + +2. Default component name: loadusr -W mb2hal config=config_file.ini + +3. Custom component name: loadusr -Wn mymodule mb2hal config=config_file.ini + +## 3. Options + +### 3.1 Init Section + +[MB2HAL_INIT] +|Value|Type|Required|Description| +|-----|----|--------|-----------| +|INIT_DEBUG|Integer|No|Debug level of init and INI file parsing
.0 = silent
1 = error messages (default)
2 = OK confirmation messages
3 = debugging messages
4 = maximum debugging messages (only in transactions) +|VERSION|String|No|Version number in the format N.N[NN]. Defaults to 1.0.| +|HAL_MODULE_NAME|String|No|HAL module (component) name. Defaults to "mb2hal".| +|SLOWDOWN|Float|No|Insert a delay of "FLOAT seconds" between transactions in order to not to have a lot of logging and facilitate the debugging. Useful when using DEBUG=3 (NOT INIT_DEBUG=3). It affects ALL transactions. Use "0.0" for normal activity.| +|TOTAL_TRANSACTIONS|Integer|Yes|The number of total Modbus transactions. There is no maximum.| + +### 3.2 Transaction Sections + +One transaction section is required per transaction, starting at [TRANSACTION_00] and counting up sequentially. If there is a new link (not transaction), you must provide the REQUIRED parameters 1st time. Warning: Any OPTIONAL parameter not specified are copied from the previous transaction. +|Value|Type|Required|Description| +|-----|----|--------|-----------| +|LINK_TYPE|String|Yes|You must specify either a "serial" or "tcp" link for the first transaction. Later transactions will use the previous transaction link if not specified.| +|TCP_IP|IP address|If LINK_TYPE=tcp|The Modbus slave device IP address. Ignored if LINK_TYPE=serial.| +|TCP_PORT|Integer|No|The Modbus slave device TCP port. Defaults to 502. Ignored if LINK_TYPE=serial.| +|SERIAL_PORT|String|If LINK_TYPE=serial|The serial port. For example "/dev/ttyS0". Ignored if LINK_TYPE=tcp.| +|SERIAL_BAUD|Integer|If LINK_TYPE=serial|The baud rate. Ignored if LINK_TYPE=tcp.| +|SERIAL_BITS|Integer|If LINK_TYPE=serial|Data bits. One of 5, 6, 7, 8. Ignored if LINK_TYPE=tcp.| +|SERIAL_PARITY|String|If LINK_TYPE=serial|Data parity. One of: even, odd, none. Ignored if LINK_TYPE=tcp.| +|SERIAL_STOP|Integer|If LINK_TYPE=serial|Stop bits. One of 1, 2. Ignored if LINK_TYPE=tcp.| +|SERIAL_DELAY_MS|Integer|If LINK_TYPE=serial|Serial port delay between transactions of this section only. In ms. Defaults to 0. Ignored if LINK_TYPE=tcp.| +|MB_SLAVE_ID|Integer|Yes|Modbus slave number.| +|FIRST_ELEMENT|Integer|Yes|The first element address.| +|NELEMENTS|Integer|Unless PIN_NAMES is specified|The number of elements. It is an error to specify both NELEMENTS and PIN_NAMES. The pin names will be sequential numbers, e.g. mb2hal.plcin.01.| +|PIN_NAMES|List|Unless NELEMENTS is specified|A list of element names. These names will be used for the pin names, e.g. mb2hal.plcin.cycle_start.
**NOTE:** There must be no white space characters in the list. Example: PIN_NAMES=cycle_start,stop,feed_hold| +|MB_TX_CODE|String|Yes|Modbus transaction function code (see specifications):