HackerBox 0082: Pico Lab

by HackerBoxes in Circuits > Raspberry Pi

7209 Views, 16 Favorites, 0 Comments

HackerBox 0082: Pico Lab

HB0082 Whole Box.png

Welcome to HackerBox 0082 where we will explore the Raspberry Pi Pico based on the RP2040 Microcontroller. Configure the Pi Pico Arduino Core, C/C++ SDK, CircuitPython, and other development environments for the Raspberry Pi Pico. Assemble the Pico VGA Lab Kit to explore video signal generation along with various other peripheral interfaces. Connect an additional external USB port for host USB power and serial I/O. Assemble the Pico Logic Analyzer Kit. Experiment with retrogaming emulators, ROMs, and game controllers on various platforms.

HackerBox is the original monthly subscription box for electronics, computer technology, and hacker culture. Each HackerBox is a discovery box, which means all members await and enjoy a new surprise each month. Tech, toys, knowledge, and fun. It's like having a hacker convention, your birthday, and the first day of school - every month - right in your mailbox.

There is a wealth of information for current and prospective members in the HackerBoxes FAQ. Almost all of the non-technical support emails that we receive are already answered there, so we'd really appreciate it if you can take a few minutes to read the FAQ.

Supplies

This Instructable contains information for getting started with HackerBox 0082. The full box contents are listed on the product page for HackerBox 0082 where the box is also available for purchase while supplies last. If you would like to automatically receive a HackerBox like this right in your mailbox each month, you can subscribe at HackerBoxes.com and join the party! Subscribers save at least $15 every month and get each new HackerBox shipped immediately off of the production line.

A soldering iron, solder, and basic assembly tools are generally needed to work on the monthly HackerBox. A computer for running software tools is also required. Have a look at the HackerBox Workshops for basic tools and a wide array of introductory activities and experiments.

The most import thing you will need is a sense of adventure, hacker spirit, patience, and curiosity. Building and experimenting with electronics, while very rewarding, can be tricky, challenging, and even frustrating at times. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from this hobby. Take each step slowly, mind the details, and don't be afraid to ask for help.

WEAR SAFETY GLASSES WHEN SOLDERING, WHEN TRIMMING WIRE LEADS, OR WHEN CUTTING, DRILLING, ETC.

Raspberry Pi Pico

Pico Pinout.png

The Raspberry Pi Pico is a tiny, fast, and versatile board built using RP2040, the flagship microcontroller chip designed by Raspberry Pi. The RP2040 features 133MHz dual-core ARM Cortex-M0+ processing, 264kB internal SRAM, support for up to 16MB of off-chip flash (2MB provided on the Pico), a DMA controller, 30 GPIO pins (4 of which can be used as analog inputs), and a wide range of flexible I/O options includes I2C, SPI, and exclusive Programmable I/O (PIO).

Raspberry Pi has provided a lot of great online documentation.

Before Soldering Anything

Do a quick test on the Pico module and validate at least one of the tool chains to compile and upload a simple program. In the next step, we will walk through doing this from the Arduino IDE, but multiple development options are available for the Raspberry Pi Pico:

Hello World

Plug the Pico into your computer. A new mass storage device (basically a flash drive) will appear. It will have the name RPI-RP2. If it does not appear, unplug the USB cable, hold down the BOOTSEL button and plug the USB cable back in before releasing the button. You can execute this BOOTSEL procedure anytime to force the Pico into a receptive state for (re)programming.

The RPI-RP2 mass storage can accept a UF2 file. Just copy/paste or drag the file onto the storage device. Once you drop it in, the Pico will automatically reset and run deposited program.

UF2 stands for USB Flashing Format. The associated bootloader allows embedded devices to be programmed using a simple USB mass storage class (removable drive) interface. The bootloader is also compatible with BOSSA (Basic Open Source SAM-BA Application), which is used by the Arduino IDE.

Raspberry Pi Pico Arduino Core

Arduino Blink.png

Install the Arduino IDE software and setup the Raspberry Pi Pico Arduino core as outlined here.

In the Arduino IDE, select: Tools > Board > Raspberry Pi RP2040 Boards > Raspberry Pi Pico

Open File > Examples > Basics > Blink

Execute the BOOTSEL procedure if necessary (unplug the USB cable, hold down the BOOTSEL button, and plug the USB cable back in before releasing the button)

Hit the arrow icon to compiler the sketch and upload it to the Pico.

The Pico's green LED should start blinking once the code is uploaded and starts running.

Solder Time

Now that we've tested the Pico and verified a first tool chain, it is safe to solder the headers to the Pico.

Use the single row header strips with the green insulators on them. There are 80 green header pins. The Pico requires 40 of them (two strips of 20). Retain the remaining green headers as some will be used while assembling the Pico VGA Lab Kit in a later step.

Pico VGA Lab Kit

VGA Kit.png

The Pico VGA Lab Kit is inspired by a reference design by Raspberry Pi. You can learn all about the design in Chapter 3 of their document Hardware Design with RP2040.

