Function generators are a handy bench tool to have around, and while you can usually cobble something together that works, it is much more handy to grab a device when you need it. Thats where this function generator sent to us by [Mohonri]comes in. Based around a ATTiny25 and a rail to rail op amp which is able to replicate frequencies from 1Hz to about 40KHz, in square, triangle, and sinewaves simultaneously.
The function generator also features independent amplitude control on each output. And it’s all on one palm-sized, single-sided PCB. The main part of the code is split into two parts: the main loop gets the inputs and constructs a waveform table in SRAM, and then an ISR reads that table and outputs it to one of the timers, which produces a PWM output, which is low-pass-filtered and then passes through a potentiometer (for amplitude control) and then to an op-amp before landing on a set of terminals.
Though its not 100% perfect, trading speed for a 6 bit resolution, it should be more than enough for most electronic projects. You can pick it up in kit form from the on-line shop, but schematics, software and PCB layouts are also available for download.

Filed under: ATtiny hacks