Help with AC Sine Wave project

Go To Last Post
24 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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:

http://www.technoblogy.com/show?QVN

 

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.

 

 

Last Edited: Tue. Dec 5, 2017 - 02:18 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use a the square wave to drive a series resonant LC circuit. This in reality will incorporate your load. You hit it...it rings. Do you have an oscilloscope?

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MrRoger wrote:

Use a the square wave to drive a series resonant LC circuit. This in reality will incorporate your load. You hit it...it rings. Do you have an oscilloscope?

 

 

 

I have a 2 channel DSO.

 

I suspect you are probably spot on, the Chinese driver pictured at top looks to be working that way with the inductor. I'm just not familiar enough with resonant LC circuits to figure out the values needed. and would I need to rely more on amplitude control rather then duty cycle since this is AC? the goal here is to control the density of the mist generated. What would be the best method of generating a square wave at that frequency, or what would be the closest I could get to the target resonant frequency?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

One over two pi root LC, that is the resonant frequency!

 

(Just an edit to add a better explanantion and formula... https://en.wikipedia.org/wiki/LC... )

 

I've never done this with ultrasonics, but this is the way that many driver cct's work, for example the coils in old CRT televisions (this is also why early computer monitors did not like scan frequency being changed ;-) )

 

You will need to take into account the characteristics of the components, for exacmple the US transducer will be capacitive....but will also be fairly self resonant.

 

So perhaps a good place to start would be to look at the 'ringing' you will almost certainly have when blast it with square waves.

 

Last Edited: Mon. Dec 4, 2017 - 07:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Excellent, this puts pieces of the puzzle I was missing in place. Thank you. I will do some more research and tinkering on that end.

 

The only thing I need now is a suitable DC square wave from the ATtiny. but narrowing down the type of waveform needed helps. 

 

Last Edited: Mon. Dec 4, 2017 - 08:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You told us about the US xducer and driver circuit, but not what you are trying to accomplish? 

Why not use the driver chip/xformer shown to drive the xducer?

 

Jim

 

Mission: Improving the readiness of hams world wide : flinthillsradioinc.com

Interests: Ham Radio, Solar power, futures & currency trading - whats yours?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

You told us about the US xducer and driver circuit, but not what you are trying to accomplish? 

Why not use the driver chip/xformer shown to drive the xducer?

 

Jim

 

 

I thought I had in my lengthy post.

I'm trying to use one of these transducers to produce a fog for a project. I have a signed NDA so I can not disclose more then that. Part of the requirements is that I can control the density of the fog with a micro. the project is also battery operated so it needs to stay 5 volts, this is also a project that needs to use off the shelf parts as it won't be a one off deal. I need to be able to order parts from mouser to reproduce the end product and duplicate it. I am designing my own PCB for it as well. that is why I would not be able to use the driver that I mentioned before. I am merely trying to reference its design for my own and do something slightly different with it, since the drivers you get typically for these US Xducers are just single purpose wave form generators. They are really cheap and easy to get a hold of but the driver circuits are a little elusive, a month of research turned up a whole lot of nothing useful. most of what came up in google searches was circuits using 555 timers for the larger 1.7mhz transducers that you find in submerged mist makers. they operate at higher loads and voltages.

 

Basically I just want to have a circuit I can reproduce on my own and have more control over for said project and a few others that are in planning. This is actually new to me, working with Ultrasonic. I understand the principals and the basic concepts but I wasn't familiar with this specific type of transducer. they seem to be fairly new. I had seen a couple posts on the Arduino forums from people looking to explore these as well but the threads dead ended.

Last Edited: Mon. Dec 4, 2017 - 08:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lots of questions.

 

That inductor looks like a step up transformer.  I suspect that the micro drives the NFet which drives the primary of the transformer.  The secondary of the transformer, with a relatively high voltage, drives the transducer.

 There are many ways the micro can connect to the inductor with an R and a  C, please post a schematic. 

 

