Code for Controlling Screw-Drive Unit by Using Raspberry Pi Pico, URL: https://www.raspberrypi.com/products/raspberry-pi-pico/
Install build tools
sudo apt-get install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential
sudo apt-get install pkg-config libusb-1.0-0-dev
Get the source with the following directory structure:
~/screw_drive_unit_pico/
pico-sdk/
pico-examples/
screw_drive_unit_pico/
Update submodules
git submodule update --init
cd pico-sdk
git submodule update --init
Set up the user environment variable, and modify $HOME with the path of the repository:
cd ~
echo "export PICO_SDK_PATH=$HOME/screw_drive_unit_pico/pico-sdk" >> ~/.bashrc
. ~/.bashrc
How to build
cd ~/screw_drive_unit_pico/screw_drive_unit_pico
mkdir build
cd build
cmake .. -DPICO_BOARD=pico_w -DCMAKE_BUILD_TYPE=Release
make
How to load program
- Hold down the BOOTSEL button on your Pico-series device while plugging it into your development device using a micro USB cable to force it into USB Mass Storage Mode.
- Copy main.uf2 in build folder into the USB Mass Storage Mode.
Website: https://www.waveshare.com/wiki/Pico-CAN-B
App | msg[0] | msg[1] | msg[2] | msg[3] | msg[4~7] |
---|---|---|---|---|---|
frame structure | header | header | Instruction | Register | Data(uint32_t): msg[4]=L ~ msg[7]=H |
Value | Insruction | Description |
---|---|---|
0x02 | Read | Instruction to read data from the Device |
0x03 | Write | Instruction to write data on the Device |
R/W | Register | Data |
---|---|---|
R | 0x01 | unique board ID |
R/W | 0x02 | Unit CAN ID: Standard ID(uint16_t): msg[6]=High 8 bits, msg[7]=L 3 bits |
R/W | 0x03 | LED Enable/Disable |
R/W | 0x04 | LED Status, On: 1, Off: 0 |
R/W | 0x05 | Motor Command |
R/W | 0x06 | Joint 1 Command |
R/W | 0x07 | Joint 2 Command |
R/W | 0x08 | Joint 1 Torque Enable |
R/W | 0x09 | Joint 2 Torque Enable |
Pico has a 2MB flash starting from address 0x10000000.
R/W | Register | Data |
---|---|---|
R/W | 0x10000000 | Unit CAN ID: High 8 bits |
R/W | 0x10000001 | Unit CAN ID: Low 3 bits |
https://github.com/KangLin/SerialPortAssistant Change port permission:
sudo chmod 666 /dev/ttyUSB0
Memory usage is different from that of a general microcontroller like Stm32.