Skip to the content
2 layers56.5 × 65 mmCore automatic robot raspberrypi extension pcb, the printed circuit board in 3D

Core automatic robot raspberrypi extension pcb

scramble-robot/CoRE_AutoRobot_2024_raspberrypi

# Uncomment some or all of these to enable the optional hardware interfaces #dtparam=i2carm=on #dtparam=i2s=on dtparam=spi=on

Size
56.5 × 65 mm
Copper layers
2
Thickness
1.6 mm
Parts
26
Nets
52
Pads
118
Tracks, vias
252, 19
Pours
1
Routed
Yes
KiCad
KiCad 7 (file 20221018)
Created
18 Sep 2023
Updated
7 Mar 2025

Overview

Core automatic robot raspberrypi extension pcb is an open-source printed circuit board by scramble-robot, from the scramble-robot/CoRE_AutoRobot_2024_raspberrypi repository on GitHub, published under the Apache-2.0 licence. It is a 2-layer board of 56.5 × 65 mm with 26 parts on 52 nets, routed with 252 tracks and 19 vias.

It is built around the TJA1051T/3/1 and B2P-VH. Its parts include 10 connectors, 5 capacitors, 3 resistors, 2 ICs and 1 crystal. It belongs with the robots and motor control boards of this library.

Main components

2

README

README.md

SDカード

  1. Raspberry Pi ImagerでRaspberry Pi OS Lite (64-bit,bullseye)をMicro SDに書き込む。Imagerの設定でユーザ名piとパスワードを予め設定すること。
  2. Micro SDに作成された"bootfs"ドライブ直下にsshという名前のファイルを配置してSSHを有効化する。
  3. OS起動後、本レポジトリのros2_ws及びserviceディレクトリをホームディレクトリ(/home/pi/)にコピーする。

C620とのCAN通信

MCP2515を用いてSPIからCANを制御

ハードウェア

1Mbpsの通信を行うために、水晶振動子を16MHzに交換すること

CAN-BUSの有効化

  1. /boot/config.txtを編集してSPIとMCP2515を有効化する

    bash
    sudo vi /boot/config.txt
    text
    # Uncomment some or all of these to enable the optional hardware interfaces
    #dtparam=i2c_arm=on
    #dtparam=i2s=on
    dtparam=spi=on
    
    # MCP2515
    dtparam=spi=on
    dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
    dtoverlay=spi-bcm2835-overlay
  2. 初期化できているか確認

    text
    dmesg | grep mcp251x

can-utilsのインストール

bash
sudo apt install can-utils

通信テスト

1Mbpsでlink up

bash
sudo ip link set can0 type can bitrate 1000000 loopback off
sudo ip link set can0 up
sudo ifconfig can0 txqueuelen 1000
sudo ifconfig

受信テスト

bash
candump can0

C620と通信できていると、以下のようなデータが受信される。

text
  can0  201   [8]  0E 16 00 00 FF FD 21 00
  can0  201   [8]  0E 16 00 00 FF FD 21 00
  can0  201   [8]  0E 16 00 00 FF BE 21 00
  can0  201   [8]  0E 16 00 00 FF FD 21 00
  can0  201   [8]  0E 16 00 00 00 3D 21 00

送信

モータ回るはず

bash
cansend can0 200#0200000000000000

systemdによるCANバスの自動有効化

  1. systemdの設定

    bash
    sudo vi /etc/systemd/network/80-can.network
    text
    [Match]
    Name=can*
    
    [CAN]
    BitRate=1000000

    設定後、以下コマンド実行

    bash
    sudo systemctl enable systemd-networkd
    sudo systemctl start systemd-networkd
  2. txqueuelenの自動設定

    bash
    sudo vi /etc/udev/rules.d/71-can-txqueuelen.rules
    text
    SUBSYSTEM=="net", ACTION=="add|change", KERNEL=="can*", ATTR{tx_queue_len}="1000"
  3. 再起動後、ifconfigでlink upしていることを確認

    text
    can0: flags=193<UP,RUNNING,NOARP>  mtu 16
            unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Pythonからの制御

bash
pip install python-can
python
import can
import struct
import time


bus = can.interface.Bus(bustype="socketcan", channel="can0", bitrate=1000000)

