Two tone oscillator

Hi,i am trying to find out if a nano can produce two tones at the same time for ssb transmitter testing,i need a tone of 800hz and 1900 hz produced at the same time,has anyone the code to do this?,i am ok with a soldering iron but no good with code,cheers in advance m3vuv 73.

Hello OM m3vuv

Take some time and study how to design timers using Arduino.

The BlinkWithOutDely might help to get started.

If do you need a sine tone a little bit more investigation should place.

73 es 55 es good DX


I got this screenshot from yt,not sure how to make it loadable to my nano,need someone to look at it and redo it so i can copy it and upload it,73.

void setup() {

// put your setup code here, to run once:

pinMode (5, OUTPUT); pinMode (4, OUTPUT);

pinMode (3, INPUT);

digitalWrite(3, HIGH);

}

void loop() {

analogWrite (5, 127);

if(!digitalRead (3)) {

tone (4,1400);

}else noTone (4);

// put your main code here, to run repeatedly:

delay(10);

}

Check out Google lens

In short: use a PWM output to produce one frequency in hardware, and tone() for the other frequency in software.

Both waves are rectangles, not sines.

Yes, the Arduino Nano can generate two tones at the same time using the tone() function. The code you provided is correct and should generate two tones at 800Hz and 1900Hz on pins 10 and 11 respectively.

However, if you want to generate a sine wave instead of a square wave, you can use the toneAC library instead of the tone() function. The toneAC library uses pulse width modulation to generate a sine wave.

You may also consider using an audio shield or an external audio amplifier to improve the sound quality and output level of your tones. In addition, you must ensure that the output levels and impedance of the Arduino's output pins match the input requirements of your SSB transmitter circuit.

You can use an AD9833 module to easily generate a sine wave.

AD9833_module R

Ha, the one I use to generate my own "Greenwich pips" has just gone off.

I've seen a topic that suggests you can connect two to an Arduino (one for each frequency):
https://forum.arduino.cc/t/connect-interface-two-multiple-ad9833-with-arduino-uno/1095087

1 Like

Just curious, did you have help composing this answer? Or did you compose any part of this answer at all?

a7

2 Likes

can i copy and paste that into the ide?,thats what i need,thanks.

Normally, two tone testing is an intermodulation test, you can't use square wave sources directly, they contain too many harmonics. Those will interfere with the noise and IMD measurements, that a are collected from the frequencies other than the two tones.

Unless, you are thinking of some other test.

1 Like

The problem with the built-in tone() function is that it only supports one tone at a time. There is a third-party Tone library that can play different frequencies on different pins.

This library

allows direct computation and output of multiple waveforms.

a7

Pure sine wave tones?
What sort of test?

I don't think you can easily get a pure enough sine wave from an Arduino to do what you want. I just downloaded a $0.99 app to my Mac called Frequency Sound Generator that allows you to play up to three different waveforms at different frequencies through the computer speakers. It has sine, square, and triangle waveforms and covers the frequencies you need. You could use that. Just place your microphone so that it picks up the sound adequately.

Thanks for your advice.

Nice device :+1:

1 Like

I've verified that you can attach 2 of the AD9833 modules to an Arduino, and generate the required frequencies:

Just connect the FSYNC pins to different Digital outputs on the Arduino.


#include <AD9833.h>

#define FSYNC_PIN1 10
#define FSYNC_PIN2 9

AD9833 gen1(FSYNC_PIN1);
AD9833 gen2(FSYNC_PIN2);

void setup() {

  gen1.Begin();
  gen2.Begin();

  gen1.ApplySignal(SINE_WAVE, REG0, 800);
  gen2.ApplySignal(SINE_WAVE, REG0, 1900);

  gen1.EnableOutput(true);
  gen2.EnableOutput(true);
}

void loop() {
}

Hello JohnLincoln

Great work.

Which Arduino is used.

does that sketch only make one tone?,i need one at 800hz and another at 1900hz running simutainuosly.

Yes, that sketch makes only one tone.

As @johnwasser mentioned, tone() can make only one tone at a time.

The reply from @king656 seems like something written ChatGPT, and may not be correct.

There must be hundreds of apps that use a computer's sound card to generate multiple tones. I suggest that the purity of the sine waves that a computer sound card can produce is much better than an Arduino without any add-ons and in many cases will be free or very low cost.