Go Down

Topic: sine wave generator (Read 4 times) previous topic - next topic

MGeo

#20
Jun 23, 2011, 12:04 pm Last Edit: Jun 23, 2011, 12:07 pm by MGeo Reason: 1

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


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.

Grumpy_Mike

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.

aphy

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

aphy

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?

AWOL

Yes, but at the wrong frequency.
(40kHz == 25us cycle)
"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.

Go Up