This is my first post in the forums. I need help with a project that im working on. I have already implemented this method using pure analog hardware (ICs and all) but want to do it using Arduino and I know its possible.
I looked at DDS, as they provide signals up to 10Khz but I cant seem to understand. I do have 2 Arduino UNOs that I can use for this project.
Its about "Generating Unipolar PWM signals" for an amplifier circuit.
I am sure most of you know how this works but just putting it out there for those who dont:
So what I am looking for is basically comparing 2 signals:
Signal 1: a Sinusoidal signal at 60Hz
Signal 2: a Triangular signal at 10Khz
Have a look at the attached picture: You will compare the 2 signals and if the Sine wave signals amplitude is higher than the triangle signal. than the output will go to 1 or high and if its lower than it will become 0 or low.
So basically in my output signals at the digital output pin is the PWM signal(blue coloured) is what i need to make this work.
Ideally I would want to use as less hardware as possible,
If you have any questions, let me know
On a 16 MHz Arduino your choices for 8-bit (Phase Correct or Phase and Frequency Correct ) PWM are 31,250 Hz or 3,906.25 Hz (prescale of 8). Neither is close to 10 kHz. You can adjust the frequency upward by using a value for TOP that is less than 255 but that cuts into your PWM resolution.
The hard part will be finding an integer value for TOP that produces a frequency near 10 kHz that is an integer multiple of 60 Hz. Your choices of TOP to get within 10% of 10 kHz are 91 through 101. None of them produces an exact multiple of 60 but a couple come close. The closest one is 101 -> 9900.990099 Hz -> 60*165.016 -> 165 * 60.0060006 Hz
If you have to have both 10 kHz +/- 10% and exactly 60 Hz you will probably need to use a non-standard system clock crystal. I think a 16.032 MHz crystal might work (if you can find one). Use a TOP of 100 to get 10.020 kHz and divide your sine wave into 167 samples to get exactly 60 Hz.
There is also the limitation of sample frequency at the analog input . Here's an article saying that the analogRead() function. Arduino analog measurements :: Electronic Measurements The author suggests pushing the sample rate to 77Hz by using registers for outputs and catching interrupts. But you have 2 analog inputs.