⚡Week 8: Electronics Design
Project Heros
Final milled Pico break out board:
Group Assignment
Our group assigment this week was to use test equipment to observe the operation of a microcontroller circuit board. There were a couple of insightful things I learn't this week, mainly in the accuracy of values. I always knew that the voltage regulators that were onboard were not 100% accurate, but they were a lot closer than I thought they would be. The 3.3 regulator was provoding 3.301 volts which was far closer as I thought it would be around 3.31 or 3.29. It was also insightful as I think its the first time I've seen a PWM signal in realtime on a scope. I am so used to the adc reading of it that seeing the duty cycle function changing was really cool. It was also interesting to see the disconnect between the code side of setting a 50% cycle and measuring that it was a few 0.1% off.
Making the PCB in KiCad
My final project has 4x motors/encoders/motordriver combos which need 5 unique GPIO pins and have need another 4 pins each for power. Because of these reasons, the motors are getting their own dedicated Pico and a breakout board will save a great deal of hassle.
I started by planning out the board, it is simple in that it is only a series of 4-pin headers, but difficult in that we have 32 connections to route from a single component. This is a sketch I made of the headers and what pins they will connect to.
Knowing what pins need to go where, I booted up KiCAD 8 and imported the Core Electronics KiCad Libraries which contained schematics and footprints for the Pico (and doesn't come pre-installed with KiCAD). The only other component I would be using is a 4-pin header which is under the name "Conn_01x04_Pin".
With all the required schematic symbols, I layed out the board roughly and labelled my 4-pin headers.
Usually it is good practice to lay out the schematic with inputs on the left and outputs on the right, but I layed it out in the rough shape of the board to get an idea of how everything is going to route. I was very adamant on having this all route without the use of 1 ohm resistors to jump over a trace.
With the schematic layed out and the footprints coming assigned with the library, I moved from the schematic editor to the PCB editor and imported the footprints and connections. This meant that all we have to do is lay everything out neatly.
After laying out the Pico and connectors I saw that a few headers could be flipped to make the routing easy.
I found that the auto-routing function didn't really help, so I spent a fair chunk of time routing all the connections. This would of been rendered a lot easier if I made a jump or 2 across the board with a 0 ohm resistor, but I was stubborn and didn't want the hassle. The 3.3 Volt rail had to be routed to nearly every header, and taking in the design constraints of the minimum thickness between traces gave me quite a lot of hassle. But now it was routed!
Now all that was left was to add the outside of the board and mounting holes. The board could of been more compact, but I opted for some extra room on the outside incase I want to write some labels or notes.
And as always, I ran the Design Rule Checker to just double check if we had any dodgey routes or miss-wired pins. There were a few warnings about my sloppy implementation of the edges and mounting holes, but this and a thoughrough visual inspection gave no issues.
Before exporting I flipped the board (ctrl + a to select all, f to flip) as this would allow me to solder the pins of my header to the nice copper side. I then exported it as an SVG, B.Cu is the through holes, Edge.Cuts are the edge and holes of the board and F.Cu is the copper traces. I exported them with these settings:
Producing the Board
To mill the board I used the Lab's SRM-20 and Mods. Right click > programs > open program > Roland > SRM-20 mill > mill 2D PCB. Then here we can select our SVGs. And we will also use the settings in the following image. For the traces I used a 1/64 bit and for the edges and holes a 1.32 bit - these settings should be updated in mods accordingly when each is exported.
Resulting tool paths:
From here we opened up the SRM's CAM software VPanel, stuck the copper plate down, zero'd in the bit and let it mill away. After 30 minutes of milling I came back to check on its progress and realised I hadn't given my board enough room. That edge trace only just made it on the sheet and I continued as the board would be functional.
After running the holes and edges, the board was finished. I forgot to get a picture of the board at this point though as I started soldering it immidiately. This is one of my first times using lead-free solder and It was not very fun.
I could complain about it all day but we got there in the end and my board was fully soldered up with headers to plug in the Pico and motor controllers.
Testing the Board
It was a good time to test my board to help isolate any issues that might be present with it before it gets integrated into the robot. To do so I took off one of my robot's wheel assemblies and hooked it up with a motor controller. Using the follow code:
from machine import Pin, PWM, Timer
import time
# Motor control pins
ENB = Pin(21, Pin.OUT)
pwm = PWM(ENB)
IN3 = Pin(20, Pin.OUT)
IN4 = Pin(19, Pin.OUT)
# Encoder pins
encoderPinA = Pin(2, Pin.IN, Pin.PULL_UP)
encoderPinB = Pin(3, Pin.IN, Pin.PULL_UP)
# Encoder variables
encoder_position = 0
rpm_calculation_period = 0.1
counts_per_revolution = 1920.0
def set_motor_speed(speed):
if speed > 0:
IN3.value(1)
IN4.value(0)
elif speed < 0:
IN3.value(0)
IN4.value(1)
speed = -speed
else:
IN3.value(0)
IN4.value(0)
# Convert speed percentage to duty cycle (0-65535)
duty_cycle = int((speed / 100) * 65535)
pwm.duty_u16(duty_cycle)
while True:
inputRPM = -(166.666 * encoder_position / counts_per_revolution) / rpm_calculation_period
print(inputRPM)
set_motor_speed(65534 * 0.4)
And I went through and tested every set of pins coming from the Pico and it all worked!
This was my first time milling a board (and actually using it in a project) and I was pleasantly suprised with the process. I extensively use protoboard for my projects, but now that I've gone through this process I would be quite inclined to use it if I were to make another board as complicated as this one as it would save a great deal of time. My local fablab is still about an hour drive away, but later in the year they are moving closer so I may opt to visit for some PCB production.
And overall Im very happy with this board and the neat little pinout it has. I am very terrible at mixing up wires and now that everything is a labelled header, I think this will save some headache and hassle in my final project.