Poll
Question: 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-grin
Do I still need to use Digital-to-Analog converter? - 0 (0%)
Is there other options? maybe the simplest way to generate 25 kHz sine wave using arduino? - 1 (100%)
Total Voters: 1

Pages: 1 [2] 3   Go Down
Author Topic: sine wave generator  (Read 3699 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 211
Posts: 13471
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 286
Posts: 25663
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
« Last Edit: June 22, 2011, 08:35:02 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok thank you very much!!! smiley-grin

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..
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 596
Posts: 33290
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
i'm just afraid to try the square wave because i'm afraid to break my sensor.
But the data sheet specifies square waves.

Quote
but one of us first picked up a pair of Murata 40kHz transducers about thirty years ago
Make that two of us  smiley
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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-grin

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.
« Last Edit: June 23, 2011, 05:07:31 am by MGeo » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 596
Posts: 33290
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 286
Posts: 25663
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

oh yes. that would make it 12.5
thank you very much!!! smiley-grin
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 286
Posts: 25663
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You'll probably find that you need shorter delays than that (you can't have a x.5us delay anyway) to account for the overheads of "digitalWrite".
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

then what could be the best way to do? and amplifier for the square wave? thanks
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 286
Posts: 25663
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
then what could be the best way to do?
Get hold of an oscilloscope or a frequency counter, and tweak your loop times until you get closest to 40kHz.

Quote
and amplifier for the square wave?
MAX232 or similar.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 211
Posts: 13471
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
to account for the overheads of "digitalWrite".

For those frequencies you might also need a look into direct port manipulation: - http://www.arduino.cc/en/Reference/PortManipulation

You must know the pin in advance, but thats not the problem I guess
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: 1 [2] 3   Go Up
Jump to: