# sine wave generator

Hi. I just want to know if it is possible to output 25 kHz sine wave using arudino Duemilanove? I will use it to drive my ultrasonic sensor. Thanks! :D

Does it really need a sine wave?
How clean does it need to be?
Do you have a spec for the transducers?

What voltage? + - ?

I'm using Murata MA40E7r/s transducers. I'm really not sure if it will work on square waves, because i need the + and -

I'm really not sure if it will work on square waves, because i need the + and -

Lots of designs use RS232 drivers for this purpose.

NB 40kHz (25us cycle time)

so what's the simplest way to do?

Well, depends what you're trying to do. (you haven't said) The spec says 85V full-whack, but only with a 10Hz repetition rate.

what I'm trying to do is just to use arduino as replacement for function generator. so I just need to output sine wave using arduino with frequency of 25 kHz.

These devices tend to be very resonant, and 25kHz is a long way off the spec of 40kHz, so it won't be very efficient at 25kHz. Can you tell us what you want to do with this transducer/sensor pair?

The spec says you can drive it up to 85V, but only with 16 cycles of 40kHz (0.4ms) every 100ms. It will probably ring for at least as long (up to maybe a millisecond) again.

Honestly, I just thought I would use 25 kHz because I need ultrasound to penetrate wood. Do you know someone who's done something like this before? I mean, I really need help. and what I'm trying to do is a hand-held device and so the first thing that I'm trying to do is make arduino act as a function generator.

I just thought I would use 25 kHz because I need ultrasound to penetrate wood

Ultra sound doesn't penetrate wood. Hit it with a square wave at 40KHz, it is going to go off at that rate anyway no matter what you hit it with.

Honestly, I just thought I would use 25 kHz because I need ultrasound to penetrate wood

So why pick a 40kHz transducer?

These things are not like loudspeakers with a roughly flat response across part of the audio spectrum - they peak massively at their resonant frequency; that's what they're designed for.

Generating 40kHz is relatively simple (a simple for loop with some padding will need a little tuning and experimentation), it just depends what else you need to be doing at the same time, but you seem to be avoiding the question.

ULTRASOUND PENETRATES WOOD.

why are you saying that i'm avoiding your question? i mean what question anyway? what i am doing may be too simple for you so I just need to know how to generate sine wave using arduino? that's all. thank you

Are you saying that the Arduino (which doesn’t need to generate a sine wave; you can prove this by switching your sig-gen to square) just needs to generate 40kHz?
You could do that with a 555 and save yourself money.
Do you need continuous 40kHz (in which case you won’t be able to use full power), or do you want bursts of maximum power at a PRR of 10Hz?

@aphy Can you explain why you want to penetrate wood ?

can 555 create nice 40 kHz sine wave? do you have any schematic? thanks

No, a 555 can’t generate a nice sine wave at 40kHz, but it has been repeatedly pointed out to you that you don’t need a 40kHz sine wave when a 40kHz square wave will do the job just as well.
A 555 will produce a 40kHz square wave.

I just guessing here, but one of us first picked up a pair of Murata 40kHz transducers about thirty years ago and happily drove it with a 555, then an 8080, a Z80, a 6809, a 68000, a PIC and then an Arduino, and one of us didn’t.

(Edit: oops missed out T450 transputer)

ok thank you very much!!! :D

i will try the square wave and the 555 as well. sorry i'm just afraid to try the square wave because i'm afraid to break my sensor.

but then i guess I'll do it. thanks..

i'm just afraid to try the square wave because i'm afraid to break my sensor.

But the data sheet specifies square waves.

but one of us first picked up a pair of Murata 40kHz transducers about thirty years ago

Make that two of us :)