Welcome to nb2214-micropython’s documentation!

An image of the ALPACA board.

Welcome to the documentation for the NB2214 MicroPython port, the programming language used to program the ALPACA board. This port is based on MicroPython lightweight implementation of the Python everybody is familiar with designed for microcontrollers such as the one found on the ALPACA.

In the sections below, the features of the nb2214-micropython port are outlined, with links to their documentation.

Features

MicroPython

The MicroPython logo.

The ALPACA is controlled by the Raspberry Pi Pico. The nb2214-micropython port extends on the features of Micropython. Import features included in base Micropython are:

  • Control of digital output pins via machine.Pin.

  • Control of analog input pins via machine.ADC.

  • Delay and timing via the time module.

See also

Quick reference for the RP2.

Online documentation for MicroPython, the programming language of the ALPACA.

machine.Pin

Class for controlling the digital output pins of the ALPACA.

machine.ADC

Class for controlling the analog input pins of the ALPACA.

time

Module for timing and introducing delays.

Array Operations with numpy

Harness the capabilities of numerical computing with the inclusion of numpy in this MicroPython port. Perform array operations, mathematical computations, and data manipulations seamlessly as you are used to in regular Python.

This feature is made possible thanks to ulab, numpy-like module for MicroPython. ulab implements a small subset of the features of numpy (and scipy). Note that this means that not all numpy functions are available on the ALPACA.

See also

ulab reference

Online documentation for ulab, which provides numpy functionality for the ALPACA.

Note

In the ulab reference, the module is imported using:

>>> from ulab import numpy as np

On the ALPACA, this can be simplified to the usual:

>>> import numpy as np

Plotting with matplotlib.pyplot

An animated gif of live plotting on the ALPACA.

The MicroPython port includes a simplified interface for plotting using the matplotlib.pyplot module. You can create visualizations directly in Jupyter, making it easy to analyze data or monitor outputs.

See also

Module matplotlib.pyplot

Documentation for the matplotlib.pyplot module.

matplotlib.pyplot.plot()

Standard plotting.

matplotlib.pyplot.liveplot()

Live plotting.

Digital-to-analog converter

An image of the Digital-to-Analog Coverter (DAC) on the ALPACA.

The ALPACA has an MCP 4822 Digital-to-Analog Coverter (DAC). This allows for the creation of analog voltages between 0 and 4 volts (in contrast to the digital outputs of the ALPACA which can be set to either 0 or 5 volts). In order to instantiate and control the DAC hardware, a special module is implemented.

See also

Module dac

Documentation for the dac module.

The dac.DAC class

Main interface class for the DAC.

Function generator

In the Studio Classroom, there are function generators which allow for the creation of various waveforms as inputs circuits. A similar feature is available on the ALPACA, which makes use of the DAC to generate waveforms. This feature allows you to generate various types of signals, like sine, triangle, sawtooth, and square waves. The function generator can be run in the background, whilst other code (e.g. code for sampling) runs in the foreground. This allows for the simultaneous generation and measurement of a signal, for example to see how that signal is perturbed by a circuit.

See also

Module functiongenerator

Documentation for the functiongenerator module.

The functiongenerator.Sine class

Class for defining and creating sine waves.

The functiongenerator.Triangle class

Class for defining and creating triangle and sawtooth waves.

The functiongenerator.Square class

Class for defining and creating square waves.

functiongenerator.FuncGen context manager.

Context manager for the function generator functionality.

Housekeeping on the ALPACA

Sometimes, the ALPACA might need some extra care, like removing files or debugging, some useful tools for this end can be found in the alpaca module.

See also

alpaca.get_version()

Function to get the version of nb2214-micropython running on the ALPACA.

alpaca.clear_disk()

Remove all files on the disk of the ALPACA.

Installation

Consult the reader on Brightspace.

Indices and tables