Hello, First post!
I hope you all will be patient with me as I try to wrap my brain around the concepts and code that I have yet to be familiarized with.
First, a brief background to help you understand where I am at:
I have been tinkering about with electronics for many years, AVRs have been an learning experience since 2010, I consider myself an advanced beginner. I know how to do some direct register manipulation with C code in Arduino IDE. I have written some fairly advanced code with libraries in Arduino with standard C++. And I have completed several timer based projects, usually dealing with bit banging data out of different GPIO pins when needed. My experience with assembly and playing with timer registers directly is somewhat limited still, I'm trying to advance in this area.
I have a project where I need to drive an untra sonic piezo transducer with a modulated sine wave with a specific frequency. 113k hz seems to be the magic number to hit the transducers resonant frequency. I reverse engineered a driver circuit that comes with one of those USB powered cool mist humidifier bottle caps. You can find some information on them from google. I did some digging and found several Chinese factories that sell them as well as manufacturers that make the transducer disks in different voltage, resonant frequency, and diameters. The driver circuit used typically for the USB versions has a small 8 pin chip with a single tactile switch on one pin tied to ground, an output for LED lighting if it has that feature, and a single output pin that generates the signal to the driver circuit. the chip is unmarked, no big surprise there. The driver is usually a small mosfet with a small capacitor and a resistor on the logic side. the mosfet is tied to one side of a coil, the other end of which is tied to +5v. the inductor has a second coil that is connected to the transducer with a series resistor oh 330ohms. On my scope I can see a perfect 5volts DC square wave with a 50% duty cycle on the chip side. and on the transducer side I see a perfect AC sine wave. Seems simple enough but not knowing the values of the coil makes it harder to reproduce.
My goal is to generate an AC sine wave using some simple BJT transistors and passive components and an AVR tiny85. I want to be able to control the duty cycle of the output and have a stable and somewhat clean 111khz-120khz signal. I've tried a few things so far.
First I tried driving the mosfet on one of the driver boards i took apart, replacing the proprietary chip. But I could not get the square wave to stabilize at the correct frequency, I was trying to use PWM on the arduino Nano with tweaked prescalers, it didn't work very well, the arduino was sputtering and jittery at the frequency I was able to get closest to. My second Idea was to use a single H bridge using 3904 and 3906 BJT transistors to drive it then using a DDS method from a tiny85 using methods also found online. but I can not figure out how to get the frequency close to the target with some stability. the other issue here is that I also need to do other things with the tiny85 such as control addressable LEDs, control an I2C OLED display, and receive input from a bluetooth module over serial. If I have to separate this in to two chips I will, I'll just need a method to control the duty cycle from the main chip and let the slave handle the frequency modulation and DDS.
Alright sorry for the lengthy backstory. anyways, I am looking for advice from more experience people who know these chips better. What would be the best method of driving one of these transducers directly with an AVR? preferably within the ATTiny family. Preferably on one chip with as few external components as possible. I know I was going to need an LC filter to smooth the signal in to a clean sine but that I will handle. I just need a stable signal of some type out of the AVR and the end result has to be within the range of 110-120khz with the ability to control the duty cycle on the fly. a DDS would be ideal as it would allow greater control of the signal IMO. but I want to hear some more ideas here. Any help is greatly appreciated. Several minds are better then one and I've already racked my brain on this for 2 weeks with lots of digging online. I finally had to create an account here to ask for help after giving up on finding a clear answer online.
Here is a link to a sit where there is some code posted and a somewhat vague explanation of using the 64mhz PLL timer on a tiny85 to create a DDS but it doesn't explain the math used:
here is one of the drivers in question from China:
UPDATE: Posted below are some signal traces from my scope of the waveforms that are seen on the chinese driver circuit. The transformer is a 1:1 iron core seemingly. the current is under 200ma. Posted below is also a schematic of the Chinese driver circuit for the piezo transducer.