Skip to content

A6 - Microcontrollers

Brief


  • Write a program for a microcontroller development board that you made, to interact (with local input &/or output devices) and communicate (with remote wired or wireless devices)

Project Enclosure

Group Assignment - Investigating a microcontroller datasheet

Checking the board


When milling the PCB we tested that the continuity seemed OK, but how do we know it will work with the microcontroller?

Lets implment the proposed tests from Assignment 4, PCB Milling: 1. Does the onboard LED work? Set the pin high and low, observe it turning on and off 2. Does the onboard button work? Read the pin, observe the serial output outputting the state 3. Do the GPIO outputs work? Wire one to another, set one high and read the other

Our development board includes a Xiao RP2040, and I'm familiar with Micropython - a pythonic language, meaning its super fast to develop with.

1. Testing the LED

The LED can be considered a digital output. It responds to an on or off (high or low, 3.3V or 0V).

Our LED is connected to pin 8 via a 10k resistor from GND...

Which is how I would have programmed it if the LED was around the right way the first time. I will fix the LED orientation in the future but for now we can spin the microcontroller, the opposite side doesnt have any power pins so we can program the voltages.

Now one side of the LED is D1(p26) and the other side is D5(P7). If we set the levels to be opposite we can turn the led on and off.

Project Enclosure

2. Testing the button

The button is a digital input, receiving an on or off value.

Our Button is connected to D9(P4) from GND.

Since the LED is reversed and we want the functionality we need to select a pin we can use as GND, or 3.3V.

The 2 pins connected now are D2 (P28) and D4(P6)

Which is how I would have programmed it if the LED was around the right way the first time. I will fix the LED orientation in the future but for now we can spin the microcontroller, the opposite side doesnt have any power pins so we can program the voltages.

Now one side of the LED is D1(p26) and the other side is D5(P7). If we set the levels to be opposite we can turn the led on and off.

Project Enclosure

3. Loop-back IO Testing

I already kind of did this in the above 2 examples! If we want to connect an external input or output we could solder headers facing down for jumper wires.

Since the microcontroller had to be soldered underneath there wasnt a good location to solder headers, I've opted to skip this step.

Extra. Communicating with an external device

In the button example we used a print statement, this allows for feedback to be sent to our computer. Say a robot is running, there are inputs (sensors). We can send these to a MatLab script to simulate the robot. Processor in the loop (PIL). Note that we also have to send information back, many processors allow UART to be DMA'd into buffers without setup.

Resources

Files