Control Box

This page introduces the control box, connecting other devices together for data streaming and power support. The core module is Raspberry Pi 5 equipped with a CAN FD HAT board. There are two CAN interfaces to connect to the gripper, and an RJ45 interface to connect to the local network.

Preview

MagiClaw control box

Specifications

Parameters
Description

Module

Raspberry Pi 5 8GB

CPU

Arm Cortex-A76, 2.4GHz quad-core 64-bit

GPU

VideoCore VII

Memory

8GB SDRAM

Power Supply

24V/5A DC via XT30

Wi-Fi

Dual-band 802.11ac

Bluetooth

Bluetooth 5.0/ BLE

Storage

1 x microSD card slot, with support for high-speed SDR104 mode

Ethernet

1 x RJ45 (1000 Mbps)

Display Output

2 x micro HDMI ports (4Kp60)

USB

2 x USB 3.0, 2 x USB 2.0

CAN

2 x CAN (XT30 2+2)

Dimensions (W x D x H)

91mm * 61mm * 38mm

Weight

153g

Operating Temperature

0 ~ 45℃

Flash Raspberry Pi OS

For a new control box, the first step is to flash Raspberry Pi OS on an SD card. Please follow the steps below:

1

Download Raspberry Pi Imager software by visiting official link.

2

Open Raspberry Pi Imager software.

3

Press CTRL + SHIFT + X on the keyboard to open OS Customisation settings.

Here you can set a hostname, set a password, enable SSH and more.

4

Click CHOOSE DEVICE and select Raspberry Pi 5.

5

Click CHOOSE OS and select Raspberry Pi OS (64-bit).

6

Click CHOOSE STORAGE and select the connected SD card.

7

Finally, click NEXT.

Please wait a few minutes until the flashing process is complete.

8

Eject the SD card and insert it into the Raspberry Pi 5. Then connect the power supply.

9

Update and upgrade:

sudo apt update
sudo apt upgrade

Log in to Raspberry Pi OS via SSH

SSH (Secure SHell) provides secure access to a terminal session on your Raspberry Pi.

INFO

If you have enabled SSH using Raspberry Pi Imager, you can skip steps 1 and 2.

1

For Wi-Fi connection, click the Wi-Fi icon on the top right corner of the Raspberry Pi OS Desktop, select your Wi-Fi network and enter the password. For Ethernet connection, connect an ethernet cable from your router to the ethernet port of the control box.

2

Open a Terminal and run

sudo raspi-config

Select Interface Options -> SSH -> Yes to enable SSH server.

WARNING

3

Configure the connection settings on the PC. Open Terminal and run

# SSH by IP
ssh <username>@<ip address>
# SSH by hostname
ssh <username>@<hostname>.local

where <username> is the user name configured during flashing OS, <ip address> is the IP address of the control box which can be found on the router setting page or ifconfig on the control box, and <hostname> is the hostname also configured during flashing OS. Both of them are capable, just select your preferred way. Type yes for the following message

ECDSA key fingerprint is SHA256:XXXXXXX.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

Then enter the password according to your settings. If you have successfully logged in to the Raspberry Pi OS, you will see the following output

Log in to Raspberry Pi OS via VNC

VNC (Virtual Network Computing) provides secure access to a desktop screen share on your Raspberry Pi. Raspberry Pi OS includes wayvnc. This provides a VNC server that you can enable in your device preferences. Before you can use VNC on your Raspberry Pi, you must enable the VNC server.

1

Open a Terminal and run

sudo raspi-config

Select Interface Options -> VNC -> Yes to enable VNC server.

WARNING

2

Download and launch RealVNC on your PC.

3

Enter the IP address of the control box.

4

When prompted for a username and password, enter your credentials.

5

Click the "OK" button to authenticate with the VNC server. If your credentials are correct, RealVNC should open a window containing the desktop of the control box.

Hardware Usage

Power

The control box is equipped with a 24V (XT30) power interface, making it suitable for the servo motor in the gripper.

Display

The control box provides two micro HDMI ports (4K60), and the right one is the default port for display.

