Digital to Analog Signal Conversion Feasability

I am trying to assess the feasibility of employing an Arduino to generate 2 sine waves of different frequencies (which must be in sync with each other) based upon an input of a 0-5v square wave. One of the output signals would be the same frequency as the input, & the second a division of the first. The max frequency would be around 5kHz.

Perhaps something like this has already been attempted on this forum?

Thank in advance for the help.

A avr is good for generating PWM waveforms up to about 8kHz. These have to be filtered in order to render sine waves. But this requires register manipulation which can possibly interfere with other timing functions. The analogWrite() has a fixed PWM frequency of 490 Hz and is not feasible.

Sounds vaguely possible, but there are no doubt better ways to do it.

The thing is, exactly what do you want to do this for? That would profoundly influence the optimum way of doing it.

Hi,

2 sine waves of different frequencies (which must be in sync with each other)

Okay I'm game, draw me a diagram of two sinewave of different frequencies and in sync with each other.

Tom..... :slight_smile:
Draw it and post a picture as an attachment..

I think he means that one wave has a frequency that is a integer multiple of the other and they share some of their zero crossings and that the one with the higher frequency has its zero crossings coincide with the edges of the square wave

Hi, one frequency is a harmonic of the other.

Tom..... :slight_smile:

This is a lot harder than you think. To output a sin wave at the same frequency as an input square wave is impossible because as the square wave comes in you do not know when. It will finish. You have to time the last square wave, then work out the sample frequency you sin output requires and output samples to the D/A at that rate at the same time as timing the next square wave. So at the very best the output will always be one wave period behind the input.
What frequency do you want the samples of the 5KHz to be at?

You are much better off doing the whole thing in hardware using a phased locked loop.

nilton61:
I think he means that one wave has a frequency that is a integer multiple of the other and they share some of their zero crossings and that the one with the higher frequency has its zero crossings coincide with the edges of the square wave

Grumpy_Mike:
This is a lot harder than you think. ... You are much better off doing the whole thing in hardware using a phased locked loop.

Which is why I say - he needs to tell us what he actually needs and why. It is just as likely something entirely different.

Gentleman (& Ladies if there are any here),

Thank you for your responses. Here is a picture of what I want the sine waves to look like. I will post a picture of the square wave in a little while. Right now, I have to take my kids to school.

Thanks again for the genuinely intelligent replies. :slight_smile:

Couple of problems

  1. Those are not sin waves
  2. Those are not constant amplitude waves

I think you will have to explain a lot more about what you are trying to do. Your original post is looking like an X Y problem.

Grumpy_Mike:
You are much better off doing the whole thing in hardware using a phased locked loop.

Do you mind explain briefly how you would go about doing that?

A phase locked loop is an electronic sub system, which consists of a phase comparator where you input a reference signal ( the square wave you want to lock to ) and the signal from a VCO (voltage controlled oscillator ). The output of the phase comparator is fed to a filter and the output of that is fed to the VCO's input. For your system the VCO should be a sin wave oscillator with a comparator to square it up on the output before feeding it to the comparator. The VCO output will follow the square wave frequency.

To get your lower sin wave simply divide the input square wave by two or four or what ever sub harmonic you want to use and feed that into another phase locked loop (PLL).

You can get all the active components of a PLL in a single chip, google around for circuits. For an introduction see:-

While it might seem complex it is one hell of a lot easier than trying to do it in software.