Pomodoro r2 – Update 1

Today, I did some research on my Pomodoro revision 2 specifications, and have come to some valuable conclusions. The main one being that my idea to control the brightness of all the LEDs via PWM, sadly, won’t work. Apparently, to use PWM with timer interrupts on an AVR, you need to use dedicated output pins to do so. When exploring the possible μCs that I could use to rework the Pomodoro timer, I settled on the ATtiny84. That μC has just enough pins, belongs to the AVR family, so my program will need minimal adjustment, and I have a fairly good idea on how to downclock it to save power. However, it only has four possible pins to use for PWM, as you can see below.

A schematic showing the pinouts of the ATtiny 24/44/84 family of microcontrollers. Each pin has an overview of all its functions next to it.
Figure 1: The pin-out schematic for the ATtiny84

Now, to be fair, I don’t even know exactly if all four can be used equally for single PWM signals, or if they need do be used in pairs. Regardless, even if they could all be used, that would still leave me one short even if I just wanted to adjust only the timing LEDs. So, easily said, I’ll scrap that off my list; it was an optional feature in any case. That makes for the second feature to be scrapped (I already concluded that the LCD screen would raise my voltage requirements).

I’ve also reconsidered my choice of the coin cell battery, opting instead for two rechargeable batteries. Firstly, I want to move towards more rechargeable power in any case (sustainability is important to me), and this offers me an easy way to do that without immediately having to learn about USB charging in a project. While I want to learn about that, it seems a little overkill for this project. Plus, I figure that including the battery holder on the back of the board somehow may actually provide it with something of a stand.

My first experiments with the volume control for the beeper were successful, but not particularly satisfying. Using a potentiometer, I could adjust the volume; however, it took so little resistance for the beeper to mute, that most of the potentiometer was wasted. I’ll have to test out a range of resistance values to see what makes a relevant value of potentiometer to use. If I can’t find a satisfactory value, I may also just use a switch to make a mute button. I mean, it’s either there to attract your attention, or it isn’t, right?

That leads to the following update to the feature list:

  • Include a 3v coin cell battery; and
  • Include 2 1.5v rechargeable batteries; and
  • Rewrite the program to run off a type of ATtiny an ATtiny84; and
  • Rework the program to use timer interrupts.
  • Change the LEDs to a single LCD screen; and
  • Add a volume control for the beeper; and
  • Add a brightness control for the lights.

Pomodoro r2

I didn’t quite feel settled with my current Pomodoro project. I’d worked up the prototype, and I’m happy it works (despite it being sloppy), but I also think there were several points for improvement left. Or, at the very least, it just didn’t feel done. I figure that the minimal specification to call it a working prototype is to have a battery included, so that it is fully self-sufficient, rather than it is now (which requires either hooking up a battery ad-hoc, or connecting it to USB via the ISP programmer). As I was brainstorming what I wanted to do with it, I came up with the following list:

  • Include a 3v coin cell battery; and
  • Rewrite the program to run off a type of ATtiny; and
  • Rework the program to use timer interrupts.

Now, I thought before of changing the μC around, but at the time, I wasn’t really sure of the what and how. Thankfully, thanks to some helpful YouTube videos, now I do, and it seems reasonable to rework the schematic to not waste the full potential of an ATMega328p on a program which needs about half of the pins. A major thing I learned from the Assembly tutorial is that you can drastically reduce power consumption by working with timer interrupts rather than using a sleep function. Considering I want the project to become more portable, getting the most out of the 3V cell seems like a great idea.

As I was thinking of those, I thought of a few other options that might be interesting. I separated these, however, because the ones in the first list are what I’d consider necessary to call the project done, these would be interesting additional features to add:

  • Change the LEDs to a single LCD screen; and
  • Add a volume control for the beeper; and
  • Add a brightness control for the lights.

The first would be cool, though I’m not sure if it will fit the project. The major issue with it is that a very cursory glance of LCD screens seems to imply that they need a 5V power source, and my intention is to keep the project small, light, and to get as much as I can out of the LEDs. While I want to get an LCD screen and play around to learn about I2C, that may be a thing for a later project.

