9. Output Devices¶
This weeks task was to connect and test an output device to my the microcontroller board that I designed and built in previous assignments.
Group work¶
- This weeks group assignment was to measure the power consumption of an output device. Our groups work was documented here: Output devices- Group assignment
Individual assignment¶
- This week individual assignemt is to connect, test and program an output device with the board I designed in Electronics design week and made in Electronics production week.
HOWEVER:
Problematic old board¶
I ended up having allot of problem getting my SEEED rp2040 based board to work consistently. I modified a test program in Arduino IDE and uploaded and it worked perfectly as seen here:
But after making a few changes to my code and uploading it, it stopped displaying anything. I tried allot of troubleshooting solutions:
- I re-uploaded the original test code that was initially working, but now it wasn’t displaying anything.
- I retested every port, trace and solder with a multimeter to see if I had accidentally broken a connector or created a short, but everything checked out correctly.
- I replaced the OLED screen with a brand new one.
- I flashed the firmware on the board to factory original in case I somehow dammaged a firmware settings. It didn’t help.
- I did weeks of research trying to figure out where I went wrong, but I couldn’t come up with a solution.
- Eventually I unsoldered my SEEED rp2040 from my board and replaced it with a SEEED ESP32C3 instead. Both these microcontroller boards have the exact same pin layout, so I wouldn’t have to redesign my board. And this worked fine for a while with my initial test codes and OLED output. But after a while the same problem reoccurred.
Eventually I realised that I might not be able to figure out what went wrong or finding a solution would take up too much time. If I swapped the microcontroller for a new one again, I couldn’t trust that the same thing wouldn’t happen a 3rd time. So I decided instead to create a new board based on a different microcontroller
My New Board¶
I decided to build my new board around the ATTINY1614 because:
- It was a more thoroughly tested and reliable microcontroller than the SEEED boards.
- We had a lot of them on hand in our lab.
- It had enough ports for my intended final projects design.
- Others in my lab had success using them previously (although most used the ATTINY412).
The attiny1614 layout:
The used KiCAD and the same methodology I used in my electronics design assignment to design the new board. I used the same methodology and settings I used in my electronics production assignment to create my new board.
Here’s the new board:
milling new board:
Output Device¶
-
My final projects design will be using an output screen primarily to display a timer. It would potentially be used for other things, like displaying instructions, but the main use is for displaying a recorded time. So I chose to use a display screen as my output for this assignment.
-
I had a couple different options to chose from for my screen, but I decided on using the 0.96 inch OLED IIC Display Module 128x64. I chose this one because I preffered this aspect ratio to the others we had on hand.
-
These screens come bare as seen here, without any pins attached. However they also come with 4 male pins that you can solder on if you would rather use pins (instead of soldering directly to the board).
-
I preffered to use the male pins in my setup, so the first thing to do was to solder them to the display board.
Connecting Hardware¶
- These display boards only need 2 data wires, plus a Power (Vcc) and Ground (GND). This display uses IIC (also called I2C) ports for communication. So these are the only ports it can use from the microprocessor. I designed my board with these 4 connectors together and in the proper order as the pins on the OLED screen.
-
I can use M/F jumper wires to connect the screen so it is more flexable and moveable later on, but for now it’s really convenient to just plug the OLED screen directly into the ports.
-
I then connected the UPDI/FTDI converter to the boards UPDI port, and the FTDI cable into the converter’s other end. Then the FTDI cable into the computer’s USB port.
Programming¶
Setting up the programming environment:
-
First I had to install the Arduino IDE software.
-
I followed the same procedure as in Quentores Xiao RP2040 project page, but with the following changes:
-
I had to add the “additional board manager URL” to find the necessary libraries. The one for the Attiny was “http://drazzy.com/package_drazzy.com_index.json”.
-
In the “board manager” I had to install the “MegaTinyCore by Spence Konde”.
-
I connected my FTDI cable to my USB port and my UPDI connector. And My UPDI cable to the UPDI port on my board to get a connection.
-
I selected the attiny1614 from the tools menu
-
I selected the programmer as “SerialUPDI SLOW”
Working Program¶
I used the test code for the OLED screen that I used in the Wowki simulator OLED example in my embedded programming assignment as a starting base and made a small modification to the text being displayed.
my code:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
/*
* James Khan Fab Academy output week assignment
* Connections
* SSD1306 OLED | Arduino Uno
* ---------------------------
* VCC | +5V (Vcc/power/+ve)
* GND | GND (Ground/-ve/0v)
* SCL | A5 (Serial Clock Line)
* SDA | A4 (Serial Data Line)
*/
const int SCREEN_WIDTH = 128; // OLED display width, in pixels
const int SCREEN_HEIGHT = 64; // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
Serial.begin(9600);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
while(true);
}
}
void loop() {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 10);
// Display static text
display.println("Hello, World!");
display.println("James Khan");
display.println("OUTPUT week");
display.display();
}
I then clicked the “upload” button in the Arduino IDE software.
After a long list of updates I in the output window, I received the message that the upload was completed successfully.
and it worked correctly