This shows you the differences between two versions of the page.
eap:laboratoare:01 [2024/07/15 11:35] jan.vaduva |
eap:laboratoare:01 [2024/07/17 11:51] (current) jan.vaduva |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Intro to Raspberry Pico ===== | + | ===== Intro to RP2040 ===== |
- | === Microcontroller === | + | ==== Microcontroller ==== |
Microcontrollers are tiny integrated circuits (ICs) that you can program to perform various tasks. They have a processor, memory, and input/output pins (GPIO) to interact with the external world. From toys to cars, microcontrollers are everywhere in electronics. | Microcontrollers are tiny integrated circuits (ICs) that you can program to perform various tasks. They have a processor, memory, and input/output pins (GPIO) to interact with the external world. From toys to cars, microcontrollers are everywhere in electronics. | ||
Line 11: | Line 11: | ||
To unleash the potential of the RP2040, the Raspberry Pi Foundation created the **Pico-SDK**. This free and open-source software development kit (SDK) equips you with the tools and libraries needed to program the RP2040 in C and C++. | To unleash the potential of the RP2040, the Raspberry Pi Foundation created the **Pico-SDK**. This free and open-source software development kit (SDK) equips you with the tools and libraries needed to program the RP2040 in C and C++. | ||
- | === RP2040 === | + | ==== RP2040 ==== |
This chip name was provided by the Raspberry Pi foundation and is explained in the datasheet: | This chip name was provided by the Raspberry Pi foundation and is explained in the datasheet: | ||
* **RP**: Stands for "Raspberry Pi," similar to how other Raspberry Pi products use "Pi" in their names. | * **RP**: Stands for "Raspberry Pi," similar to how other Raspberry Pi products use "Pi" in their names. | ||
Line 43: | Line 43: | ||
In short, the RP2040 packs powerful processing, flexible memory options, diverse communication options, and built-in peripherals, making it suitable for various development projects. | In short, the RP2040 packs powerful processing, flexible memory options, diverse communication options, and built-in peripherals, making it suitable for various development projects. | ||
- | === Environment interaction === | + | ==== Environment interaction ==== |
General-purpose input/output pins let you connect external components like LEDs, sensors, or buttons to your RP2040. You can configure them to be inputs (reading data) or outputs (sending data). The RP2040 provides 30 multi-function GPIOs controllable via software (C/C++ or MicroPython) for diverse functionalities beyond basic input/output. | General-purpose input/output pins let you connect external components like LEDs, sensors, or buttons to your RP2040. You can configure them to be inputs (reading data) or outputs (sending data). The RP2040 provides 30 multi-function GPIOs controllable via software (C/C++ or MicroPython) for diverse functionalities beyond basic input/output. | ||
Line 62: | Line 62: | ||
- | == LED-s == | + | === LED-s === |
LEDs - Light Emitting Diode - also called electroluminescent diodes - emit light when they are directly polarized. Not to be confused with light bulbs as they have radically different methods of operation. | LEDs - Light Emitting Diode - also called electroluminescent diodes - emit light when they are directly polarized. Not to be confused with light bulbs as they have radically different methods of operation. | ||
Line 81: | Line 81: | ||
<note warning>If there is no resistor in the circuit, the resistance will be almost 0 Ω, the current will tend to ∞, meaning a short circuit. This will absolutely burn the LED and make it unusable, but it can also burn the MCU. Most MCUs have short circuit protection, but is safer to not rely on that.</note> | <note warning>If there is no resistor in the circuit, the resistance will be almost 0 Ω, the current will tend to ∞, meaning a short circuit. This will absolutely burn the LED and make it unusable, but it can also burn the MCU. Most MCUs have short circuit protection, but is safer to not rely on that.</note> | ||
- | == Buttons == | + | === Buttons === |
The simplest way for the user to interact with a MCU is through the use of buttons. | The simplest way for the user to interact with a MCU is through the use of buttons. | ||
Line 91: | Line 91: | ||
<note tip>To save external space, in most MCUs these resistors have been included inside the integrated circuit. Initially they are disabled and their activation can be done through software.</note> | <note tip>To save external space, in most MCUs these resistors have been included inside the integrated circuit. Initially they are disabled and their activation can be done through software.</note> | ||
- | == Breadboard and jumper wires == | + | === Breadboard and jumper wires === |
A **breadboard** is a rectangular board with a grid of holes that allows you to create temporary electronic circuits without soldering. The board typically has metal strips underneath the surface, connecting the holes in certain patterns. These patterns follow a standard layout, facilitating circuit building. Breadboards are reusable and provide a convenient way to prototype circuits quickly and make changes easily by rearranging components. | A **breadboard** is a rectangular board with a grid of holes that allows you to create temporary electronic circuits without soldering. The board typically has metal strips underneath the surface, connecting the holes in certain patterns. These patterns follow a standard layout, facilitating circuit building. Breadboards are reusable and provide a convenient way to prototype circuits quickly and make changes easily by rearranging components. | ||
+ | |||
+ | |{{ :eap:laboratoare:breadboard-b88a275da351ebc6f0db4afc80c44b5e.png?nolink&350 | breadboard}} | {{ :eap:laboratoare:breadboard_connections-05382eb0cf1abde26b957a2719218a65.png?nolink&300 | breadboard connections}} | | ||
+ | <html><center>a) Breadboard for Electronics Prototyping, b) Internal Wiring of a Breadboard</center></html> | ||
+ | |||
**Jumper wires** are flexible wires with connectors at each end, typically male connectors (pins) or female connectors (sockets). They are used to create electrical connections on a breadboard by plugging one end into a hole on the breadboard and the other end into another hole, forming a connection between the two points. | **Jumper wires** are flexible wires with connectors at each end, typically male connectors (pins) or female connectors (sockets). They are used to create electrical connections on a breadboard by plugging one end into a hole on the breadboard and the other end into another hole, forming a connection between the two points. | ||
- | === Datasheets === | + | {{ :eap:laboratoare:jumper_wires-4b72cd30e43584bece8b01fd6644604e.png?nolink&200 | jumper wires}} |
+ | |||
+ | ==== Datasheets ==== | ||
The RP2040, like most electronic components, has a datasheet (sometimes called a data sheet or spec sheet). This document is like an instruction manual for the chip, explaining its features and how to use it in your projects. | The RP2040, like most electronic components, has a datasheet (sometimes called a data sheet or spec sheet). This document is like an instruction manual for the chip, explaining its features and how to use it in your projects. | ||
Line 109: | Line 115: | ||
* Complementary Resources: If the datasheet is overwhelming, online resources like tutorials and forums can help explain concepts in a more user-friendly way. | * Complementary Resources: If the datasheet is overwhelming, online resources like tutorials and forums can help explain concepts in a more user-friendly way. | ||
- | === References === | + | ==== GPIO configuration ==== |
+ | GPIO pins can be used as outputs (LEDs, motors, buzzers) or as inputs (buttons, sensors). | ||
+ | |||
+ | The R02040 has three peripherals that control the GPIO pins: | ||
+ | |||
+ | - **Pads** - control the actual physical pin or pad that the processor has outside. This control the electrical parameters, like maximum current or pull up and pull down resistors | ||
+ | - **IO Bank0** - connects and multiplexes the peripheral's pins to the output pads. Several peripherals use the same output pad to communicate with the exterior. For example, in the image below, **GPIO0** can be used either for: | ||
+ | * **SIO** - the **GPIO** function | ||
+ | * **SPI_RX** - the receive pin for the **SPI** peripheral | ||
+ | * **I2C0_SDA** - the data pin for the **I2C0** peripheral | ||
+ | * **UART0_TX** - the transmit pin for the **UART0** (serial port 0) peripheral | ||
+ | - **SIO** - that controls the interior MCU's pins. This is the peripheral that developers use to read and write the value of the pins. | ||
+ | |||
+ | {{ :eap:laboratoare:marble-pico-pinout.png?nolink&600 |Marble Pico board}} | ||
+ | [[https://github.com/GroundStudio/GroundStudio_Marble_Pico/blob/main/Documentation/REV0.0.3/RLJDMV_GS%20REV0.0.3%20GroundStudio%20Marble%20Pico%20Pinout%20REV%201.1.pdf | Marble Pico pinout]] | ||
+ | ==== Wowki simulator ==== | ||
+ | Wokwi is a web-based platform that allows you to simulate and prototype electronic circuits with microcontrollers. It provides a visual interface where you can drag and drop components, connect them with virtual wires, and write code to control their behavior. Wokwi currently supports popular microcontroller boards like: | ||
+ | * Arduino Uno, Mega, Nano, etc. | ||
+ | * Raspberry Pi Pico | ||
+ | * ESP32 boards (generic) | ||
+ | * STM32 multiple boards | ||
+ | |||
+ | ==== Exercises ==== | ||
+ | - Create a program in Wowki to blink an LED connected to a Raspberry Pi Pico (RP2040) microcontroller. | ||
+ | * [[https://wokwi.com/projects/403560205017402369|You can start from this template project]] | ||
+ | - Design and implement a program for a Raspberry Pi Pico (RP2040) microcontroller that increments a counter from 0 to 9 and displays the current count on an 7-segment display. The program should also include a reset button that, when pressed, resets the counter back to 0. | ||
+ | * [[https://wokwi.com/projects/403561096139405313|Use this as starting project]] | ||
+ | |||
+ | ==== References ==== | ||
- [[https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf|RP2040 microcontroller datasheet]] | - [[https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf|RP2040 microcontroller datasheet]] | ||
- [[https://datasheets.raspberrypi.com/pico/pico-datasheet.pdf|Raspberry Pi Pico datasheet]] | - [[https://datasheets.raspberrypi.com/pico/pico-datasheet.pdf|Raspberry Pi Pico datasheet]] | ||
- [[https://www.raspberrypi.com/documentation/microcontrollers/c_sdk.html|Pico-SDK]] | - [[https://www.raspberrypi.com/documentation/microcontrollers/c_sdk.html|Pico-SDK]] | ||
+ | - [[https://www.raspberrypi.com/documentation/pico-sdk/hardware.html#ga71d35b29e897b9bb4fc881b587b08cab|Pico-SDK Documentation]] |