The other two, however, shouldn’t be too difficult. The beeper I have on there is quite loud, which is good, but I can imagine there’s occasions where I’d want a more subtle notification (plus, my wife will be grateful for less noise too). I could either just install a slide switch to turn it off or on, or perhaps I can put in a potentiometer for more fine-tuned control. The latter will take some experimentation, which will be fun in and of itself.

The brightness control is something that I’d also want to experiment with. Clearly, having a potentiometer for each individual LED would be needlessly complex, let alone that it would result in inconsistent brightness of LEDs. Rather, I would want to handle that directly from the μC. Now, I’ve been reading a bit about PWM signals, and that would seem to fit the bill. Given that my project uses 11 pins (9 LEDs, a buzzer, and a button), adding power and ground, means I have to use a DIP-14 package; i.e. there would be one pin open. What I could explore is if I can use a potentiometer there to control the μC PWM duty cycle. Not only would that mean I can control the brightness, but unlike using resistors to do so, this method would actually also save power and match my original goal of having a low-powered portable device.

I know nothing about PWM aside from the broad concept, so that would be an interesting thing to learn about. That would mean that revising this project would teach me about both timer interrupts and PWM signals – score! On top of that, I do enjoy how that would make the control of the device consistent: a single push button to control pauses and resets, and two potentiometers to control the amplitude of the output (whether soundwaves or lightwaves).

If I only manage to add the battery and have it at that, I think I’ll leave it as a perfboard prototype. If I do the other points as well, I think I’ll see about designing it as a PCB, and having it manufactured somewhere to get a final product. That’d be bonus points for practicing PCB design and soldering!

Point-to-Point failings and lessons

Well, I tried soldering the pomodoro timer from the underside, and, essentially, my skills were lacking – though I suspect I also tried to do something you just shouldn’t really do. You see, I was going to attempt to solder wires directly from a point on the underside to another point. The problem I run into is that I can’t really add a wire on top of a solder point like that. Have a gander at the image below to see some of what happened.

The underside of a perfboard with solder blobs for a set of components.
There are three things to note in this image: firstly, there’s a nice, direct wire running at the top; secondly, right in the middle, there’s a lot of sloppy solder on the two central rails; and, thirdy, in the bottom middle you can see a section where three copper islands have come off the board.

The first thing that went rather wrong was when I was trying to solder an ISP header on the perfboard. I’m talking about those three missing islands at the bottom center of that perfboard. I noticed, after soldering, that what I had soldered was skewed and wouldn’t hold my connector. So, I tried to bend it a little so that it would stick – big mistake there. What I ended up doing was tearing the copper islands off the perfboard, rendering that connector pretty much useless.

The second big problem is right in the middle of the photo. You can see some sloppy soldering there, and what looks to be a loose bit of metal in the middle of that solder. I was attempting to make a nice bridge between the central rail and a pin using a tin wire. However, by trying to put it on top of an already soldered pin, I ended up just trying to smush it next to it, which quickly became very messy. In part, I think my tin wire is too thick. If it were a little thinner, I could have it wrap around the pin and then solder the two together. Secondly, I tried to do this the wrong way around: I first soldered the pin, and then tried to lay out the wire. As a result, it started shifting. I think I need to solder the other end down first, and then either wrap the other end around the island awaiting the pin for the final soldering, or wrap it tightly around the soldered pin and try to melt that in.

The top part is something I’m more pleased with, despite the top right being a little messy. I should have planned this better and laid out the rail first, but either way, I decided to put a single ground rail there to connect all the LEDs to. Sloppy as it is, I think it would have made a really stable connection.

Overall, I think I need to conclude two things: firstly, in trying to make these connections work out, I ended up using far too much solder in places, causing these unsightly bumps. Secondly, I tried to be a little to flexible in this process at this point, which didn’t work out at all. What I need to do is plan out the perfboard in far more detail before starting to solder. Perhaps I’ll put it all on a much larger space. Alternatively, maybe I’ll add another dimension to it by using two bits of perfboard and a connection between them – if I screw them together it’ll be someting of an open box, as it were. That would certainly give me some more space.

Either way, this failure gives me a great opportunity to redesign and improve what I have here. I’m looking forward to making this thing work after all.

