Skip to content

107-systems/CyphalPicoBase-CAN-firmware

Repository files navigation

💾 CyphalPicoBase/CAN-firmware

General Formatting Checks Spell Check Compile Examples

Firmware for the CyphalPicoBase/CAN board. You can buy one here 💸.

How-to-build/upload

arduino-cli compile -b rp2040:rp2040:rpipico -v .
arduino-cli upload -b rp2040:rp2040:rpipico -v . -p /dev/ttyACM0

or

arduino-cli compile -b rp2040:rp2040:rpipico -v . --build-property compiler.cpp.extra_flags="-DCYPHAL_NODE_INFO_GIT_VERSION=0x$(git rev-parse --short=16 HEAD)"

Adding argument --build-property compiler.cpp.extra_flags="-DCYPHAL_NODE_INFO_GIT_VERSION=0x$(git rev-parse --short=16 HEAD)" allows to feed the Git hash of the current software version to 107-Arduino-Cyphal stack from where it can be retrieved via i.e. yakut.

How-to-yakut

Install and configure yakut:

. setup_yakut.sh

Obtain value of digital input 0 using yakut (cyphal.pub.input0.id = 1001):

y sub 1001:uavcan.primitive.scalar.Bit.1.0 --with-metadata

Quickstart

How-to-configure the Node-ID

Set cyphal.node.idto the desired value, for example 30.

y r 0 cyphal.node.id 30

Store settings to eeprom and restart controller.

y cmd 0 store
y cmd 0 restart

How-to-control the built-in LED

How to control the built-in LED on the Raspberry Pi Pico.

Set cyphal.sub.led1.idto a value different than 65535, for example 100.

y r 30 cyphal.sub.led1.id 100

Store settings to eeprom and restart controller.

y cmd 30 store
y cmd 30 restart

Turn LED on by publishing to Subject-ID 100

y pub -N 1 100:uavcan.primitive.scalar.Bit.1.0 true

Turn LED off by publishing to Subject-ID 100

y pub -N 1 100:uavcan.primitive.scalar.Bit.1.0 false

How-to-control a digital output

How to control digital output 0 and digital output1 of the CyphalPicoBase-CAN.

Set cyphal.sub.output0.idto a value different than 65535, for example 200.

y r 30 cyphal.sub.output0.id 200

Store settings to eeprom and restart controller.

y cmd 30 store
y cmd 30 restart

Turn digital output 0 on by publishing to Subject-ID 200

y pub -N 1 200:uavcan.primitive.scalar.Bit.1.0 true

Turn digital output 0 off by publishing to Subject-ID 200

y pub -N 1 200:uavcan.primitive.scalar.Bit.1.0 false

How-to-control a servo PWM output

How to control the servo PWM outputs 0 and 1 of the CyphalPicoBase-CAN.

Set cyphal.sub.servo0.idto a value different than 65535, for example 300.

y r 30 cyphal.sub.servo0.id 300

Store settings to eeprom and restart controller.

y cmd 30 store
y cmd 30 restart

Turn servo to a dedicated position by publishing to Subject-ID 300. Possible values are between 800 and 2200. Others will be dismissed.

y pub -N 1 300:uavcan.primitive.scalar.Integer16.1.0 1500

Register list

Name Type Default Value Description
cyphal.node.description rw CyphalPicoBase-CAN Node description
cyphal.node.id rw 0 Node id (max 127)
cyphal.pub.analoginput0.id rw 65535 Subject-ID (publish) for analog input 0
cyphal.pub.analoginput0.type ro cyphal.primitive.scalar.Integer16.1.0
cyphal.pub.analoginput1.id rw 65535 Subject-ID (publish) for analog input 1
cyphal.pub.analoginput1.type ro cyphal.primitive.scalar.Integer16.1.0
cyphal.pub.input0.id rw 65535 Subject-ID (publish) for digital input 0
cyphal.pub.input0.type ro cyphal.primitive.scalar.Bit.1.0
cyphal.pub.input1.id rw 65535 Subject-ID (publish) for digital input 1
cyphal.pub.input1.type ro cyphal.primitive.scalar.Bit.1.0
cyphal.pub.input2.id rw 65535 Subject-ID (publish) for digital input 2
cyphal.pub.input2.type ro cyphal.primitive.scalar.Bit.1.0
cyphal.pub.input3.id rw 65535 Subject-ID (publish) for digital input 3
cyphal.pub.input3.type ro cyphal.primitive.scalar.Bit.1.0
cyphal.pub.inputvoltage.id rw 65535 Subject-ID (publish) for input voltage
cyphal.pub.inputvoltage.type ro cyphal.primitive.scalar.Real32.1.0
cyphal.pub.internaltemperature.id rw 65535 Subject-ID (publish) for internal temp
cyphal.pub.internaltemperature.type ro cyphal.primitive.scalar.Real32.1.0
cyphal.sub.led1.id rw 65535 Subject-ID (subscribe) for led1
cyphal.sub.led1.type ro cyphal.primitive.scalar.Bit.1.0
cyphal.sub.lightmode.id rw 65535 Subject-ID (subscribe) for light mode
cyphal.sub.lightmode.type ro cyphal.primitive.scalar.Integer8.1.0
cyphal.sub.output0.id rw 65535 Subject-ID (subscribe) for digital output 0
cyphal.sub.output0.type ro cyphal.primitive.scalar.Bit.1.0
cyphal.sub.output1.id rw 65535 Subject-ID (subscribe) for digital output 1
cyphal.sub.output1.type ro cyphal.primitive.scalar.Bit.1.0
cyphal.sub.servo0.id rw 65535 Subject-ID (subscribe) for servo PWM output 0
cyphal.sub.servo0.type ro cyphal.primitive.scalar.Integer16.1.0
cyphal.sub.servo1.id rw 65535 Subject-ID (subscribe) for servo PWM output 1
cyphal.sub.servo1.type ro cyphal.primitive.scalar.Integer16.1.0
pico.update_period_ms.analoginput0 rw 500 Update period for analog input 0
pico.update_period_ms.analoginput1 rw 500 Update period for analog input 1
pico.update_period_ms.input0 rw 500 Update period for digital input 0
pico.update_period_ms.input1 rw 500 Update period for digital input 1
pico.update_period_ms.input2 rw 500 Update period for digital input 2
pico.update_period_ms.input3 rw 500 Update period for digital input 3
pico.update_period_ms.inputvoltage rw 3000 Update period for input voltage
pico.update_period_ms.internaltemperature rw 10000 Update period for internal temperature
pico.update_period_ms.light rw 250 Update period for light functions