Ethernet

The control box provides an RJ45 port with up to 1000Mbps, which is the only way to communicate with other control boxes or PCs by connecting to a local network.

USB

The control box has a total of 4 USB ports: 2 USB 3.0 ports, and 2 USB 2.0 ports. Their arrangement order is consistent with the default settings of Raspberry Pi 5.

WiFi

The WiFi chip of the control box is set to AP mode for connecting Metafinger and iPhone, so it cannot be used to connect to any other WiFi. It is set at 5GHz to achieve high data bandwidth. The default name is consistent with the hostname, and the default password is 12345678.

Here we provide several steps to set the WiFi to AP mode.

INFO

All steps below are included in the setup.sh in Installation. If you have already run the bash file successfully, you can skip the following part.

1

Open a Terminal and run

sudo raspi-config

Select Localisation Options -> WLAN Country and set the legal wireless channels.

2

Install hostapd, dhcpcd, and dnsmasq by running the following command

sudo apt install hostapd dhcpcd5 dnsmasq
3

Open /etc/hostapd/hostapd.conf, and add

interface=wlan0
driver=nl80211
ssid=rpi5_5g
hw_mode=a
ieee80211n=1
ieee80211ac=1
require_ht=1
require_vht=1
wmm_enabled=1
country_code=US
ht_capab=[HT40-][HT40+][SHORT-GI-40][DSSS_CCK-40]
channel=149
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP

WARNING

4

Open /etc/default/hostapd and modify DAEMON_CONF as

DAEMON_CONF="/etc/hostapd/hostapd.conf"
5

Open /etc/dhcpcd.conf, and add

interface wlan0
    static ip_address=192.168.4.1/24
    nohook wpa_supplicant
6

Open /etc/dnsmasq.conf, and add

interface=wlan0
dhcp-range=192.168.4.2,192.168.4.254,255.255.255.0,24h
7

Disable NetworkManager for wlan0 by opening or creating a new file /etc/NetworkManager/conf.d/10-ignore-wlan0.conf, and add

[keyfile]
unmanaged-devices=interface-name:wlan0
8

Start wlan0 by running

sudo ip link set wlan0 up
9

Stop and restart all services by running the following command

sudo systemctl unmask hostapd
sudo systemctl unmask dhcpcd
sudo systemctl unmask dnsmasq
sudo systemctl enable hostapd
sudo systemctl enable dhcpcd
sudo systemctl enable dnsmasq
sudo systemctl start hostapd
sudo systemctl start dhcpcd
sudo systemctl start dnsmasq
sudo systemctl restart NetworkManager
10

View wlan0 interface by running

ifconfig

INFO

If wlan0 doesn't have IPV4 address, try to reboot the control box.

11

If devices connected to Raspberry Pi 5, check them by running

arp -a

INFO

To test network bandwidth between MagiClaw-RPI5 and connected devices, you can use iperf3, etc.

WARNING

CAN

The control box is equipped with two CAN ports (XT30 2+2). Since the Raspberry Pi does not support CAN, we use a CAN controller (MCP2518FD) with SPI interface and a transceiver to complete CAN function.

Here we demonstrate sending data from CAN0 to CAN1. First, connect the signal lines of CAN0_H to CAN1_H and CAN0_L to CAN1_L. Then, open terminal and install can-utils:

sudo apt install can-utils

Open a Terminal 1 and enter the following command to receive data from CAN0:

candump can0

Open a Terminal 2 and enter the following command to receive data from CAN1:

cansend can1 000#11.22.33.44

Then you will see

The output voltage of XT30 2+2 theoretically equals the current DC input voltage of the control box. Since the voltage of the servo motor used in the gripper needs to be 24V, it is important to ensure the input voltage of the control box is also 24V. If you want to know more details, you can refer to the schematic.

Here we provide steps to set the CAN bus.

INFO

All steps below are included in the setup.sh in Installation. If you have already run the bash file successfully, you can skip the following part.

1

Open a Terminal and run

sudo raspi-config

Select Interfacing Options -> SPI -> Yes to enable the SPI interface

