Snippets

Alex Sharikov Setup EtherCAT master on RPI 4 with NodeJS (using Etherlab)

Created by Alex Sharikov last modified

Raspberry Pi 4 Model B 4GB:

pi@raspberrypi:~ $ node -v
v14.18.2

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 5.10.63-v7l+ #1459 SMP Wed Oct 6 16:41:57 BST 2021 armv7l GNU/Linux

pi@raspberrypi:~ $ lsb_release -a
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 11 (bullseye)
Release:    11
Codename:   bullseye
# Setup the RasbianOS as usual. It's recommended to have the two Ethernet cards: eth0 for EtherCAT and eth1 for other purposes.
# Example of seting up static IPs: 
# $ sudo nano /etc/dhcpcd.conf
# interface eth0
#     static ip_address=192.168.88.1/24
# interface eth1
#     static ip_address=192.168.1.1/24
# 


# SSH to the PI and run the following commands
$ curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
$ sudo apt-get update && sudo apt-get upgrade

$ sudo apt install -y build-essential git bc bison flex libssl-dev libtool automake tree dkms nodejs

$ sudo apt-get install mercurial

$ sudo apt-get update && sudo apt-get upgrade
$ sudo apt install -y raspberrypi-kernel-headers
$ git clone https://github.com/icshwi/etherlabmaster
$ cd etherlabmaster
$ make init

# replace old `etherlab` source with the new one

$ rm -rf etherlabmaster-code
$ git clone https://gitlab.com/etherlab.org/ethercat.git etherlabmaster-code

# continue with the installation of the EtherCAT library

# !!!!!!IMPORTANT TSC not availbe in ARM (Set ENABLE_CYCLES=NO)!!!!!!! 
$ echo "ENABLE_CYCLES = NO" > configure/CONFIG_OPTIONS.local
$ make build
$ make install
$ echo "ETHERCAT_MASTER0=eth0" > ethercatmaster.local
$ make dkms_add
$ make dkms_build
$ make dkms_install
$ make setup
$ sudo reboot
1
2
3
4
5
6
7
$ mkdir nodejs_ethercat
$ npm init
$ npm install etherlab-nodejs

# Look for examples at https://github.com/STECHOQ/etherlab-nodejs/tree/main/sample
# Create the slaves.json
# Create the main.js to test the 

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.