def set_current(bus, currents):
    d = [0]*8
    raw_array = [0]*4
    for i in range(4):
        v = int(round(currents[i]/20 * 16384))
        v = min(v, 16384)
        v = max(v, -16384)
        raw_array[i] = v
    b = struct.pack('>4h', *raw_array)
    msg = can.Message(arbitration_id=0x200, is_extended_id=False, data=b)
    bus.send(msg)

def parse_c620_data(msg: can.Message):
    data = struct.unpack('>hhhbb', msg.data)
    degree = data[0]/ 8192 * 360
    rpm = data[1]
    current = data[2]/16384*20

サーボモータ

ハードウェア

  • 信号線はGPIO17に接続
  • サーボモータの5Vは外部電源から取ること

requirements

bash
sudo apt install -y pigpio python3-pigpio
sudo pigpiod
sudo systemctl enable pigpiod

動作確認

python
import pigpio

output_pin = 12 # 12 or 13


def setServoDegree(pi, output_pin, degree):
    min_width = 500
    max_width = 2500
    deg_range = 270
    output = degree / deg_range
    output *= max_width - min_width
    output += min_width
    output = int(output)
    pi.set_servo_pulsewidth(output_pin, output)


pi = pigpio.pi()
pi.set_mode(output_pin, pigpio.OUTPUT)
pi.set_servo_pulsewidth(output_pin, 0)

while True:
    print("input Duty Cyle (0 - 270)")
    degree = float(input())
    setServoDegree(pi, output_pin, degree)

ROS2のインストール

Raspbian OS用の、非公式のdebパッケージを使ってインストールする

bash
wget https://github.com/Ar-Ray-code/rpi-bullseye-ros2/releases/download/ros2-0.3.1/ros-humble-desktop-0.3.1_20221218_arm64.deb
sudo apt install ./ros-humble-desktop-0.3.1_20221218_arm64.deb
sudo pip install vcstool colcon-common-extensions

echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
source ~/.bashrc

ROS2パッケージのビルド

text
cd ~/ros2_ws
colcon build --symlink-install
source install/local_setup.bash
echo "source ~/ros2_ws/install/setup.bash" >> ~/.bashrc

ROS2ノードの実行

bash
ros2 launch scramble_auto_robot hardware.launch.py
  • この段階で下記のようなエラーが出る場合は,Raspberry piのOSのバージョンが誤っているためSDカード作成からやり直す必要がある.OSのバージョンはbullseyeを指定すること(何も指定しないと最新版のbookwormがインストールされる)
[INFO]
[INFO] [launch]: Default logging verbosity is set to INFO
[ERROR] [launch]: Caught exception in launch (see debug for traceback): Caught exception when trying to load file of format [py]: No module named 'rclpy._rclpy_pybind11'
The C extension '/opt/ros/humble/lib/python3.9/site-packages/_rclpy_pybind11.cpython-311-aarch64-linux-gnu.so' isn't present on the system. Please refer to 'https://docs.ros.org/en/humble/Guides/Installation-Troubleshooting.html#import-failing-without-library-present-on-the-system' for possible solutions

確認

bash
ros2 topic pub /can_node/c620_0/target_current std_msgs/Float64 "{data: 1.0}"
ros2 topic pub /can_node/c620_0/target_current std_msgs/Float64 "{data: 0.0}"
ros2 topic pub /servo0/degree std_msgs/Float64 "{data: 0}"
ros2 topic pub /servo1/degree std_msgs/Float64 "{data: 0}"
ros2 topic echo /can_node/c620_0/rpm

自動起動

bash
sudo ln -s /home/pi/service/scramble_auto_robot_ros2.service /etc/systemd/system
chmod 755 /home/pi/service/ros2_launch.sh
sudo systemctl enable scramble_auto_robot_ros2.service
sudo systemctl start scramble_auto_robot_ros2.service
systemctl status scramble_auto_robot_ros2.service

起動オプションの変更

  1. ターミナルでsudo raspi-configを実行
  2. "1. System Options"を選択
  3. "S6 Network as Boot"でネットワーク確率までBootを待つように設定
  4. "S5 Boot / Auto Login"で"Console Autologin"を選択

SDカードのRead only化

SDカードへの書き込み中に電源を抜くとSDカードが壊れる可能性があるので、read-onlyに設定する。