Have you confirmed the frequency of the driver as 113 KHz?  What is the voltage on the output of the transformer, driving the resistor and the transducer?  (Frequency and Peak-to-Peak voltage, and the waveform's shape)

 

How much energy can the transducer handle, (i.e. what are its specs?), and how much energy are you planning on pumping into it?  The point being, for higher energy outputs you may benefit from using a sine wave driver at the resonate frequency, as the drive signal energy is then maximally coupled into mechanical energy.  At low energies, it  is much, much easier to drive it with a square wave, and the down side is that the harmonic frequency energy is essentially lost as heat within the transducer.  Hence the energy within the harmonicst heats the transducer, and doesn't contribute to the desired mechanical resonance. 

 

Are you building one, or many?

 

If you are building one, then you can tweak the code for the desired frequency, (the transducer's resonant frequency).  If you are building many, then you have to decide if you wish to "tune" each unit for its maximal energy output or not.

 

You mention changing the duty cycle to control the output, (amount of mist generated).  It is not intuitively obvious to me that that is a good approach.  The transformer significantly complicates the circuit analysis in this mode, and I suspect the circuit would not actually be driving the transducer in the manner in which you think it is being driven.

 

You additionally mention amplitude control to control the output, (amount of mist generated).  That is certainly possible, but the above described circuit does not lend itself well to amplitude control of the resonant frequency.  The driver transistor is configured to be fully on or fully off, and the output of the micro and the configuration of the transistor are not ideally set up for operation within the linear range of the transistor.  (Classic Class A or AB amplifier, etc.  I doubt the transformer is configured for a class D output, although if it was, one could in fact have true signal amplitude control.)

 

So, what's that leading up to?  I'd drive the transducer at its resonant frequency, likely with a square wave or a minimally filtered square wave, and I'd adjust the on and off times to control the overall amount of mist generated.  That means you run it on for 0.5 Sec and off for 0.5 Sec for partial mist generation.  Running it always on gives you maximal mist generation, while on for 0.25 Sec, off for 0.75 Sec gives you significantly less mist generation, etc.

 

You are changing the "duty cycle" of the overall system, changing its on time.  You are not attempting to modulate the drive signal itself, either by duty cycle or by amplitude.

 

You mentioned a push-pull driver with the 2N 3904 and 2N 3906 pair, so this is apparently a low energy system.  I'm not sure you need to use a true sine wave to drive the system.  One would have to look at the transducer's data sheet and the manufacturer's App Notes and recommendations in this regard, to see if this was either needed, or worthwhile.

 

Also know that one can measure the transducer's current flow when it is in resonance, and tune the drive frequency to be right on the resonant frequency, if desired.  Note that the low cost humidifiers are a cost sensitive market, and the additional circuit complexity isn't worth it. 

 

Finally, you mentioned the micro monitoring a Bluetooth connection, driving a display, and driving a digitally controlled LED.  None of those tasks require much "processor time", especially if the BT link is interrupt driven.  So, if a Timer/Counter is used to generate the clock signal in hardware, then the micro can easily run the rest of the project.  If, however, for some reason you decide you need to use a microcontroller DDS generated drive signal, then especially at 100+ KHz you might well wish to use a dedicated micro as part of the transducer driver.  I think generating a "good" 100+ KHz sine wave with the DDS approach is a bit challenging in and of itself.  You would, I suspect, likely need a couple of op-amp filter stages to clean up the signal, at which point you would have a very clean sine wave.  But, if one goes that route, you might just as well feed the filter stages a T/C module generated square wave with essentially no processor overhead.

 

Good luck with your project.

 

JC  

 

Cross post, I left for a bit, then posted my comments, without seeing your post...

 

 

 

 

 

Last Edited: Mon. Dec 4, 2017 - 10:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The ‘inductor’ on the board is a transformer - most likely an autotransformer. This is to transform the low voltage/low impedance source to a high voltage/high impedance load which is the piezo transducer.
If you want to buy from Mouser, then you’ll probably have to custom wind it vs probably around $0.50 from china.
The cpu is probably nowhere fast enough to do DDS at any good resolution at 100+kHz as thats 160clocks. Evennif you could do a DDS loop in 16 clocks, thats only 10 times the desired frequency.
Having not used the high speed timers, i could guess you might be able to use ctc mode or pwm with a smaller top value. Or chose a more suitable device.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Its alright I will try to provide you with more information to the best of my abilities.

 

The coil is an iron core transformer. I am pretty sure the windings are identical on both sides because voltage is still 5 volts when applying a pulse of 5 volts across the opposite side. the transformer actually has 8 pins but only 4 are used. 

 

Here is a capture of the trace I got last week when probing the driver.

Channel 1 is the square wave coming from the chip. channel 2 is the sine wave at the transducer while under load producing mist. removing the transducer collapses the sine wave in to distortion. both at within the 10 volt range on the scope but auto setup set the voltage scaling weird.

 

Here is a rough schematic of what the driver circuit looks like

 

T1 is the transformer, ignore the second set of windings. Q1 Doesn't appear to be any specific type of Mfet. one of the boards i have has a small SMD labeled XORB, the other has a larger one labeled Nikos PA110BDA. they vary by manufacturer it seems but all have the same output, transducer specs, and voltages. R2 and R3 are arbitrary resistors, they are small SMD components.

 

The majority of the samples I have pull under 200ma at peak startup and then settle at around 60-100ma during regular use.

 

this is what is driving the ones I have that are samples. they are meant to be bought in bulk form a factory in china and stuck in some cheap plastic bottle cap and powered via a USB charger. sold for pennies on the dollar.

 

The goal is to come up with a method of modulating the signal to change the mist behavior dynamically via the AVR. This is something that I need to be able to reproduce in a production run so off the shelf parts are needed.

 

An ATTINY85 is what is on hand so that is what I have to use. If I need to I can order something else.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Some Pics are attached of the samples I've been reverse engineering and tinkering with.

 

 

Also, The AC sine wave appears to be the only type of waveform that will work for the piezo transducer to start cavitation and produce mist.

Other wave forms or signal types are not going to work here.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Frequency of the sine wave is less key, it just needs to be close to the resonant frequency of the piezo crystal disk I've seen values in the range stated that seem to produce a decent amount of mist regaurdless. The factory outlets sell them as being either 110khz freq, 130khz, or 1.7mhz when selecting different disks. they also come in different voltages and diameters, but I will be strictly working with the 5 volt type. It uses a soft cotton wick to bring water up underneath the diaphragm there is a small dome in the center of the metal diaphragm and the dome is full of micro perforations. when the crystal oscillates at resonant frequency the water cavitates to the top surface and vaporizes in to fine particles. Since they are already mass produced cheaply, I would assume they allow for a margin of error in exact specs. So I have some headroom on what to use. but I know from my research that a sine wave is needed. I have been able to confirm this with a wave form generator set to match the driver. I just need to figure out how to get an ATtiny85 to drive a circuit that will drive one of these. I know I'm not far off but I have never really messed with these kinds of circuits before. most of what I've done is all logic and high power control.

 

I appreciate all of you stopping in to give your 2 cents and advice. Its very much so appreciated. I don't usually ask for help but this is an important project.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The transformer is probably ferrite as iron and powdered iron are too lossy at those frequencies.
You do realise that it is the transducer that makes the sinewave? All you have to do is excite it at the right frequency and it rings like a bell. The circuit you’ve shown with the transformer and the mosfet is what you need. The avr just drives the mosfet. Note the mosfet must be a ‘logic level’ mosfet in order to be driven by the AVR. Your challenge is to generate 113kHz pwm. You probably want pwm so you can vary the amount of energy put into the transducer.
Your scope picture suggests there is around 140V applied to the transducer. This is what i’d expect - not the 5V you speak of.

Last Edited: Tue. Dec 5, 2017 - 04:16 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

You do realise that it is the transducer that makes the sinewave? All you have to do is excite it at the right frequency and it rings like a bell. The circuit you’ve shown with the transformer and the mosfet is what you need. The avr just drives the mosfet. Note the mosfet must be a ‘logic level’ mosfet in order to be driven by the AVR. Your challenge is to generate 113kHz pwm. You probably want pwm so you can vary the amount of energy put into the transducer.

 

Actually no that was not evident to me. I actually have never messed with piezo transducers or crystals before so this is a learning experience for me.

That makes sense though. I was under the impression that the coil was somehow creating the AC sine wave, but from what you just explained, the crystal resonates reverse current back through the coil. So if I were to "ping" the transducer directly with the right frequency I should see a reverse echo back. ok that all makes sense to me now.

 

I knew it was a logic level mosfet, that was obvious with the way the circuit is designed.

 

Now the big question I have is how to produce that frequency in PWM on the AVR without holding up timer functions and built in functions like millis() etc. these are things I use regularly to speed up firmware development.

I would assume you would change the timer1 prescaler and change some registers for the PWM mode? I am not too familiar but I will probably need to study the datasheet section pertaining to that. I'd appreciate some quick tips or code snippets if anyone has the time or patience.

 

Also, Is the transformer absolutely necessary or is there a way to accomplish this with less expensive parts? I am trying to keep the sum of the BOM as low as possible while retaining functions that are needed. The fundamental part of this project is being able to modulate the transducer in real time to provide an "effect" with the mist.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If the chinese use a transformer then it is pretty well guaranteed it is the simplest and cheapest solution.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok but that doesn't help me much, I need to find an equivalent component available for order somewhere. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Reverse engineer the transformer and get a local company to make them.
Or you could make a boost converter to give you 150V then make a h-bridge. That gets rid of the transformer. Cost wise and EMC wise, you’ve made your job much harder.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

Reverse engineer the transformer and get a local company to make them.
Or you could make a boost converter to give you 150V then make a h-bridge. That gets rid of the transformer. Cost wise and EMC wise, you’ve made your job much harder.

 

Not exactly sure where you got the 150v from. nothing in this design reaches that voltage. these small piezo transducers run at much lower voltages then the ones used for ultrasonic cleaners.

 

I guess I will end up having to reverse engineer the transformer and source it.

 

Still missing the code part of this puzzle though.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Personally, i’d just contact the chinese factory and buy theirs. According to you scope picture, the voltage across the transducer is much greater than 5V. The transformer is used for a reason. Go back and measure it again.
Table 12-3 in the tiny85 datasheet gives you some numbers to get your required pwm frequency

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

Personally, i’d just contact the chinese factory and buy theirs. According to you scope picture, the voltage across the transducer is much greater than 5V. The transformer is used for a reason. Go back and measure it again.
Table 12-3 in the tiny85 datasheet gives you some numbers to get your required pwm frequency

 

You ought to take another look at the scope traces. the one channel that displays the square wave is scaled to 20 volts so that I could see the sine wave better in comparison to the square wave. so it appears as though the square wave is significantly lower voltage then the sine wave but they both peak at 5 volts. the sine wave obviously swinging peak to peak by about 10 volts.

 

Its not just one factory its several dozen that produce them, and they all seem to be different. Problem is they don't want to sell just the components. I have a feeling you may be right in that they are produced in house. I will figure something out later for that.

 

Thanks thats what I was looking for, I'll give it a look and come up with something. is there a specific PWM mode I need to set to get fast PWM?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Give me a better picture of the scope. What i can currently see is the square wave at 5V/div and the sine wave at 20V/div. This lines up with what I’d expect. Reverse engineer the transformer and that should give further evidence.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

Give me a better picture of the scope. What i can currently see is the square wave at 5V/div and the sine wave at 20V/div. This lines up with what I’d expect. Reverse engineer the transformer and that should give further evidence.

 

I'll have to get one tomorrow. Its 1:24 AM here in the states.

You have the channels swapped though, the sine wave is the one with the 5v/div not the 20v/div. But I'll go ahead and pull a couple captures from each waveform separately.

This is also confirmed with a Voltmeter btw.

Sorry about that misleading capture. I had grading turned on so you can't really see the difference in which channel is which.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sometimes I wonder why I bother...

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:

Sometimes I wonder why I bother...

 

JC

I'm sorry, whats the problem?