2

Open /boot/firmware/config.txt, and add

# CAN
dtparam=spi=on
dtoverlay=spi1-3cs
dtoverlay=mcp251xfd,spi0-0,interrupt=25
dtoverlay=mcp251xfd,spi1-0,interrupt=24
3

If you have modified the WiFi AP mode, open /etc/dhcpcd.conf, and add

denyinterfaces can0
denyinterfaces can1

Then restart Raspberry Pi 5 by running

sudo reboot
4

Set the baud rate, working mode, whether to enable FD and configure the size of the transmission buffer of CAN by

sudo ip link set can0 up type can bitrate 1000000 dbitrate 8000000 restart-ms 1000 berr-reporting on fd on
sudo ip link set can1 up type can bitrate 1000000 dbitrate 8000000 restart-ms 1000 berr-reporting on fd on
sudo ifconfig can0 txqueuelen 65536
sudo ifconfig can1 txqueuelen 65536

WARNING

5

View CAN interface by running

ifconfig
6

To setup CAN interface on boot, create /etc/systemd/system/can-setup.service and add

[Unit]
Description=Setup CAN interfaces on boot
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/local/bin/setup_can.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
7

Create /usr/local/bin/setup_can.sh, and add

#!/bin/bash

# can0
sudo ip link set can0 up type can bitrate 1000000 dbitrate 8000000 restart-ms 1000 berr-reporting on fd on
sudo ifconfig can0 txqueuelen 65536

# can1
sudo ip link set can1 up type can bitrate 1000000 dbitrate 8000000 restart-ms 1000 berr-reporting on fd on
sudo ifconfig can1 txqueuelen 65536
8

Grant execution permission to /usr/local/bin/setup_can.sh

sudo chmod +x /usr/local/bin/setup_can.sh
9

Start can-setup.service by running

sudo systemctl enable can-setup.service
sudo systemctl start can-setup.service

Now the CAN interface will be automatically set up for next time on boot.

FAN

The control box is equipped with a Raspberry Pi official active cooler. We recommend modifying the fan settings in /boot/firmware/config.txt like:

# FAN
dtparam=cooling_fan=on
dtparam=fan_temp0=36000,fan_temp0_hyst=2000,fan_temp0_speed=90
dtparam=fan_temp1=40000,fan_temp1_hyst=3000,fan_temp1_speed=150
dtparam=fan_temp2=52000,fan_temp2_hyst=4000,fan_temp2_speed=200
dtparam=fan_temp3=58000,fan_temp3_hyst=5000,fan_temp3_speed=255

where fan_temp indicates the trigger temperature that will turn on the fan (unit in 0.001 ℃), fan_temp_hyst indicates the temperature reduction that turns off the fan (unit in 0.001 ℃), and fan_temp_speed indicates the fan speed (from 0 to 255).

Conda Environment

Since Raspberry Pi OS Bookworm, users can not install libraries directly into the system version of Python. Instead, install libraries into a virtual environment (venv or conda). Here we select miniconda as the package manager for Python.

1

Create a new directory named miniconda3 in your home directory

mkdir -p $HOME/miniconda3
2

Download the Linux Miniconda installation script for your chosen chip architecture and save the script as miniconda.sh in the miniconda3 directory

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh -O $HOME/miniconda3/miniconda.sh
3

Run the miniconda.sh installation script in silent mode using bash

bash $HOME/miniconda3/miniconda.sh -b -u -p $HOME/miniconda3
4

Remove the miniconda.sh installation script file after installation is complete

rm $HOME/miniconda3/miniconda.sh
5

Close and reopen your terminal application or refresh it by running the following command

source $HOME/miniconda3/bin/activate
6

Initialize conda on all available terminals by running the following command

conda init --all

Now you can reopen the terminal to see whether conda is available.

Bill of Materials

CAD Models

STEP files of all 3D-printed parts are provided on Google Drive. A 3mf file is also provided for 3D printing at .

PCB Files

All PCB files are provided on Google Drive, including schematic, gerber, bom, etc.

Last updated