Hello there! Welcome to UR@B electrical team! UR@B Electrical training will introduce you to basic circuit concepts, and firmware. Additionally, the HOPE Decal content created by IEEE @ Berkeley will introduce you to printed circuit board CAD tools.
"Note: Feel free too ask/wait for a electrical team member to help you when working on this training to prevent frustration."
"Note: If you already feel comfortable with all the concepts below, feel free to skip this whole training all together and work on the project"
- None
At the end of the training, you will know:
- Basic Circuit (Electronic) Concepts
- Basic Firmware
- Basic Printed Circuit Board Design (PCB) CAD Tools
Technologies Used: C, RP2040, Raspberry Pi Pico, pico-sdk, VMWare Workstation Pro, Linux (Ubuntu), etc...
"Note: For each part, click on the dropdown to show the content."
You will learn about the concept of ground, voltage, current and various machine tools used in electrical engineering.
Electronics Dropdown
Current is the rate at which electrons (particles) flow. Remember that particles are physical in nature.
Particles will stay still unless there is enough pressure to get them moving. Voltage is the difference in electric potential energy between two points. It is the "Push" that gives pressure to push electrons (particles) through a circuit.
Reference voltage commonly referred to as **ground** is a value that can be used with respect to everything else. One example is that "Earth ground" can be used as the reference voltage but most times the reference voltage is relative to the application."Common" ground is the reference voltage that is shared across the whole application.
V_GND = 0 V
Most times, zero volts are used as the reference voltage to make calculations easier.
Note that the reference voltage may not necessarily be 0 volts, It can be any value as long as the circuit designer is consistent.
Resistance is the opposition to the flow of current. Everything has resistance including wires itself.
Image Credits: Build-electronics-circuit / Oyvind Nydal DahlBringing it all together with Ohm's Law.
Voltage = Current * Resistance
Current = Voltage / Resistance
Resistance = Voltage / Current
Note: Please ask if you are interested in getting hands on experience with these machines.
Power supply unit provide a voltage source.
Measures Voltage, Current, and Resistance.
Mainly used for tracking "signals". Signals are just voltage values. Oscilloscope is a multimeter but is able to provide a graph of the signal over time.
Checkpoint: No Checkpoint for Part 1
When you are making anything, you are often not creating everything from scratch. You will need to use technical manuals, reference sheets, datasheets to know various features of "devices" that you plan on using in a design.
For example, consider a LED.
There is a voltage value that the LED must be used to get the LED to turn on. This voltage value is called the "forward voltage". Consider: https://learn.adafruit.com/all-about-leds/the-led-datasheet If you look at the datasheet, you will find that the "forward voltage" is 1.85V. That means the voltage difference across the LED should be that voltage value.
Note: Classes, Search engines, and books are your best friend in figuring out what various attributes you need to know when designing.
Naturally, you are effectively required to search for information on your own because no one knows the exact information that is required.
Additionally, to make the LED work, you need to add a resistor. The point of the resistor is to limit the current. R = 150Ohm - 300 Ohm
will work. The resistance depends on how intense the LED you want and minimum LED values.
Note: Please ask if you are interested in doing the LED application. It is a simple lab that walks you through how to get a LED to work.
Checkpoint: No Checkpoint for Part 2
"Note: Feel free too ask/wait for a electrical team member to help you when working on this to prevent frustration."
Note: You will need access to a RP2040 microcontroller with a LED.
With the RP2040 microcontroller which is part of the Raspberry Pi brand.
Firmware (Software) Dropdown
Prerequisites: These topics can be learned on the "job".
If you need help setting up Git/Github, use a search engine and search for "CS 61B Lab01: Setup" Lab.
If you need help with command related issues, please search for answers online.
If you need help with C language, please refer to https://inst.eecs.berkeley.edu/~cs61c/sp21/resources-pdfs/garcia_c_reference_slides.pdf
If you need help with understanding CMake/Make then please search for the answers online. CMake/Make are just build tools. Instead of manually typing alot of commands, Make is able to "build" the code to a binary (.elf) file for you to use. CMake creates the "Make" file.
Setting up Ubuntu with VMWare Workstation Virtual Desktop
- Download VMWare Workstation Pro or VMWare Fusion Pro for MAC from broadcom.com, you can also use other virtualization software like VirtualBox
- Download Ubuntu24.04 LTS ISO
- Add the Ubuntu to VMWare
- Command Line:
In the Ubuntu Create 2 folders somewhere:
- “development”, “program_files”
- Do this by opening command line and going to the root directory. ~/
- run
“mkdir development”
- It will be used to do any development
- run
“mkdir program_files”
- Stores program files that you will see below such as picotool and pico-sdk
- “development”, “program_files”
- There are two ways to install programs. Using a package manager or downloading the program directly and then installing.
- Note: Normally in other OS, you can double click files and a installer pops up, but in linux, you need to use
"sudo apt install ./<filename>.deb
- Recommendation: Use one Package Manager. Ubuntu has “Snap” and “APT” . I recommend using “APT” and staying consistent.
- Some Notes: Adding Environment Variables
- Used when Building and compiling projects so programs know where files are
- vim ~/.basrhc
- Add by using EXPORT VAR_NAME=”/path”
- Used when Building and compiling projects so programs know where files are
- Download VSCode by Googling “VScode Ubuntu” and downloading the .deb file
- Open a terminal and goto the “Downloads folder” then run
“sudo apt install ./<filename>.deb”
- You can now run
“code .”
in directories in the terminal to open VSCode for a directory. - Other method of installing:
sudo snap install code --classic
- In terminal, run:
code --install-extension ms-vscode.cmake-tools
- In terminal, run:
code --install-extension ms-vscode.cpptools
- Open a terminal and goto the “Downloads folder” then run
- Download “Github CLI”. “gh” in the APT package manager
- run
“gh auth login”
and login to github.
- run
- Packages Needed: sudo apt install gh git curl screen
Some Command Line Commands: https://www.git-tower.com/blog/command-line-cheat-sheet/
Source/Reference: Many of the instructions and command was adapted from lf-lang.org
- Packages Needed:
sudo apt install gh git curl screen
- In the program_files directory, clone https://github.com/raspberrypi/pico-sdk.
gh repo clone raspberrypi/pico-sdk
command. - Packages Needed:
sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
cd
to the program_files/pico-sdk and rungit submodule update --init
- Set the PICO_SDK_PATH
1.
- run
export PICO_SDK_PATH=
pwd` - run
echo "export PICO_SDK_PATH=$PICO_SDK_PATH" >> ~/.profile
- Alternative Method:
- In terminal:
vim ~/.bashrc
- Use
pwd
to figure out what the absolute path to the pico-sdk - Add
EXPORT PICO_SDK_PATH=”/home/<ubuntuname>/program_files/pico-sdk"
to the end of the file.
- In terminal:
- run
- Follow: Reference
- In the program_files directory, clone https://github.com/raspberrypi/picotool.
gh repo clone raspberrypi/picotool
command. - Packages Needed:
sudo apt install build-essential pkg-config libusb-1.0-0-dev cmake
- Make sure you have run
"git submodule update --init"
in the PICO-SDK. - Go through the process of running the commands in program_files
- To allow RP2040 via USB without superuser priviledges
curl -s https://raw.githubusercontent.com/raspberrypi/picotool/master/udev/99-picotool.rules | sudo tee -a /etc/udev/rules.d/99-picotool.rules >/dev/null
. See: more info.
-
Goto the
development
directory. If you are in/program_files
, then runcd ../development
-
Clone the training repo that belongs to you.
- Goto
https://github.com/berkeleyauv/electrical_training
and find the "fork" button which is close to thegreen <> Code
button. - Clone the training repo.
- Goto
-
Login and authenticate yourself by doing
gh auth login
-
Create your own branch
first/lastname
and rungit checkout first/lastname
- Disclaimer: Permissions issues may be created due too
berkeleyauv/electrical-training
being protected so you may not be able to 'push'. Please let us now if this happens.
- Disclaimer: Permissions issues may be created due too
-
Note: When you want to
"save"
, rungit add .
thengit commit -m "whatever message you want"
and rungit push origin <your own branch or just main>
- If you have forked, then push to "main"
- If you have created a branch, then push to the "branch"
- Check what remote options you have by running
git remote -v
. It may not be "origin"- If you don't have origin, run
git remote add origin https://github.com/linktorepo
- If you don't have origin, run
-
All the setup has been done. Now, create a new folder and label it
rp2040_blink
.cd
to the electrical-training repo and runmkdir rp2040_blink
-
If you haven't already. open vscode to the directory by running
code .
-
cd
intorp2040_blink
in terminal. -
create a
pico_sdk_import.cmake
file- Goto
<PICO_SDK_PATH>/external/pico_sdk_import.cmake
file using another terminal or vscode. - Copy and paste the file contents to
pico_sdk_import.cmake
that you have just created
This is a copy of <PICO_SDK_PATH>/external/pico_sdk_import.cmake ...Get a copy from the file above.
- Goto
-
Create
blink.c
file.#include "pico/stdlib.h" #define GPIO_ON 1 #define GPIO_OFF 0 #define LED_PIN 25 int main() { //Intiailize stdio stdio_init_all(); gpio_init(LED_PIN); gpio_set_dir(LED_PIN, GPIO_OUT); while(true) { printf("Blinking On!\n"); gpio_put(LED_PIN, GPIO_ON); sleep_ms(2000); printf("Blinking Off!\n"); gpio_put(LED_PIN, GPIO_OFF); sleep_ms(2000); } } ```
-
Create
CMakeLists.txt
#Source: https://www.youtube.com/watch?v=JhajoAyP8e4 cmake_minimum_required(VERSION 3.12) # PULL in PICO SDK include(pico_sdk_import.cmake) project(blink C CXX ASM) set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 17) set(PICO_EXAMPLES_PATH ${PROJECT_SOURCE_DIR}) #Using picotool set(picotool_DIR $MY_INSTALL_DIR/picotool) #Initializing the SDK pico_sdk_init() add_executable(blink blink.c) # Pull in our pico_stdlib which pulls in common libraries target_link_libraries(blink pico_stdlib) # Create map/bin/hex file etc. pico_enable_stdio_usb(blink 1) pico_enable_stdio_uart(blink 0) pico_add_extra_outputs(blink)
-
Create a
build
directory in the blink RP2040 Project directory. runmkdir build
-
cd into
build
-
run
cmake ..
-
run
make
-
You will now see "blink.elf" in the folder.
-
Connecting USB to the RP2040 MCU
- Put the Raspberry Pi PICO into BootMode
- Disconnect the USB
- Hold the Button and put the USB back in while simultaneously holding the button.
- If you are using VMWare Workstation, make sure that the RP2040 is connected to the virtual machine instead of your host computer.
- If it isn’t, right click the virtual machine at the side panel and goto “Removeable” Devices. then select RP2 Boot and Connect
- Put the Raspberry Pi PICO into BootMode
-
Run
picotool load -x blink.elf
-
Congratulations! The LED should be blinking.
For more examples, see: https://github.com/raspberrypi/pico-examples.git
- At this point, you have the necessary toolchain to make any rp2040 project work.
- To debug, often times you want to see print statements to know what your project is doing.
- Follow: https://www.lf-lang.org/embedded-lab/Tools.html#finding-the-device-on-linux
- Install "Screen"
- Use
ls /dev/ttyACM*
to find thePORT
that has the serial monitor. - Ensure these attributes exist in the corresponding files
blink.c:main(..) //Add to the start of the main stdio_init_all(); CMAKELists.c: pico_enable_stdio_usb(blink 1) pico_enable_stdio_uart(blink 0)
- Run
sudo screen <device> 115200
N/A
N/A
Checkpoint: Blinking LED and showing the Serial Monitor
Instead of using prototyping boards like stripboards and breadboards, you will now create a "PCB" which makes your electronics much more versatile. Instead of wires failing off, the wires can't fall off printed circuit boards. Like how 3D Printing design uses CAD tools like Solidworks, electrical engineers use electronic computer aided design (ECAD) like KiCad.
PCB ECAD Tools Dropdown
To get used to the KiCad ECAD software, please follow the HOPE course.
IEEE @ Berkeley has created a awesome decal (course) on printed circuit board design. All content and credits goes to staff at the Hope Decal
See HOPE Decal- https://ieee.berkeley.edu/hope/
If the link does not work, please search for: IEEE Berkeley HOPE Decal
For underwater robotics, Please do the following content and associated labs:
- Install Kicad
- Light Sensor Schematic
- Light Sensor Components
- Light Sensor Layout
- USB Charger Components (Optional)
- USB Charger Schematic (Optional)
- USB Charger Layout (Optional)
Checkpoint: The DRC for both schematic/layout should show no errors. DRC - Design Rule Checker.
We did not at all cover the "Design" aspect of electrical engineering, searching for answers through your coursework, using search engines, and asking questions are the best way to learn "Design".
Here are some keywords that outlines the steps to make a design work:
- Planning
- Tapeout
- Bringup
- Implementation
To see an example, see: Example
The training and project is not meant to be comprehensive. Hopefully the training and project is good enough as a launchpad for you to further investigate engineering.