So, in the last batch of Electrocards I assembled, one of the displays had a very poor brightness. A fun project to see if I would be able to debug this issues.
The benefit of having multiple copies of your board (including correctly functioning boards) is that you can simply compare your measurements. So with the help of my $15 SMD multimeter I started poking around on the board. Of course, some items give strange values since they are connected to the board, but it's a good first step.
C1, C2 and C3 should give a value somewhere near 1uF. And on the functioning board, this was indeed the case.
However, On the faulty board C2 resulted in an overload message on my multimeter. Did I really find the issue with my second measurement?
C1 and C2 are used by the OLED's internal voltage pump. This voltage pump creates the high voltage nessecery to light op the OLED pixels. Without a correctly funtioning voltage pump the pixels won't light up bright enough (or not at all ...). So an issue with C2 could indeed cause the problem.
With a few karate kicks, some screaming and crying I managed to remove the faulty capacitor.
Replacing the capacitor was just as easy, so less than a minute later I was able to do another measurement. Unfortunately the problem still persisted.
This lead me to an other possible cause: a shortage in the display's board connector. And with the help of an macro lens on my iPhone, I figured out it wouldn't be very strange. Boy this solder joint looks messy!
One quick swipe with my soldering iron over the joints removed the short. And lo and behold: the issue was gone, indeed!
Of course, the next step would be making a nice photo for this blog post to show the result. But since the new C2 capacitor was placed a little bit crooked, I decided to quickly give it a blast of hot air. Pure for aesthetics.
Well, that turned out be be a mistake. Apparently the tiny OLED screen near the capacitor didn't really enjoy the cosy warm atmosphere. It still worked, but it clearly had some visible damage.
The greenish yellow part of the screen on the photo below was caused by the heat. Not by a reflection of light. Oops!
So with another blast of hot air I removed the damaged screen and cleaned up the soldering pads.
Luckily I have a huge stash of OLED's laying around, so a replacement part was quickly found.
After an other soldering job, this time with my regular soldering iron, the board worked as it should. Ready to be given away to one of my customers.
And for these two innocent components?
They'll end up in the round archive. AKA the trash bin.
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
✓ Live Streaming✓ Interactive Chat✓ Private Shows✓ HD Quality
Anya is LIVE right now
FREE
Free to watch • No registration required • HD streaming
If you are a regular visitor of my blog, you might have noticed a slightly longer period of inactivity between my regular posts. In the past weeks I've exchanged my soldering iron for a nice juice on a sunny and warm beach. Regular visitors might also know that the mail man usually leaves me a nice package to come home to after my holiday. This time was no exception.
Since I started my Electrocard project, I've tried all different kind of soldering techniques to improve my production speed whilst maintaining the quality. And although I found out a hot air soldering really makes life a lot easier, applying solder paste is a bit of a time consuming work.
To make life a little easier, I ordered a solder stencil with my next batch of Electrocard PCB's (which also fixes the wrong IC footprint). For 15 dollars, Elecrow adds a high quality stencil to your order.
To use solder paste, either a reflow oven or a rework station (hot air soldering iron) is somewhat required. Since I currently don't have enough space for a reflow oven, I have to go for a rework station.
Unfortunately the 35 dollar rework station I owned always resulted in a game of Russian roulette with two possible outcomes: burning my PCB beyond recognition, or burning down my house. Because of this it was time for an upgrade: The mailman's second package ...
The Quick 861DW is an affordable but high quality and semi professional rework station. It has a very clean control panel and heats up lightning fast. It's relatively quiet, and has an extremely convenient feature: auto turnoff when it's placed back in it's holder. Time to go for a spin!
Using one sacrificial Electrocard PCB cut in pieces, I made a template to keep my PCB's in the exact correct spot below my stencil.
Using my IKEA Family pass, I applied the solder paste (Sn62, Pb36, Ag2) on the stencil. Thanks for your help, IKEA!
The first time you do this, you'll be awed by the speed and precision in which you can apply solder paste.
The next step will be picking and placing the parts. I don't own a pick and place machine (yet), but with tweezers and some patience, you'll come a long way.
To make life a little easier, I filled a small pill container with all the tiny parts used for the Electro card. Going through my stash to find the right parts usually took most of the time. So this really speeds up the process.
Next up is putting the Quick Reflow Oven to work. It took some fiddeling to find out the right temperature and airflow. But once I found the sweet spot, the Quick's memory button really came in handy!
The result really puts a smile on my face. Soldering with a reflow station really is a lot of fun ... As long as you don't have to be afraid to burn your house down.
This boy made the transition between the sunny beach and my desk bearable. And whenever I miss the warm days, I just turn it up a notch.
But let's be honoust, this view irreplaceable ... Anyway, good to be back!
PS: If you want to learn more about the Quick 861DW, I recommend watching Louis Rossman's extensive review:
My Electrocards are pretty popular. To make sure I always have a few in stock I tend to assemble a few of them every week. A great way to improve my soldering skills. And try out some different techniques. What's your preferred way of soldering SMD? #electrocard #soldering #electronics #pcb #smd #attiny85 #atmel #arduino #oled #business #card #branding
Now that the hardware part of my Electrocard is done, it's time to start working on the software side of my electronic business card.
This is a 3 part story. Check out the previous parts here:
Part 1: Designing the PCB.
Part 2: Soldering the board.
First of all, it's good to make a list of the desired functionalities. Of course, the OLED screen combined with the 3 push buttons give me a lot of nice opportunities, so most of all, the display will be used to display the important company information for as far as it isn't already printed on the PCB's.
Secondary, it would be nice to display some debug information regarding the battery, the memory and the software version.
And last but not least, it's mandatory to add a nice easter egg to a business card like this. But more about that later.
The controls
Since I have three buttons, and have both primary and secondary functionalities, I want to add a short press and long press feature to the buttons. This is easily done with the help of the clickButton library. It gives me a simple way to add 6 desired modes:
Button A, Short press: Power on / Display the startup screen.
Button B, Short press: Display my company's address.
Button C, Short press: Display my company's & blog's url.
Button A, Long press: Standby mode (also initiated after 30 seconds of inactivity).
Button B, Long press: Debug mode.
Button C, Long press: Start the easter egg.
With the help of the earlier mentioned button library and a simple state machine the user can switch between the various modes, without the need of an complicated user interface.
Controlling the display
Controlling the display isn't particular difficult, especially since there are a lot of example codes and libraries available to control the SSD1306 OLED controlled I've used. I've tried a few of them, and most of them run fine on the ATTiny85 processor. But during the process I found out there are actually two separate challenges.
Control the display by sending an image to the OLED controller.
Drawing realtime graphics onto the screen.
The first challenge isn't extremely difficult. Most of the available libraries allow you to send a 128x32 pixel monochrome image (a BPM converted to a HEX values stored in the micro controller's flash memory) to the OLED controller. It took a while to figure out how to convert the BPM to the correct values, since it depends a bit on how the library reads and writes the data. But after some googling I found a working combination of the TinyOLED library and the LCD Assistant image converter.
This is the same method as used for writing text to the OLED. In stead of one complete stream of image data, every letter has a small portion of data (6 bytes) which is read from the micro controller's flash memory.
The second part is a bit more complicated, and that is mostly due to the limited available memory (RAM) of the ATTiny85 micro controller.
The OLED expects a sequential stream of bytes to control 8 vertical pixels per byte. The 128x32 pixel oled is built up by four rows (called pages) of 8 vertical pixels (1 byte). Each 128 bytes width. In total that adds up to 512 bytes.
If you want to draw lines and shapes on any position on the screen, you'll need to create a buffer for those 4096 pixels (512 bytes) in the micro controller's memory, to which you can draw. After drawing to the buffer, you send the full buffer to the OLED and your lines and shapes are displayed on the screen. That's how most OLED libraries work (for example, the popular Adafruit SSD1306 library).
The problem is, that you'll need to allocate 512 bytes of memory in you micro controller as the buffer. Since the ATTiny85 I used only has 512 bytes of RAM in total, there isn't enough memory to allocate this buffer.
In other words: I can't allocate a buffer. I need to render the drawing while I'm writing all the graphics data to the OLED controller. This turned out to be a BIG challenge. And while I only needed this for incorporating the easter egg, it's something I wanted to solve.
The Easter Egg: Horizontal Micro Tetris!
So, as told, I wanted to add a nice easter egg. I already programmed Pong once. But with the 3 push switches and the width 128x32 pixel screen, i reckon Tetris was better suited. Or to be more precise: horizontal Tetris. The added benefit of tetris is that it doesn't need a high frame rate. And honestly, seeing such a cute little Tetris game on a business card, brings a smile to most people's faces.
Due to the size of the screen, I opted to go for Tetris blocks of 4x4 pixel squares. This way, 8 blocks will fit vertically, and there is room for 32 horizontal blocks. In total there will be room for 256 blocks.
The blocks that are already on screen will be stored in an array called the arenaMatrix. And since each vertical row has 8 blocks, this array will consist of 32 bytes.
unsigned char arenaMatrix [32] = {};
The currently falling piece will be stored in a 4x4 block matrix, called the userMatrix. And since since we only need 16 bits of data, we can easily store this in an integer.
unsigned int playerMatrix = 0;
In other words, for storing all the blocks, we only need 34 bytes of data. Leaving us 478 bytes for additional variables (like the score and the user's piece position) but of course also a lot of other objects and pieces of code that's loaded in to memory.
Since the two matrixes matrices contain every piece of information I want to display on screen during a game of tetris, the render function can "simply" lookup and calculate the bytes of data for the OLED controller on the fly. This solves the lack of the graphics buffer. Or, if you look at it from a different perspecitve: this is an alternative graphics buffer with a 1/16th resolution (since the blocks are made of of 4x4 pixels).
In any way: it allowed me to render tetris without the use of any helper methods like drawLine() or drawSquare(). It all comes down to flipping bits one by one. Which isn't the most convenient, but did teach me A LOT about bit manipulation.
Now, of course, drawing a few matrices to the screen isn't enough to make a playable tetris. It needs some timers to drop the pieces. It needs collision detection to check if the blocks hit an other block. It needs a way to check if a fill line is filled with blocks, and it needs a way to remove the fully filled lines.
The Code
I'd love to run you thru the code, but that would probably account for a full year of blog posts. So to make things easier, I put all my code on GitHub so you can take a look at everything that's in there. Feel free to take a look at the Electrocard Repository.
If you're not familiar with the PlatformIO folder structure, you might want to start at the entrance point of the firmware in the main.cpp file. If you're mainly curious for the Tetris code, check out the Tetris.cpp file.
Fun fact: the full code used almost every byte of flash available in the the ATTiny85 (8KB). Of course, I could work on making the code more efficient, but everything I wanted to be in there is in the code.
Game Over
And with this information, I think this project is a wrap. It was an extremely satisfying and fun project to work on. Both the electronics and the code.
Although I'm extremely satisfied with the end product, there are some things to reconsider if I start a similar product:
Consider a different micro controller. Finding a solution for the limited amount of memory of the ATTiny85 was fun, but having a little bit more memory would probably allow me to add a few nice effects.
If I did have an other micro controller, I'd probably have more GPIO pins, which allowed me to add more buttons, and a nice colorful LED. Every project is better with a LED.
In the future, I'll definitely check EVERY footprint before I order my PCB's.
Work on the software on the breadboard prototype before you finish up the PCB. This would have showed me the limiting factor of the ATTiny85. I would have given me a heads up before I pulled out all my hairs during the search for a solution.
If you have any question or suggestions about this project, feel free to leave them in the comments down below.
Ever since I have my own company I wanted to have a PCB business card. Of course I wouldn't be the first, but it would definitely give a nice touch to my company's identity. And since I wanted to give KiCad a good try anyway, why not go for it?
Of course it's fun to just make a fake pcb layout, but it would be even better if an assembled version of my business card really had some nice features. Since I managed to get a bare SSD1306 OLED working, there wasn't any excuse to not accommodate the business card with an OLED display.
Due to the cost and time of the assembled version, not all my clients or prospects would get the fully assembled edition. The bare PCB will be my default business card. The assembled version will be a present for paying customers. A great incentive to become a paying customer. ;)
Based on the schematics I worked out to control the OLED, the schematics for this ELECTROCARD are pretty straight forward. The OLED requires 8 passive components, and will be controlled by an ATTiny85 which also needs one capacitor. To interact with the business card I'll add 3 SMD push buttons. The board will be powered by a CR2032 coin cell. Since I'll be using the low power sleep mode when the card is not in use, the card won't need a real on/off switch.
With the schematics worked out, I started designing the PCB. Since the card is 85mm x 55mm I have more than enough room for all the components. Of course, I did put some effort in the visual aspect of the PCB layout. This step took a lot of time, since there's alway something to improve. Luckily KiCad's Push and Shove functionality makes it a breeze to make any modifications.
With the help of KiCad's 3D render function I could get a good idea of the final result. So after a few days of tweaking, playing and checking the footprints based on a paper printed version, It was time to order the first version of the PCB. Of course I used red PCB's since this is my company color.
Since I wanted the bare PCB's to be cheap I checked some Chinese PCB production facilities and ended up going for Elecrow. When ordering 50 boards, they would cost me €1,- per board (€6,- per board including components from AliExpress). A perfect price for a premium business card. Normaly you would only order a small batch for testing first, but since I can use unassembled (and faulty) PCB's as my business cards I decided to order 50. Elecrow really did a great job here. Fast delivery. High Quality and perfect communication. If you're looking for cheap PCB's, I can really recommend these guys.
Of course no project can ever go without any set back. While I was waiting for my PCB's to arrive, I received the ATTiny 85's. And lo and behold, they didn't fit the SOIC footprint I used. Stupid me used an ATTiny84 to check the width of the footprint ...
It turned out there are two different package standards. The EIAJ SOIC body is approximately 5.3mm wide, while the JEDEC SOIC body is approximately 3.8mm wide. Make sure to check your parts before ordering your PCBs ... Luckily it isn't a big deal, since I could simply bend the pins of the ATTiny85 and make them fit. None the less: the next batch will have a fixed footprint.
The end result of the PCB really looks more beautiful than I could have hoped. The red soldering mask really pops, and the 0.8mm PCB's are the perfect size to be used as a real business card. On the back I used coper traces to imprint my company's name. Remember that name, it might be the company you need for you future innovation projects. ;)
Next time I'll be showing the hand soldering of one of the cards ... Keep an eye on my blog to make sure you don't miss it. :)
EDIT: Check out Part 2 here.
Psssttt ... wondering what happened to my activity board project? I'm still working on it, but had some issues with sourcing the materials I need. No worries, I'll write an update soon!
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
✓ Live Streaming✓ Interactive Chat✓ Private Shows✓ HD Quality
Anya is LIVE right now
FREE
Free to watch • No registration required • HD streaming