Point-to-Point Pomodoro

Today I tried laying out the pomodoro timer on a small breadboard I had lying around.In the end, I could fit everything on the board, so that was good news. There are two major drawbacks to this, however: firstly, as you may notice, there’s no power laid out here yet; and, secondly, I’m going to have to solder this point-to-point.

Components of the pomodoro circuit on a breadboard
The initial layout for my pomodoro timer. At least, this seemed like a decent way to have everything on a breadboard I had lying around. It looks reasonably functional, though the downside will be that I’ll have to do a point-to-point soldering, as there’s too little room to properly place the wires on the board.

As far as power is concerned, I’m planning to use a 3.3V coin battery, which I was hoping to mount somewhere on the back. However, given how tight everything is mounted, that may not be an option. I’ll pretty much be using every little bit of real estate there. Firstly, of course, for the leads of the components, but as they’re all placed so close to each other, I’ll have to do point-to-point soldering, I’m assuming right now. That will also imply I won’t have a surface left to glue a coin battery mount to. I may have to resort to leaving that just trailing on a side.

Either way, I’m looking forward to soldering these components on soon, now that I have a basic layout going.

Pomodoro Breadboard

Yesterday, I liberated the Atmega328p from the Arduino Uno, and installed it in the breadboard. I rewired the full thing to fit on the one board, changed the resistances for the LEDs around to 220Ohm (as I moved from the 9V to a 3V power source), and had to fiddle with the code a bit to get the ports correct. I’m pretty pleased with a fully working breadboard prototype. The next step is to solder it to some perfboard, and have a mobile prototype ready. Perhaps if I enjoy it enough, I’ll actually make some PCBs for this.

This photo shows all the components of the pomodoro timer on a breadboard, with a long ISP-6 cable in the middle leading off-screen.
The finished prototype on my breadboard. As I wired this up, I discovered that some of the ports on my schematic were off. Fortunately, now that I have an ISP in there (that wide cable in the middle there), I could just adjust the code slighlty to match the ports that I had on the schematic.

One thing that I might consider to add is a small switch near the buzzer to turn the audio off or on if needed.

This image shows the electrical schematic of the pomodoro timer.
I adjusted the schematic based on the redesign, and also cleaned it up a little more from the last iteration. The only thing I can see that would make it neater is to adjust that reset connection between the ISP and the ATmega328P so that the reset line is at the top, to clean up the resistor. However, I didn’t feel like editing up the schematic in KiCad, save it to a new library, and so on.

Pomodoro Timer r2

As I mentioned yesterday, I learned a little bit more about ISP, and so I learned not only how to run the Atmega328P without an external crystal timer, but also how to flash it on the fly. I’m pretty happy with this redesign right now, and don’t see it changing significantly. Possibly, another revision might replace the IC with a version of ATtiny, seeing as how eight ports are not used in this design. As far as the actual schematic is concerned, I’m pretty pleased with how orderly it came out, though I’m less pleased with how the ISP module connects to the Atmega328P: there are 11 crossing cables in there, due to the positioning of the AVR-ISP-6.

If I were to clean this up, I’d have to basically make a new symbol for the Atmega328p that would fit that general principle. PB0, PB3, PB4, PB5, and PC6 are better suited to be placed on the left side of the Atmega328p, considering they’re all set as inputs. That would make the whole image much cleaner as a result. I guess if I ever do end up making a fourth revision, I’ll clean that image up for a more final result.

The third revision of the Pomodoro timer, which is likely to be a final version for the time being.

Yesterday, I also managed to run my first succesful test of uploading an Arduino sketch using the USB programmer. I haven’t tried uploading directly through AVRDude just yet, because that would involve compiling my own code, which would be the next step. First, I wanted to see whether uploading itself would work. So, I hooked up my USB programmer to the Arduino Uno, and used the Arduino IDE to flash the Atmega328P via the programmer (for which it uses AVRDude in the background anyway). It went off without a hitch! I also tried setting the lfuse to 0xF2 to have it run on its internal clock, which results in the program running half as slow (as the internal clock is 8Mhz versus the 16Mhz external crystal). So, I did have to adjust some timers to have it run correctly again.