Using Arduino Uno to Drive full H-Bridge at high frequencies

As more of a proof of concept rather than anything else, I'd like to make a DIY aroma diffuser using a piezo element with a 1.7mHz resonant frequency.

I tried generating a 1.7mHz square wave with the Uno and am running into 2 problems:

1.) The waveform is rather messy when looking at it through the oscilloscope - I can use a capacitor to smooth this out but the result is more of a triangle wave than a square wave.

2.) More importantly, this waveform could not possibly power the piezo element, as it requires a much higher Vpp to diffuse water. Note: While I can't find the specifications anywhere, I have been able to find some YouTube videos of people using these elements with success around +/- 24V.

So: My idea of a solution was to make a full H-bridge out of TIP127's and use an external 24Vdc power supply - which hopefully in theory would give me the +/- 24V I'm looking for.

Is this a viable solution? If so, how would I control the H-bridge with the Arduino Uno, and would I require any additional IC's?

Or, should I try going a different route?

Thank you! John

Can you show your code that generates the messy waveform? Can you show an image of the messy waveform?

Hardware is not my strong point but why a H-bridge and not simply a logic level mosfet?

Post a link to the piezo element for the aroma diffuser you intend to use. Is it similar to this application of a fluid atomizer:

https://www.electroschematics.com/ultrasonic-mist-maker/

In this case a simple mosfet seemed to be enough.

Post crossed with @sterretje

I’ve attached a picture of the waveform before and adding a capacitor to smooth it out.

sterretje:
Can you show your code that generates the messy waveform? Can you show an image of the messy waveform?

Hardware is not my strong point but why a H-bridge and not simply a logic level mosfet?

Here’s the code I’m using - I found this on another forum and it seems to produce the correct frequency…

const uint8_t OUTPUT_PIN = 3;  // = OC2B
const uint8_t PERIOD = 9;      // 9 CPU cycles ~ 1.778 MHz

void setup()
{
    pinMode(OUTPUT_PIN, OUTPUT);
    TCCR2B = 0;           // stop timer
    TCNT2  = 0;           // reset timer
    TCCR2A = _BV(COM2B1)  // non-inverting PWM on OC2B
           | _BV(WGM20)   // fast PWM mode, TOP = OCR2A
           | _BV(WGM21);  // ...ditto
    TCCR2B = _BV(WGM22);  // ...ditto
    OCR2A = PERIOD - 1;
    OCR2B = PERIOD/2 - 1;
}

void loop()
{
  soundBuzzer();
}

void soundBuzzer() 
{
    TCCR2B |= _BV(CS20);  // F_CPU / 1
}

void silenceBuzzer() 
{
    TCCR2B &= ~_BV(CS20);
    TCNT2 = 0;
}

6v6gt:
Post a link to the piezo element for the aroma diffuser you intend to use.
Is it similar to this application of a fluid atomizer:

https://www.electroschematics.com/ultrasonic-mist-maker/

In this case a simple mosfet seemed to be enough.

Post crossed with @sterretje

Yes - that application does look quite similar to what I’m trying to accomplish.

Here’s the link to where I bought the piezo element: https://www.amazon.com/gp/product/B0794MW9FQ/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&psc=1

The main differences between the two I notice are that the one from your link has a 113kHz resonant frequency rather than a 1.7mHz frequency like the one I’m using. I read somewhere that higher resonant frequencies produce a finer mist, which was the reason I decided to use that one vs the 113kHz.

I also see that it seems as if the included circuit diagram uses a 555 timer to produce the frequency rather than an Arduino uC - is this observation correct?

I’m having a bit of trouble understanding how that circuit produces an AC waveform, but based on the output waveform I understand why it works successfully - they achieved a very clean AC waveform with ~60Vpp at the desired resonant point. I basically need to do exactly the same, just at a much higher frequency.

If the 555 timer is responsible for producing the correct frequency, do you think a 555 would be capable of producing the higher frequency I need at 1.7mHz?

OP's waveform images.

|500x305|500x300

How is your scope tip grounded? Are you using a ground spring? If not, try shorten the probe ground lead.