Close

Another improvement

A project log for Annoy-o-tron Tiny

The (in)famous beeping prank made as small as possible

nick-sayerNick Sayer 06/27/2020 at 19:090 Comments

The 1.0 boards are being built now, but I've already had an idea for a 1.1 improvement.

With 1.0, one pin of the controller is connected to the piezo element and the other lead of the element is grounded. This means that the piezo will see a 3 volt square wave.

Instead, v1.1 hooks one pin of the controller to each side of the element and it is fed with two square waves 180º out of phase. In this manner the piezo element effectively sees a square wave with a peak-to-peak amplitude of 6 volts.

Previously, I was careful to use pin B2, which is the only pin not involved in TPI on the chip. By using two pins, it forces us to use one of those TPI pins. But B2 will be high impedance during programming, so this isn't as big a deal as it might seem - the piezo will effectively have one side disconnected and the other won't therefore load the programming pin.

The code doesn't have to change much. There are already instructions to set up the DDR register, toggle the pin and clear it when the beeping is done. In principle these instructions simply need to have the constants changed to have two bits set instead of one. The one extra instruction needed is to set one (but not both) pins to 1 at the start of the beeping. From then on, toggling both will result in the out-of-phase square waves we want. At the end, both outputs are set low. As before, the remaining (non !RESET) pin is set to be an input with the pull-up turned on. This will minimize power consumption.

Discussions