To make things easier to assemble from a kit, the Pico VGA Lab Kit leverages common modules and large (1206 size) passive components with enlarged soldered pads. The Pico VGA Kit also adds a serial USB module for additional connectivity options.

The schematic of your Pico VGA Lab PCB is provided in the attached PDF file.

As usual, we suggest mounting components and modules onto the Pico VGA Lab PCB in order from shortest/smallest elements first. For example, in the following order...

22 SMD-1206 Sized Resistors

  • THREE 8.06K "8061" (R6, R12, R18)
  • THREE 4.02K "4021" (R5, R11, R17)
  • THREE 2K "2001" (R4, R9, R15)
  • THREE 499R "4990" (R1, R7, R13)
  • SIX 1K "1001" (R2, R3, R8, R10, R14, R16)
  • TWO 47R "470" (R19, R20)
  • TWO 10K "1003" (R21, R22)

Resistors are not polarized, so each can be soldered in either orientation. However, be sure to put the correct value is populated into each location. Note the value markings in quotes above and match them to values on the PCB silkscreen.

SS34 SMD Diode (D1)

Diodes are polarized, meaning they must be correctly oriented. The PCB silkscreen for D1 shows a white box that is closed at the cathode terminal and open at the anode. The diode has a thick line adjacent to its cathode terminal. Match these up by putting the cathode marking (thick line on the diode) into the closed side of the white box.

CP2102 Serial USB Module

Use 6 pins of a single row header to mount the CP2102. For a tight looking finished result: Solder the header onto the module, slide the plastic insulator off of the header from the bottom of the module, and then solder the module flush onto the Pico VGA Lab PCB. If instead, you wish to leave the header's insulator in place, that is fine.

MicroSD Card Module

Use 9 pins of a single row header to mount the MicroSD Card Module to the Pico VGA Lab PCB. See the note above explaining how to get a flush, tight looking finished result.

Four Tactile Switch Pushbuttons

Insert each pushbutton in either direction. Solder the pins from the rear of the PCB.

Two 1x20 "Shorty" Female Headers

Solder the pins from the rear of the PCB.

PCM5102A Audio Module

Use 6 pins of a single row header to mount the Audio Module to the Pico VGA Lab PCB. If following the note above to get a flush, tight looking finished result, be sure to place an insulator (such as card stock or electrical tape) over the back of the module to protect the exposed contacts.

2x6 Jumper Block

Cut a 2x6 section from the 2x40 male header. Retain the remainder of the header for use in a future step. Insert the shorter side of the header pins into the PCB and solder from the other side. Retain the three yellow shorting jumpers for use with this 2x6 jumper block.

VGA Socket with PCB Mount

Insert the connector and solder the pins from the rear of the PCB.

USB Interfaces

USB Options.png

Pico USB Port

The Raspberry Pi Pico microcontroller has a built-in USB 1.1 controller with PHY. It can support both host and device operation, which means the Pico can act as a device (like a keyboard or mouse) or it can act as a host (something we can plug a mouse or keyboard into).

Pico USB Port in Host Mode

Generally, a USB device is powered by a USB host. For example, a mouse or keyboard is powered by the computer it is plugged into. When the Pico USB port is acting as a host, the Pico's USB port is expected to provide power. Thus, the USB port is no longer a useful place to power the Pico. Instead, power can be input to the External USB port and a yellow shorting jumper is placed on the two pins labeled "USB HOST" to connect the External USB port's +5V pin to the Pico module's VBUS pin. With the External USB port serving to input power to the board, the Pico USB port can act as a host (outputs power). Plugging a USB OTG adapter into the Pico USB will allow standard (USB Type-A) devices (like keyboards, mice, or game controllers) to be plugged into the Pico USB port.

External USB Module

The external serial USB module features the CP2102 chip (datasheet) from silicon labs. In addition to providing a means to input +5V when the Pico USB port is in host mode, the external USB module can also be used a second serial USB interface.

The TX and RX pins of the CP2102 can be connected to the GPIO20 and GPIO21 pins of the Pico by installing two yellow shorting jumpers on the appropriate pins of the jumper block (as illustrated above). NOTE: These two IOs are shared with the microSD card reader, so any cards in use should also be removed from the microSD slot.

Jumper Block and Power Pins

The 2x6 header block serves four (mostly) unrelated functions:

  1. Shorting USB HOST allows the External USB port to power the system when the Pico USB port is in host mode
  2. Shorting TX and RX to GPIO20 and GPIO21 selects the External USB serial interface
  3. Opening GPIO20 and GPIO21 selects the microSD card reader
  4. The GND, 5V, and 3V3 pins can be used for power

Since the three power signals are already connected in mirrored pairs, the yellow shorting jumpers can be stored on them when not in use. Obviously, be careful not to short different levels together.

Serial Interface Demo on Pico USB Port

