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:
I have the programming skills.
I eventually want to make it controllable via iOS and Android.
I need to be able to do the following:
Create a true accurate sine wave (more on what I understand about accurate and true)
Change the frequency from 20kHz thru to 30kHz
Need to be able to have a resolution of at least 30Hz steps in between the above frequencies.
The amplitude of the sine wave should not vary or have little variation as the frequency is changed.
The frequency should not vary over time and remain as fixed as possible.
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:
What arduino is best if any to achieve the above.
What code is out there I can use for generating sine waves
What components and shields will I need if any
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.
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.
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)
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.
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