Useless machine

Posted on July 11, 2012 | Category :All, Micro, Projects | No Comments on Useless machine

 Useless Machine Part two >

A simple toy using an attiny85, a servo and a toggle switch.

The idea is simple. A toggle switch is mounted on the top of a box. When turned on, a ‘finger’ pops out of the box, turns the switch off then returns to the box leaving the machine in a powered off state.

The finger will be attached to a servo horn.  When the switch is turned on, the micro will fire up, turn on a relay that by-passes the switch. It will then rotate the servo to move the finger to operate the toggle switch. The micro will then retract the finger and turn off the relay removing power to the circuit.

The micro I intend to use is the attiny85. Why ? Cause I had a couple to play with.

Why ? cause I had just go hold of the USBtinyISP byLadyAda from .:oomlout:. and…. err…

OK, So I have a new toy and wanted a simple project to use it for. This seems pretty simple.  Two outputs, the servo and the relay. No inputs. 5 Volt regulator and a power switch.

I grabbed an attiny85 and my trusty UsbTinyIsp programmer. Bread board awaiting, I add an led, power through a switch to the rails (5 volt regulated from the Bench psu).

Connect up a servo to one of the pwm pins (PB0 or PB1) and away we go…….


My first problem is the code.

I can’t get a pwm generation going……..

Out with the scope.

Play with the code…


Reprogram chip…

Rerun program…

….and loop

After many iterations I get a working waveform.

Hook up the servo.

Trim the top and bottom values.


Working servo control.

After getting the servo to move I had to trim the output.  The attiny can drive a servo beyond its home and full rotation positions.  To get the most out of the servo the code needs to be adjusted so it gets close to full rotation with out hitting the end stops.  This stops the motors and gearboxes in the servo being damaged.

To trim the servo you could use a variable resistor connected to an analogue input. Read this and adjust the servo until correct then output the value some where.  Instead of this I just tried a few values, entering each one in the code and recompiling. Start with a value below the max and approach it bit by bit. When the servo does not move any further for and increase in value, back the value off by one and use that.

I may add a trim feature to the circuit and software.  If this sounds useful, let me know.

On to part 2. The hardware.


Comments 0

Leave a Reply

Your email address will not be published. Required fields are marked *


Powered by WordPress 4.9.4 | Theme MxS2