The three yellow shorting jumpers can either be installed or left off. It does not matter.

  • This demonstration uses the USB cable plugged into "Pico USB" the entire time
  • Execute either BOOT procedure:
  • Unplug USB power and plug it back in while holding the BOOTSEL button, OR
  • Press and hold both BOOTSEL and RUN, release RUN, wait a couple seconds, release BOOTSEL
  • In the Arduino IDE, open the attached sketch: ButtonsPicoUSB.ino
  • Upload the sketch
  • The green LED on the Pico will flash 4 times
  • Open Tools > Serial Monitor and select 9600 baud
  • Press buttons A, B, or C and note the button status on the Serial Monitor
  • If there is no display, close the Serial Monitor, hit the RUN button, and reopen the Serial Monitor

Serial Interface Demo on External USB Port

Install the three yellow shorting jumpers on VBUS, IO20, and IO21 pairs.

  • Insert USB cable into "Pico USB"
  • Execute either BOOT procedure:
  • Unplug USB power and plug it back in while holding the BOOTSEL button
  • Press and hold both BOOTSEL and RUN, release RUN, wait a couple seconds, release BOOTSEL
  • In the Arduino IDE, open the attached sketch: ButtonsExtUSB.ino
  • Upload the sketch
  • The green LED on the Pico will flash 4 times
  • Unplug the USB cable
  • Plug the USB cable into "External USB"
  • Again, the green LED on the Pico will flash 4 times
  • Open Tools>Serial Monitor and select 9600 baud
  • Press buttons A, B, or C and note the button status on the Serial Monitor

Generating VGA Signals

VGA outout.png

The examples in Raspberry Pi's pico-playground repo are written for their reference hardware discussed above.

These include some fun VGA generation examples that run perfectly, right out of the box, on the Pico VGA Lab Kit.

To build the examples from Raspberry Pi, we need to set up their RP2040 C/C++ SDK toolchain. It can be a bit of a task to get that done, but luckily they have great documentation in the Getting Started with Raspberry Pi Pico guide. (See Chapter 1 for Linux or Chapter 9 for macOS or Windows.)

If you are in a rush and just want a quick test of your hardware build, someone was kind enough to post compiled UF2 files here so you can test the VGA demos by simply plugging in a VGA display, doing a BOOTSEL startup, and dropping one of the UF2 files (e.g. demo1.uf2) onto the RPI-RP2 mass storage device.

Pico Logic Analyzer Kit

Logic Analyzer.png

The Pico Logic Analyzer Kit features a PCB designed by El Dr. Gusman. All of the project details are available on the github repo. The pin mapping between the Pico and header is provided in the repo file Schematic1.jpg.

The Pico Logic Analyzer Kit is easily assembled from the PCB by simply soldering on two 1x20 "shorty" female headers (to form a "socket" for the Pico) and a 2x15 header. The 2x15 header can be cut from the remainder of the 2x40 header used to form the 2x6 bumper block for the VGA kit.

The mini-grabber test clips (with DuPont compatible connection pin) can be coupled to the 2x15 header using the female-to-female DuPont jumper wires. Together, these serve as test leads for use with the logic analyzer.

Additional Pi Pico Logic Analyzer Links:

  • El Dr. Gusman project details on Hackster.io
  • Pi Pico Logic Analyzer details on Hackaday
  • Sigrok-Pico - logic analyzer and oscilloscope
  • Scoppy: Oscilloscope and Logic Analyzer for Android Phones and Tablets


More Raspberry Pi Pico Projects

More Pico Projects.png

Many cool Pi Pico projects continue to emerge and evolve. We will post additional project links here that you can explore with your Raspberry Pi Pico, so keep an eye out. Also, feel free to email us anything you'd like to see added to the list!

BBC Model B Emulator

Pico Pong

Bit-Banged Ethernet

CircuitPython pico-ducky Bad USB / Rubber Ducky (Video)

M.CU.M.E (Multi CompUter Machine Emulator) ZX, Atari800, C64 (Video)

pico-dirtyJtag uses PIO to produce and capture JTAG signals

pico-xvc implements a Xilinx Virtual Cable (XVC) for programming FPGAs

Retrogaming

retro games.png

With an SNES-Style Game Controller, conveniently updated to plug into a USB port, you're primed for some retrogaming action!

LaunchBox can turn a Windows or Android box into retro gaming powerhouse. (video)

Mobile devices (e.g. smartphones or tablets) generally have Type-C or MicroUSB connectors. No worries... The dual OTG cable should allow a USB game controller to be used.

If you are not running Windows, or don't want to clutter your main drive, check out Batocera. Since Batocera boots and runs from a USB stick, it is totally "operating system agnostic". (video)


Carpe Technica

outro.png

We hope you are enjoying this month's HackerBox adventure into electronics, computer technology, and hacker culture. Reach out and share your success in the comments below or other social media. Also, remember that you can email support@hackerboxes.com anytime if you have a question or need some help.

What's Next? Join the party and live the HackLife. Get a cool box of hackable gear delivered right to your mailbox each month and enjoy a generous member discount. Surf over to HackerBoxes.com right now and sign up for your monthly subscription to HackerBox or the new HackBox Byte Size.