Template: Pico Motor Driver Guide

From Waveshare Wiki
Revision as of 02:42, 11 November 2022 by Eng35 (talk | contribs) (→‎Raspberry Pi)
Jump to: navigation, search

Pico Quick Start

Download Firmware

  • MicroPython Firmware Download

MicroPython Firmware Download.gif

  • C_Blink Firmware Download

C Blink Download.gif

Hardware connection

Attach the Pico on the driver board, please take care of the direction according to the USB port silk screen printing.
Pico-Motor-Driver-5.jpg

Setup environment

Please refer to Raspberry Pi's guide: https://www.raspberrypi.org/documentation/pico/getting-started/

Use in the Raspberry Pi environment

Dowload Demo

1. Open a terminal of Raspberry Pi
2. Download and unzip the demo codes

sudo apt-get install p7zip-full
cd ~
sudo wget  https://www.waveshare.com/w/upload/5/5c/Pico-Motor-Driver-code.7z
7z Pico_pico-Motor-Driver-code.7z -o./pico-Motor-Driver-code.7z
cd ~/pico-Motor-Driver-code

C

  • The following tutorial is operated on Raspberry Pi, but due to the multi-platform and portable characteristics of cmake, it can be compiled successfully on PC, but the operation is slightly different, and users need to judge by themselves.

To compile, make sure you are in the c directory:

cd ~/pico-Motor-Driver-code/c/

Create and enter the build directory in the folder, and add the SDK: where ../../pico-sdk is the directory of your SDK. There is a build in our sample program, just enter it directly

cd build
export PICO_SDK_PATH=../../pico-sdk
(Note: Be sure to write the path where your own SDK is located)

Execute cmake to automatically generate Makefile files

cmake..

Execute make to generate executable files, the first compilation time is relatively long

make -j9

After the compilation is complete, the uf2 file will be generated. Press and hold the button on the Pico board, connect the pico to the USB port of the Raspberry Pi through the Micro USB cable, and release the button. After connecting, the Raspberry Pi will automatically recognize a removable disk (RPI-RP2), and copy the main.uf2 file in the build folder to the recognized removable disk (RPI-RP2).

cp main.uf2 /media/pi/RPI-RP2/

python

Run in Raspberry Pi

  • Hold the BOOTSET key of the Pico board, then connect the Pico to Raspberry Pi by USB cable, then release the key.
  • Once the removable disk (RPI-RPI2) is recognized, copy the rp2-pico-20210418-v1.15.uf2 file to pico.
  • Open the Thonny IDE in Raspberry Pi, update it if it doesn't support Pico
  • Configure the port by choosing MicroPython(Raspberry Pi and ttyACM0 port) in Tools -> Options... -> Interpreter

Pico-lcd-0.96-img-config2.png
If your Thonny doesn't support Pico, you can update it with the following command:

sudo apt upgrade thonny
  • Choose File->Open...->python/ and select the corresponding .py file to run the codes

Use in Windows

  • 1. Press and hold the BOOTSET button on the Pico board, connect the pico to the USB port of the computer through the Micro USB cable, and release the button after the computer recognizes a removable hard disk (RPI-RP2).
  • 2. Copy the rp2-pico-20210418-v1.15.uf2 file in the python directory to the recognized removable disk (RPI-RP2).
  • 3. Open Thonny IDE (Note: Use the latest version of Thonny, otherwise there is no Pico support package, the latest version under Windows is v3.3.3).
  • 4. Click Tools->Settings->Interpreter, select Pico and the corresponding port as shown in the figure.

Pico-lcd-0.96-img-config.png

  • 5. File -> Open -> the corresponding .py file, click to run, as shown in the following figure:

Pico-Thonny-v1.15.jpg