Network Servo Interface Adapters for LinuxCNC
This release requires card firmware 3.0.0 or later. Please contact me for update instructions.
Installation - Debian 12 Bookworm (PREEMPT_RT)
- Install Debian 12 Bookworm PREEMPT-RT
- Download and install LinuxCNC 2.9.3nyx51 DEB packages. This build includes the
card driver module and sample configurations
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install wget dkms linux-image-rt-amd64 linux-headers-rt-amd64
$ sudo reboot
$ wget http://yurtaev.com/files/2.9.3nyx51/bookworm-uspace/linuxcnc-uspace_2.9.3nyx51_amd64.deb
$ wget http://yurtaev.com/files/2.9.3nyx51/bookworm-uspace/nyx-pci-dkms_3.2.0_amd64.deb
$ sudo dpkg -i linuxcnc-uspace_2.9.3nyx51_amd64.deb nyx-pci-dkms_3.2.0_amd64.deb
$ sudo apt -f install
$ sudo systemctl stop systemd-timesyncd # disrupts servo-thread period
$ sudo systemctl disable systemd-timesyncd # during system time adjustment
Configuration
Check realtime latency. Should be somewhere under plus/minus 50us:
$ latency-histogram --nobase --servo 888888
Verify the YxxxxP PCI card has been detected:
$ sudo nyxq info
NYX v3.2.1 YMDS2P -- Oct 4 2023 13:52:35, http://yurtaev.com
axes:9 mds:7 gpi:12+17 gpo:8 enc:6 dac:2 yio:8 stepgen:2
If required, edit ~/linuxcnc/configs/nyx/par/*.par parameter file for your servo drives.
Initially those files contain default parameters which will be transfered to drives
(and will overwrite EEPROM contents on J2/J2S/J3/J4 amps - backup servo drive parameters
using MR Configurator software if you need them)
Start LinuxCNC and select sample config matching your card/drives from the tree under "nyx" node.
Connected amps should get initialized, corresponding green indicators in the LinuxCNC Axis window should turn on.
LinuxCNC driver v3.2.0 and up
LinuxCNC HAL driver module name is nyx. During operation the
controller and SSCNET network are synchronized to servo thread of the
LinuxCNC. Servo thread period should be set to
- 888888 ns for YSSC1P, YSSC2P, YMDS2P
- 222222 ns for YSSC3P, YSSC3HP, YMDS3P
- 1000000 ns for YMTL1P, YMTL2P
Module parameters:
- maxdrives=N - limit number of axes the module creates pins for
- param_file=PATH - servo parameters file
- nodma=dir - disable DMA PCI transfers, 1=read, 2=write, 3=both. Motherboards with chipsets supporting native PCI usually perform better with nodma=0. With PCIE-to-PCI bridges try nodma=1
- cycle=div - communication cycle divider: 0=servo-thread frequency, 1=1/2, 2=1/4, etc.
- encres=res0,res1,... - feedback resolution override
The following HAL commands load the driver and add its callback function to the servo thread:
loadrt motmod servo_period_nsec=888888 ...
loadrt nyx maxdrives=6 param_file=par/j2s.par
addf nyx.0.rd servo-thread
addf nyx.0.wr servo-thread
servo parameter file
Servo parameters are transfered to drives during initialization after LinuxCNC startup.
Sample files are located in /usr/share/nyx. For MR-J*-B and SGD* parameter file is
optional - drives will use values from the EEPROM. For MDS drives parameter file is mandatory.
Consult servo drive manual for parameters description.
nyx
Controller status pins:
- nyx.0.ready (bit, out) - the controller is in sync with
LinuxCNC servo thread. Before it come true other pins are
inactive
- nyx.0.error-cnt (u32, out) - communication error count. Number
of clocks when servo thread sync was absent. If the value increases then
the jitter is probably too large. Jitter tolerance is about 50
microseconds
- nyx.0.phase (float, out) - an offset of the servo thread call
relative from the timing slot of controller's cycle, 45MHz ticks.
Should not exceed about 1000
servo
Depending on adapter the driver supports up to 16 servo amplifiers, AX number is 00 thru 15. Parameters:
- nyx.0.servo-AX.pos-scale (float, rw) - position scale factor, in length units per revolution. Default is 5, which is suitable for direct motor coupling to 5mm lead ball screw
- nyx.0.servo-AX.vel-scale (bit, rw) - velocity scale factor. Default is 10, so that vel-cmd is in rotation per minute with 0.1 rpm resolution. For J3/J4 should be set to 100
- nyx.0.servo-AX.trq-scale (bit, rw) - torque scale factor. Default is 1
- nyx.0.servo-AX.origin (signed, rw) - position offset
Mechatrolink uses a fraction of max motor speed/torque as units during velocity control, see [NYX] section in nyx-mtl2.ini sample config for sample values.
Pins:
- nyx.0.servo-AX.online (bit, out) - the controller has detected and initialized AX servo amplifier
- nyx.0.servo-AX.offline (bit, out) - inverted online pin output
- nyx.0.servo-AX.ready (bit, out) - READY-ON status (power relay is on)
- nyx.0.servo-AX.enabled (bit, out) - SERVO-ON status
- nyx.0.servo-AX.warning (bit, out) - servo amplifier warning
- nyx.0.servo-AX.alarm (bit, out) - servo amplifier alarm
- nyx.0.servo-AX.alarm-code (u32, out) - servo amplifier alarm code (hex)
- nyx.0.servo-AX.zero-speed (bit, out) - motor velocity is below zero speed threshold (set by amp param)
- nyx.0.servo-AX.in-position (bit, out) - position complete (threshold set by amp param)
- nyx.0.servo-AX.at-speed (bit, out) - motor at reached commanded speed (velocity control mode)
- nyx.0.servo-AX.in-NN (bit, out) - [ssc3/mii] amplifier digital input state, NN is 00 thru 02
- nyx.0.servo-AX.in-NN-not (bit, out) - [ssc3/mii] .. inverted
- nyx.0.servo-AX.out-NN (bit, in) - [ssc3] set servo amplifier digital output selected by 0x21, 0x22, 0x23 in PD07..PD09
- nyx.0.servo-AX.power (bit, in) - turn on amplifier power relay (READY-ON)
- nyx.0.servo-AX.enable (bit, in) - enable servo (SERVO-ON)
- nyx.0.servo-AX.reset-alarm (bit, in) - reset servo amp alarm when true
- nyx.0.servo-AX.pos-cmd (float, in) - position command input
- nyx.0.servo-AX.pos-fb (float, out) - motor feedback position
- nyx.0.servo-AX.velocity-mode (bit, rw) - [ssc2/ssc3/mii] velocity control mode. Change is possible at zero speed only
- nyx.0.servo-AX.vel-cmd (float, in) - [ssc2/ssc3/mii/mds] commanded velocity
- nyx.0.servo-AX.vel-fb (float, out) - motor velocity feedback
- nyx.0.servo-AX.trq-fb (float, out) - motor torque feedback, percent of nominal motor torque
- nyx.0.servo-AX.error-cnt (s32, out) - amplifier feedback receive error count
- nyx.0.servo-AX.spindle-fwd (bit, in) - [mds] start spindle in forward direction with vel-cmd speed. enable should be false
- nyx.0.servo-AX.spindle-rev (bit, in) - [mds] start spindle in reverse direction with vel-cmd speed. enable should be false
- nyx.0.servo-AX.spindle-orient (bit, in) - [mds] start spindle orientation. Has proirity over spindle-fwd, spindle-rev
- nyx.0.servo-AX.spindle-orienting (bit, out) - [mds] spindle orientation in progress
- nyx.0.servo-AX.spindle-oriented (bit, out) - [mds] spindle orientation complete
- nyx.0.servo-AX.spindle-lcoil (bit, in) - [mds] select spindle low-speed coil
- nyx.0.servo-AX.spindle-in-coil-change (bit, out) - [mds] true during coil change
- nyx.0.servo-AX.spindle-in-lcoil (bit, out) - [mds] low-speed spingle coil active
- nyx.0.servo-AX.counts (s32, out) - servo position feedback counts in native encoder resolution
- nyx.0.servo-AX.counts-cmd (s32, out) - servo position command counts in native encoder resolution
- nyx.0.servo-AX.droop (s32, out) - amplifier reported following error, in native encoder resolution
- nyx.0.servo-AX.rxtime (s32, out) - amplifier feedback reception time during servo cycle for servo protocol debug
- nyx.0.servo-AX.forward-torque (float, in) - forward rotation torque limit, percents
- nyx.0.servo-AX.reverse-torque (float, in) - reverse rotation torque limit, percents
- nyx.0.servo-AX.limit-torque (bit, in) - turn on torque limiting
- nyx.0.servo-AX.torque-clamped (bit, out) - torque clamp indication
- nyx.0.servo-AX.absolute (bit, out) - absolute position feedback is valid (set by amp param)
- nyx.0.servo-AX.abs-lost (bit, out) - absolute position is not valid due to e.g. motor disconnection or discharged backup battery
- nyx.0.servo-AX.abs-ok (bit, out) - absolute position is enabled and valid
- nyx.0.servo-AX.index-enable (bit, io) - [ssc3] reset pos-fb to zero on encoder index pulse, for z-index homing
- nyx.0.servo-AX.undroop (bit, in) - connect to joint.x.homing to add droop pulses to pos-fb to avoid jerk during z-index homing
- nyx.0.servo-AX.z-offs (s32, out) - connect to joint.x.homing to add droop pulses to pos-fb to avoid jerk during z-index homing
- nyx.0.servo-AX.z-offs-delay (s32, in) - delay (cycles) when z-offset is available after the z-passed flag is raised
encoder
An encoder input channel converts quadrature signals on CN2 Phase A, Phase B, Index Z into 32-bit up/down counter values. The sampling requency is 45 MHz. NN is
encoder channel: 00 or 01. Parameter:
- nyx.0.encoder-NN.cpr (float, rw) - encoder resolution, counts per revolution. Sign defines rotation direction. Default is -10000
- nyx.0.encoder-NN.x4-mode (bit, rw) - count on every edge
Pins:
- nyx.0.encoder-NN.index-enable (bit, io) - reset counter on next index mark Z
- nyx.0.encoder-NN.pos (float, out) - encoder counter divided by the cpr parameter value. Signed fractional number of revolutions.
- nyx.0.encoder-NN.counts (s32, io) - encoder counter.
- nyx.0.encoder-NN.velocity (float, out) - estimated velocity, RPM.
The interface is intended for use with motion.spindle-index-enable and motion.spindle-revs.
gpio
Digital input signals IN0..IN11 connected to CN1. Pins:
- nyx.0.in-NN (bit, out) - a state of digital input NN 00 thru 11
- nyx.0.in-NN-not (bit, out) - inverted
Expansion connector CN2 as GP inputs IN12..IN29. Pins:
- nyx.0.in-NN (bit, out) - a state of digital input NN 12 thru 29
- nyx.0.in-NN-not (bit, out) - inverted
Digital output signals OUT0..OUT7 going to CN3:
- nyx.0.out-NN (bit, in) - set output number NN 00 thru 07
dac
2-channel 12-bit digital-to-analog converter on YEX1-A expansion board. Paramaters:
- nyx.0.dac-CH.scale (float, rw) - max input value (for 10V output voltage). Default is 1.0, CH is 00 or 01
- nyx.0.dac-CH.bias (float, rw) - DAC offset. output voltage = 10V * (value / scale + bias)
Pins:
- nyx.0.dac-CH.value (float, in) - DAC output voltage, values 0..scale give 0..10V
yio
Connected YIO modules are detected, pins are created for each on nyx module load. ID is by DIP switches, 00 thru 15.
Pins:
- nyx.0.yio-ID.in-NN (bit, out) - a state of digital input NN 00 thru 15(1f)
- nyx.0.yio-ID.in-NN-not (bit, out) - a state of digital input NN 00 thru 15(1f)
- nyx.0.yio-ID.out-NN (bit, in) - set output NN 00 thru 15(1f)
- nyx.0.yio-ID.alarm (bit, out) - true if serial connection to the module is interrupted or fault is reported by the I/O module
- nyx.0.yio-ID.error-cnt (s32, out) - communication error counter
YO32P pins:
- nyx.0.yio-ID.vb1 (float, out) - 00..0f output driver field voltage supply
- nyx.0.yio-ID.vb2 (float, out) - 10..1f output driver field voltage supply
- nyx.0.yio-ID.t1 (float, out) - 00..0f output driver temperature, degrees centigrade
- nyx.0.yio-ID.t2 (float, out) - 10..1f output driver temperature, degrees centigrade
- nyx.0.yio-ID.i-NN (float, out) - digital output NN 00 thru 1f current, mA
- nyx.0.yio-ID.v-NN (float, out) - digital output NN 00 thru 1f voltage, V
- nyx.0.yio-ID.pull-down (bit, in) - disable weak pull-ups on outputs
YAO2 params:
- nyx.0.yio-ID.encoder-NN.cpr (float, rw) - counts per revolution
- nyx.0.yio-ID.encoder-NN.min-speed-estimate (float, rw) - the minimum velocity at it will be reported as nonzero
- nyx.0.yio-ID.encoder-NN.x4-mode (bit, rw) - when true (the default), the counter counts each edge of the quadrature waveform (four counts per full cycle)
YAO2 pins:
- nyx.0.yio-ID.dac-NN.value (float, in) - DAC output voltage, values -scale..scale give -10V..10V
- nyx.0.yio-ID.dac-NN.bias (float, in) - DAC offset. output voltage = 10V * (value / scale + bias)
- nyx.0.yio-ID.dac-NN.scale (float, in)
- nyx.0.yio-ID.encoder-NN.index-enable (bit, io) - encoder Z index enable
- nyx.0.yio-ID.encoder-NN.pos (float, out) - counts / cpr
- nyx.0.yio-ID.encoder-NN.velocity (float, out)
- nyx.0.yio-ID.encoder-NN.velocity-rps (float, out)
- nyx.0.yio-ID.encoder-NN.counts (s32, out)
Absolute encoder support
Motors with absolute encoders allow to skip LinuxCNC homing operation on each startup. Patched version
of LinuxCNC adds the folloing pins to halui module:
- halui.joint.n.set-homed (bit, in) - set axis "homed"
state to true for current offsets without actually performing a homing
operation
Those pins can be connected to
net x-abs-ok halui.joint.0.set-homed <= nyx.0.servo-00.abs-ok
net x-abs-lost halui.joint.0.unhome <= nyx.0.servo-00.abs-lost
To enable absolute encoder mode, set parameters:
- MR-J2(S)-B: No.1=0001
- MR-J3/J4-B: PA03=0001
- MDS-x-V: SV017 bit 7 (0080)
- SGDS: Pn002=_0__
For Yaskawa drives write Pn002 to NVRAM. Start LinuxCNC and execute the following commands (should be in servo-off):
$ sudo nyxq servo pwnv 0-2:Pn002=0x13 # axes 0..2. power cycle amps, will show A.810
$ sudo nyxq servo abs 0 1 2 # execute encoder setup op and power cycle again
Add [JOINT_n]ABSOLUTE_ENCODER=1 var to .ini configuration file. LinuxCNC will save
the motor_offset to the position file instead of current position.
Mitsubishi MDS-x-SP spindle drive sync moves
The mdssp component emulates ABZ incremental encoder using spindle drive postion feedback.
To use it for lathe threading or rigid tapping make sure SP038 bit 2 (0x0004) is set to 1 and make
the following HAL connections:
loadrt mdssp
addf mdssp.0 servo-thread
net s-counts nyx.0.servo-05.counts => mdssp.0.spindle-counts-in
net s-oriented nyx.0.servo-05.spindle-oriented => mdssp.0.spindle-oriented-in
net s-index spindle.0.index-enable => mdssp.0.index-request
net s-revs spindle.0.revs <= mdssp.0.revs
To make emulated spindle index postiion repeatable between LinuxCNC restarts, execute the "orient spindle" op once.
Z-index homing
When using MR-J3-BS or MR-J4-B-RJ amps in fully-closed mode with an ABZ incremental linear/rotary load-side encoder
LinuxCNC's Z-index homing is supported. To use it add to HAL/INI:
net x-home nyx.0.servo-00.di3 => joint.0.home-sw-in
net x-index nyx.0.servo-00.index-enable <=> joint.0.index-enable
net x-homing nyx.0.servo-00.undroop <= joint.0.homing
HOME_USE_INDEX = YES
ABSOLUTE_ENCODER = 0
Z-index homing is also supported with SSCNET III/H and Mechatrolink I, II since fw 3.0.10, MDS-A/B/C-V since 3.4.0
nyxq utility
- Card firmware information
$ sudo nyxq info
NYX v2.4.0 YMDS2P -- Jun 2 2020 20:16:07, http://yurtaev.com
axes:7 mds:7 gpi:12+17 gpo:8 enc:2+4 dac:2 yio:12
Servo information
$ sudo nyxq servo info
SSCNET III 8 axes replied:0 online:1
0: [e9] pos= 2113657638 vel=0.0 trq=0.0 inp wrn
Servo parameters writing/reading
$ sudo nyxq servo pw 0,2:pa9=10
$ sudo nyxq servo pr 0-2:PA9 # works for SSCNET-III and Mechatrolink-II only
0:P9=10 0xa
1:P9=12 0xc
2:P9=10 0xa
I/O monitor
$ sudo nyxq io
ENC0..5: 45656 0 0 0 0 0
DAC0..1: 0 0
------- fedcba9876543210fedcba9876543210
GPI: -11-111-111111111------------
GPO: --------
0: YI16 ----------1--111
1: YO16 ---------------1
2: YI32 -------------------------------1
3: YO32 -------------------------------1
------- fedcba9876543210fedcba9876543210