sine wave generator

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!!! :smiley:

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 :slight_smile:

aphy:
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! :smiley:

Did you get an answer to your original question?

Google DDS (for direct digital synthesis), NCO (numeric controlled oscillator) and read up. These are techniques that let a micro generate programmable sine waves.

Here is a link to a good one http://interface.khm.de/index.php/lab/experiments/arduino-dds-sinewave-generator/

The link shows a fancy filter on the output, but you can get away with a simple RC if your not too picky on bandwidth and distortion. Try it and let us know how it works.

Did you get an answer to your original question?

We established that he did not want to do this at all. Well that is he did not need to do it as a square wave would do equally as well, and that it would have done him no good even if he had generated one.

@grumpy mike, I've tried the square wave but How can I get 40kHz? I tried the PWM but the frequency is quite low.

int outPin = 8; // digital pin 8

void setup()
{
pinMode(outPin, OUTPUT); // sets the digital pin as output
}

void loop()
{
digitalWrite(outPin, HIGH); // sets the pin on
delayMicroseconds(25); // pauses for 25 microseconds
digitalWrite(outPin, LOW); // sets the pin off
delayMicroseconds(25); // pauses for 25 microseconds
}

will this program be ok to drive my ultrasonic transmitter?

Yes, but at the wrong frequency.
(40kHz == 25us cycle)