/HAL2UDP

External step generator and IO interface for LinuxCNC over Ethernet with dual-core ESP32 and W5500 modules.

Primary LanguageC++GNU General Public License v2.0GPL-2.0

HAL2UDP

External step generator and IO interface for LinuxCNC over Ethernet with dual-core ESP32 and W5500 modules.

The hardware is connected to LinuxCNC over Ethernet. The controller operates in position mode at low speed and at higher speeds in velocity mode.

video on operation

Features

  • step and dir signals for 3 axes
  • 8 input pins
  • 6 output pins, any can be pwm signal
  • step frequency up to 40 kHz

Install

Clone this repository and open it with platformIO

Settings

set your eth0 to 192.168.96.55
(the Esp32 with Ethernet will have 192.168.96.54)

LinuxCNC driver

sudo apt-get install linuxcnc-uspace-dev build-essential
sudo halcompile --install udp.comp

Hardware

ESP-WROOM-32 dev board + W5500 ethernet module

ESP32 3v3 -- 3v3 W5500
ESP32 GND -- GND W5500

GPIO 1 -> OUT-03 or PWM-03
GPIO 2 -> OUT-00 or PWM-00 & onboard blue LED
GPIO 4 -> OUT-01 or PWM-01
GPIO 5 -> W5500 SCS
GPIO 12 -> step-0
GPIO 13 -> dir-0
GPIO 14 -> OUT-04 or PWM-04
GPIO 15 -> OUT-05 or PWM-05
GPIO 16 -> step-1
GPIO 17 -> dir-1
GPIO 18 -> W5500 SCLK
GPIO 19 <- W5500 MISO
GPIO 21 -> step-2
GPIO 22 -> dir-2
GPIO 23 -> W5500 MOSI
GPIO 25 -> OUT-02 or PWM-02
GPIO 26 <- IN-00 {pullup}
GPIO 27 <- IN-01 {pullup}
GPIO 32 <- IN-02 {pullup}
GPIO 33 <- IN-03 {pullup}
GPIO 34 <- IN-04 {no pullup!}
GPIO 35 <- IN-05 {no pullup!}
GPIO 36 <- IN-06 {no pullup!}
GPIO 39 <- IN-07 {no pullup!}

LinuxCNC HAL pins

udp.0.position_cmd (in - float) commanded position in position units
udp.1.position_cmd
udp.2.position_cmd

udp.0.velocity_cmd (in - float) commanded velocity in position units/s
udp.1.velocity_cmd
udp.2.velocity_cmd

udp.0.position_fb (out - float) feedback position in position units
udp.1.position_fb
udp.2.position_fb

udp.0.velocity_fb (out - float) feedback velocity in position units/s
udp.1.velocity_fb
udp.2.velocity_fb

udp.out.00 (in - bit) digital output
udp.out.01
udp.out.02
udp.out.03
udp.out.04
udp.out.05

udp.pwm.00 (in - float) PWM output 0...1
udp.pwm.01
udp.pwm.02
udp.pwm.03
udp.pwm.04
udp.pwm.05

udp.in.00 (out - bit) digital input
udp.in.01
udp.in.02
udp.in.03
udp.in.04
udp.in.05
udp.in.06
udp.in.07

udp.ready (out - bit) module state
udp.enable (in - bit) module enable
udp.packets (out - s32) lost packets

LinuxCNC HAL parameters

udp.0.dirsetup (rw - u32) minimum time from a direction change to the beginning of the next step pulse in ns
udp.1.dirsetup
udp.2.dirsetup

udp.0.scale (rw - float) steps per position unit
udp.1.scale
udp.2.scale

udp.0.accel (rw - float) acceleration in position units/s2
udp.1.accel
udp.2.accel

udp.pwm.00.freq (rw - u32) PWM frequency in Hz 0..65000
udp.pwm.01.freq
udp.pwm.02.freq
udp.pwm.03.freq
udp.pwm.04.freq
udp.pwm.05.freq

PWM usage

If the udp.pwm.xx.freq parameter is set to 0, the udp.out.xx pin works and the udp.pwm.xx pin does not.
If the value of the udp.pwm.xx.freq parameter is not 0, the udp.out.xx pin does not work and the udp.pwm.xx pin does.