Sine wave generation project controlled via iOS and Android

Hello,

I wish to make a function generator (only sine wave required right now) and am thinking arduino is the best platform for me for the following reasons:

  1. I have the programming skills.
  2. I eventually want to make it controllable via iOS and Android.

I need to be able to do the following:

  1. Create a true accurate sine wave (more on what I understand about accurate and true)
  2. Change the frequency from 20kHz thru to 30kHz
  3. Need to be able to have a resolution of at least 30Hz steps in between the above frequencies.
  4. The amplitude of the sine wave should not vary or have little variation as the frequency is changed.
  5. The frequency should not vary over time and remain as fixed as possible.
  6. eventually communicate wirelessly (blue tooth or wifi) to iOS and Android

What I know so far:
From my reading a standard arduino cannot create a true sine wave with PWM, it would seem you need a DAC.
I'm assuming this is true.
So my assumptions lead me to think I should use an Arduino DUE as this has a DAC onboard.

I would really appreciate help in pointing me in the right direction of what I should use to achieve my above goals.
Any recommendations on the following would be really help:

  1. What arduino is best if any to achieve the above.
  2. What code is out there I can use for generating sine waves
  3. What components and shields will I need if any
  4. All the other bits I have not considered but need to know to achieve the above.

Please note I'm new to arduino but have many years of programming experience.

Thanks in advance for any time you can spare in helping me.

seen this - http://www.ad7c.com/projects/ad9850-dds-vfo/ - ?

robtillaart:
seen this - AD9850 DDS VFO | AD7C - ?

Hello,

Nope I have not see that.
Thank you very much. Looking into it right now.

Are there any all in one (arduino + DAC) if thats what I need solutions?

Are there any all in one (arduino + DAC) if thats what I need solutions?

Arduino Due has 2 DACs, band should be easily capable of generating 20 to 30khz as the CPU runs at 84Mhz

BTW Re: You clients specification

I need to be able to do the following:

  1. Create a true accurate sine wave (more on what I understand about accurate and true)
  2. Change the frequency from 20kHz thru to 30kHz
  3. Need to be able to have a resolution of at least 30Hz steps in between the above frequencies.
  4. The amplitude of the sine wave should not vary or have little variation as the frequency is changed.
  5. The frequency should not vary over time and remain as fixed as possible.
  6. eventually communicate wirelessly (blue tooth or wifi) to iOS and Android

It would be helpful if you could tell us exactly what you are building, or its it commercial in confidence etc

rogerClark:
BTW Re: You clients specification

I need to be able to do the following:

  1. Create a true accurate sine wave (more on what I understand about accurate and true)
  2. Change the frequency from 20kHz thru to 30kHz
  3. Need to be able to have a resolution of at least 30Hz steps in between the above frequencies.
  4. The amplitude of the sine wave should not vary or have little variation as the frequency is changed.
  5. The frequency should not vary over time and remain as fixed as possible.
  6. eventually communicate wirelessly (blue tooth or wifi) to iOS and Android

It would be helpful if you could tell us exactly what you are building, or its it commercial in confidence etc

Thanks for the advice about Ardiuno DUE Roger.
Is there any sample projects to use that can help me with generating a sine wave as per my needs?

This is not for a client, its just a hobby project.
At the moment its an idea I'm investigating to do with harmonics.

I hope that helps if you need any other information then is there any specific metrics I can give apart from what I have provided that would help?

Is there any sample projects to use that can help me with generating a sine wave as per my needs?

http://lmgtfy.com/?q=due+dac

Look at the result for the youtube video and follow the links :wink:

rogerClark:

Is there any sample projects to use that can help me with generating a sine wave as per my needs?

http://lmgtfy.com/?q=due+dac

Look at the result for the youtube video and follow the links :wink:

Thanks Roger.

I've seen that video before but could not determine if the quality of the sine wave would be meet my needs.
Is anyone able to verify that?

Did you look at the code, it doesn't use a very big table to generate the sine wave.
It looks like its only 64 bytes at the most.

What resolution of sine wave do you require?

You could calculate the theoretical maximum frequency of a 12 bit sine wave, based on the shape of a sine wave, and a 1 bit change per sample at the zero crossing point.
I.e if the due was doing nothing else except outputting to the dac.

In practice, the Arduino core does a lot of other stuff like running the millis timer etc.

So the max update rate would have to factor in these other interrupts

I think the problem is that the Due is a fairly new board, so not many people are using them.
I only got one last week, and have not had time to do anything with it apart from uploading Blink to test it works at all

rogerClark:
Did you look at the code, it doesn't use a very big table to generate the sine wave.
It looks like its only 64 bytes at the most.

What resolution of sine wave do you require?

You could calculate the theoretical maximum frequency of a 12 bit sine wave, based on the shape of a sine wave, and a 1 bit change per sample at the zero crossing point.
I.e if the due was doing nothing else except outputting to the dac.

In practice, the Arduino core does a lot of other stuff like running the millis timer etc.

So the max update rate would have to factor in these other interrupts

I think the problem is that the Due is a fairly new board, so not many people are using them.
I only got one last week, and have not had time to do anything with it apart from uploading Blink to test it works at all

Thanks again Roger.
Thats very helpful info.

Please keep me posted on should you find anything useful regarding doing this on a DUE.

BTW.

What do you mean by

Create a true accurate sine wave

There is no such thing in the digital world, only approximations of a sine wave

I think you would probably need to use an analogue circuit of some type to get a "true accurate sine wave"

What resolution do you require, e.g. 8 bit, 10 bit 12 bit ?

BTW. I don't think the Due would be fast enough to output data at 12bit (4096) resolution such that the steepest part of the Sin curve only changed 1 LSB of the DAC

I'm not even sure if it could manage 10 bits (you'd need to do the maths)

rogerClark:
BTW.

What do you mean by

Create a true accurate sine wave

There is no such thing in the digital world, only approximations of a sine wave

I think you would probably need to use an analogue circuit of some type to get a "true accurate sine wave"

What resolution do you require, e.g. 8 bit, 10 bit 12 bit ?

BTW. I don't think the Due would be fast enough to output data at 12bit (4096) resolution such that the steepest part of the Sin curve only changed 1 LSB of the DAC

I'm not even sure if it could manage 10 bits (you'd need to do the maths)

I'm not entirely 100% sure what BIT precision I need here I'm both experimenting and learning as I go.
I assume by BIT you mean what memory chunk sizes I need to store the array of values of the sine wave approximations into?
IS that correct?

What I feel is a "true wave" is a consistent and symmetrical sine wave, I hope that makes sense.

Danny Mendoza (the guy with the you tube video thats used the DUE) mentioned I could use a filter to help smooth out the wave.

Just as I side note I think currently as it stands we live in a digital universe. This is because time is actually not continuous, I believe you can only subdivide it until you reach planck's constant.

So I guess we are all analogue approximations :slight_smile:

I need here I'm both experimenting and learning as I go

Probably best just to get a Due and try it.

Alternatively the external hardware oscillator AD9850 is very good,

http://www.instructables.com/id/0-40Mhz-Sine-wave-generator-for-25/ and would mean you can use any Arduino to control it.

Albeit you can't control the amplitude as far as I'm aware

Re: Filtering

Yes. That can work, but you'd have to take the effects of the filter into consideration with the amplitude of the sine wave, or perhaps build a closed loop system e.g. feedback using the ADC to monitor the output of the filter

Albeit you can't control the amplitude as far as I'm aware

use a digital (I2C) potentiometer to reduce the signal ?