参考: Raspberry Pi で Overlay File System (read-only file system) を試す

  1. ターミナルでsudo raspi-configを実行
  2. "4 Performance Options Configure performance settings"
  3. "P3 Overlay File System Enable/disable read-only file system"
  4. 有効化して再起動

その他

  • ros2_launch.shにてROS_DOMAIN_ID=0に設定しています。
  • デフォルトの設定ではIPアドレスの割当はDHCPで行われます。

Third-party license

本手順で作成した場合、以下のサードパーティ製ソフトウェアがインストールされます。 (本レポジトリに直接は含まれていません)

デバッグ用

Parts

26
QtyValueFootprintReferences
4Conn_01x04_PinConnector_JST:JST_XH_B4B-XH-A_1x04_P2.50mm_VerticalJ7, J8, J9, J10
4MountingHoleMountingHole:MountingHole_3.2mm_M3H1, H2, H3, H4
30.1uCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderC3, C4, C5
222pCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderC1, C2
24.7kResistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR1, R2
2Conn_01x03_PinConnector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_HorizontalJ3, J4
2PH_B2BConnector_JST:JST_PH_B2B-PH-K_1x02_P2.00mm_VerticalJ5, J6
1120Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR3
116MCrystal:Crystal_HC49-U_VerticalY1
1B2P-VHConnector_JST:JST_VH_B2P-VH-B_1x02_P3.96mm_VerticalJ2
1Conn_02x20_Odd_EvenConnector_PinHeader_2.54mm:PinHeader_2x20_P2.54mm_VerticalJ1
1MCP2515-xSOPackage_SO:SOIC-18W_7.5x11.6mm_P1.27mmU1
1SolderJumper_2_OpenJumper:SolderJumper-2_P1.3mm_Open_Pad1.0x1.5mmJP1
1TJA1051T-3Package_SO:SOIC-8_3.9x4.9mm_P1.27mmU3

Similar boards

  • 4 layers152.4 × 152.4 mmCSTAR, the printed circuit board in 3D

    CSTAR

    GenerateNU/Concrete

    192 parts1
  • 4 layers76.2 × 50.8 mmSpeaker amp, the printed circuit board in 3D

    Speaker amp

    AMuszkat/bpi_amp_platform

    Banana pi cm4io class D amp board based on MAX98397

    119 parts
  • 4 layers100 × 100 mmSmc power, the printed circuit board in 3D

    Smc power

    efebasol/StepperMotorController

    Rev A — single-motor bench prototype power board. Feeds the driver board (48 V), the stepper motor brake (24 V) and the logic (5 V / 3V3).

    104 parts
  • 2 layers99.1 × 63.6 mmBehlkeswitcher, the printed circuit board in 3D

    Behlkeswitcher

    gasperhauptman/Behlke-HV-switcher

    44 parts
  • 6 layers7.5 × 1.3 mmPCBWearable, the printed circuit board in 3D

    PCBWearable

    GEEGABYTE1/eeProjects

    Repository for all stuff EE and CE⚡️

    82 parts
  • 2 layers65 × 56 mmTeamc carrier, the printed circuit board in 3D

    Teamc carrier

    SantiBarrios2002/mtp-f26-teamc

    MTP F26 (UPC) Team C workspace: radio link budget, RFM69 firmware, protocol simulator

    94 parts
  • 4 layers198.9 × 130 mm640A PowerAmp, the printed circuit board in 3D

    640A PowerAmp

    SSSound13/Cambridge_640A_PowerAmp

    Replacement 4-layer KiCad PCB for the Cambridge Audio Azur 640A (V1) power amp board AP12707/6

    296 parts

Questions

How big is the Core automatic robot raspberrypi extension pcb PCB?

It measures 56.5 × 65 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Core automatic robot raspberrypi extension pcb use?

26 parts, built around the TJA1051T/3/1 and B2P-VH. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Core automatic robot raspberrypi extension pcb KiCad files?

From the scramble-robot/CoRE_AutoRobot_2024_raspberrypi repository on GitHub, at the commit this page was made from: the board is kicad/core_automatic_robot_raspberrypi_extension_pcb.kicad_pcb and its schematic kicad/core_automatic_robot_raspberrypi_extension_pcb.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Core automatic robot raspberrypi extension pcb design in my own project?

Its repository publishes it under the Apache-2.0 licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).