Author Topic: Generate FM using IQ inputs?  (Read 5220 times)

0 Members and 1 Guest are viewing this topic.

Offline biasteeTopic starter

  • Regular Contributor
  • *
  • Posts: 60
  • Country: my
    • 9W2LC
Generate FM using IQ inputs?
« on: June 01, 2023, 05:09:27 am »
My sig-gen (R&S SMIQ06L) doesn't have a built-in FM modulation capability, but it has IQ inputs (red circled in attached image). Is it possible to generate FM by feeding two baseband audio signals, at the same frequency and in quadrature phase (90 deg. difference) to the IQ inputs? I think the quadrature audio waveforms could be generated by one of those low-cost function generator with dual outputs.
Is my assumption correct? Did I overlook something? TIA.
 

Offline Berni

  • Super Contributor
  • ***
  • Posts: 5025
  • Country: si
Re: Generate FM using IQ inputs?
« Reply #1 on: June 01, 2023, 05:24:22 am »
Yep you can make almost any kind of modulation with IQ inputs.

The FM one is one of the more more tricky ones to do since you need to actually make a FM modulated IQ signal. But it looks like that signal generator supports FM modulation with an external control voltage.
 
The following users thanked this post: pdenisowski, biastee

Offline xmo

  • Regular Contributor
  • *
  • Posts: 193
  • Country: us
Re: Generate FM using IQ inputs?
« Reply #2 on: June 01, 2023, 07:55:56 pm »
See the R&S Application note:

 
The following users thanked this post: analogRF, biastee

Online radiolistener

  • Super Contributor
  • ***
  • Posts: 4011
  • Country: ua
Re: Generate FM using IQ inputs?
« Reply #3 on: June 01, 2023, 09:25:32 pm »
you can generate IQ WAV file with required FM modulation signal and play it with sound card into IQ input :)

FM modulation is pretty easy, you can do it in the following way:
Code: [Select]
var iq = new complexd[audio.Length];
            for (int i = 0; i < iq.Length; i++)
            {
                // calculate phase increment based on input audio signal
                var phaseIncrement = audio[i] * scale;

                // update current phase
                phasePrev += phaseIncrement;

                // calculate IQ stream
                var re = Math.Cos(phasePrev);
                var im = Math.Sin(phasePrev);
                iq[i] = new complexd(re, im);
            }

if you don't familiar with programming, I've implemented a little console application which can process signal in WAV file. It allows to perform FM modulation into IQ stream based on audio taken from another WAV file. Also it allows to perform FM demodulation from a WAV file with IQ stream. And in addition it allows to perform frequency shift for a WAV file with IQ stream.

here is example on how to use it:
Code: [Select]
IQDSP.exe fmmod 100000 input.wav output.wav

where 100000 is FM deviation, input.wav is a WAV file with audio signal and output.wav is a file which will contains IQ stream with FM modulated signal at 0 Hz carrier.

if you're don't like 0 Hz carrier (many soundcard cannot play DC signal due to capacitors on the output) you can also use it to perform frequency shift. For example in order to shift 0 Hz carrier to 20000 Hz carrier use the following:
Code: [Select]
IQDSP.exe fqshift 20000 iqfmdc.wav output.wav

It supports uncompressed PCM and IEEE FLOAT WAV formats.
Preffered input format is IEEE FLOAT32 or IEEE FLOAT64. Probably it can eat any format but I didn't tested it deep.
Output WAV file has IEEE FLOAT32 format and the same sample rate as input file.

Note that FM modulated signal requires more wide bandwidth than audio signal.
It is recommended to use input file with sample rate which is about 12 times more wide than audio signal bandwidth.
For example 240 kHz sample rate is recommended for 20 kHz signal bandwidth.
 
The following users thanked this post: biastee

Offline biasteeTopic starter

  • Regular Contributor
  • *
  • Posts: 60
  • Country: my
    • 9W2LC
Re: Generate FM using IQ inputs?
« Reply #4 on: June 04, 2023, 06:00:37 am »
See the R&S Application note:

The R&S Application note requires option B60 (ARB generator) which I don't have.

you can generate IQ WAV file with required FM modulation signal and play it with sound card into IQ input :)

Does the WAV file needs to be playback in a loop? Anyway, this appears to be more complicated than adding a dual-channel function generator, but I will file the idea away for some future use. Thanks.
 

Offline xmo

  • Regular Contributor
  • *
  • Posts: 193
  • Country: us
Re: Generate FM using IQ inputs?
« Reply #5 on: June 04, 2023, 04:59:37 pm »
As an alternative to trying to add B60 to your SMIQ, you could look for a R&S ARB generator such as AMIQ or AMU200.  Then you can use some of the many R&S IQ programs such as WinIQsim and ARB toolbox as a great learning experience.

"The ARB Toolbox PLUS is a powerful and easy-to-use set of tools for creating or manipulating waveforms for R&S vector signal generators and baseband IQ modulation generators."

 

Offline biasteeTopic starter

  • Regular Contributor
  • *
  • Posts: 60
  • Country: my
    • 9W2LC
Re: Generate FM using IQ inputs?
« Reply #6 on: June 05, 2023, 06:37:08 am »
I am living in a Third World country with an unfavourable exchange rate. The B60, AMIQ or AMU200 are way too expensive for me, especially when compared to the China-made function generator.
 

Offline LeLyfa

  • Newbie
  • Posts: 3
  • Country: de
  • HAM (DL7LL) and Electronics Enthusiast.
Re: Generate FM using IQ inputs?
« Reply #7 on: June 09, 2023, 05:31:29 pm »
Hi,
yes, it is possible, I have done it using a homebrew TRS to 2*BNC adapter cable and my laptop. It has the limitation that I can only generate mono fm signals (because my soundcard has too little bandwidth). I use gnuradio to generate IQ wav files (there are plenty of tutorials for that online).
 
The following users thanked this post: ch_scr, biastee

Offline EggertEnjoyer123

  • Frequent Contributor
  • **
  • Posts: 307
  • Country: us
Re: Generate FM using IQ inputs?
« Reply #8 on: July 01, 2023, 07:00:37 am »
It might be possible to do this on an Arduino (with a DAC) or with a STM32 microcontroller (like the STM32G491RE, which has two 10Msps DACs built in).

 

Online radiolistener

  • Super Contributor
  • ***
  • Posts: 4011
  • Country: ua
Re: Generate FM using IQ inputs?
« Reply #9 on: July 01, 2023, 07:24:47 am »
It might be possible to do this on an Arduino (with a DAC) or with a STM32 microcontroller (like the STM32G491RE, which has two 10Msps DACs built in).

yes, a new cheap STM32 MCU allows to do much things in digital domain.

But it seems that FM modulation is not so lightweight for computational resources. What is the best approaches to implement FM modulator in digital domain?
 

Offline gf

  • Super Contributor
  • ***
  • Posts: 1321
  • Country: de
Re: Generate FM using IQ inputs?
« Reply #10 on: July 01, 2023, 09:29:11 am »
But it seems that FM modulation is not so lightweight for computational resources. What is the best approaches to implement FM modulator in digital domain?

What about DDS with time-dependent phase increment? Either use the DDS to directly generate a real-valued FM-modulated IF signal, or to generate a DC-centered complex IQ signal which can then be up-converted to the desired carrier frequency with a quadrature mixer. Depends on the input required by subsequent processing steps. Of course the sample rate must be high enough for the bandwidth of the generated signal. If the sample rate of the modulating signal happens to be lower, then it must be up-sampled first.
 

Offline Berni

  • Super Contributor
  • ***
  • Posts: 5025
  • Country: si
Re: Generate FM using IQ inputs?
« Reply #11 on: July 01, 2023, 10:59:04 am »
Using a DDS oscillator in software is a perfectly valid way to do it in a MCU.

The method only requires fixed point addition and multiply, along with some bitshift sprinkled in, the expensive part is a sine calculation but that can be sped up a lot using a simple lookup table or some more fancy fast approximation methods. So a STM32 like that one should be capable of doing it, tho will likely need some carefully performant written firmware to keep up. At 170MHz it has 17 cycles of time to generate one pair of IQ DAC samples. Would also definitely involve a DMA to keep feeding that DAC smoothly enough.

These modern ARM MCUs are not to be underestimated tho. Most of them have floating point units that can do a single precision multiply accumulate in a single clock cycle. Or even do double precision for twice that time. The faster STMs also run at 480MHz.
 

Offline gf

  • Super Contributor
  • ***
  • Posts: 1321
  • Country: de
Re: Generate FM using IQ inputs?
« Reply #12 on: July 01, 2023, 11:44:06 am »
Either use the DDS to directly generate a real-valued FM-modulated IF signal, or to generate a DC-centered complex IQ signal which can then be up-converted to the desired carrier frequency with a quadrature mixer.

The requirement in the O.P. obviously calls for the latter. Advantage of IQ the signal is also that the required sample rate is only > the occupied bandwidth of the FM channel (and not > 2 fIF + BW).
 

Online radiolistener

  • Super Contributor
  • ***
  • Posts: 4011
  • Country: ua
Re: Generate FM using IQ inputs?
« Reply #13 on: July 01, 2023, 02:27:36 pm »
FM modulation is not so easy to analyze like AM or DSB/SSB, because it has non linear properties.

Discrete-time FM modulator uses constant \$k_\omega\$ called "frequency sensitivity", which is related with modulation index \$\beta\$ in the following way:

\$\beta=\frac{k_\omega*A_m}{\omega_m}=\frac{peak\_frequency\_deviation}{message\_frequency}\$

Some questions is not clear for me. One of them is - how to determine required peak frequency deviation and modulation index from message signal bandwidth? What is the dependency between dynamic range of message signal with deviation and modulation index for FM modulation? Can anybody help to explain it? Thanks

« Last Edit: July 01, 2023, 03:10:01 pm by radiolistener »
 

Offline gf

  • Super Contributor
  • ***
  • Posts: 1321
  • Country: de
Re: Generate FM using IQ inputs?
« Reply #14 on: July 01, 2023, 09:42:51 pm »
A rule of thumb for the approximate bandwidth is Carson's bandwidth rule:
https://en.wikipedia.org/wiki/Carson_bandwidth_rule

Retracted - After reading again I think this is not what you are after.
« Last Edit: July 01, 2023, 10:01:52 pm by gf »
 

Online radiolistener

  • Super Contributor
  • ***
  • Posts: 4011
  • Country: ua
Re: Generate FM using IQ inputs?
« Reply #15 on: July 02, 2023, 04:04:34 am »
Carlson rule shows how to select required channel bandwidth from a known peak frequency deviation \$\Delta f\$.

But I want to know how to select proper \$\Delta f\$ from a known message signal bandwidth, dynamic range, noise or other properties...
 

Offline switchabl

  • Frequent Contributor
  • **
  • Posts: 445
  • Country: de
Re: Generate FM using IQ inputs?
« Reply #16 on: July 02, 2023, 05:22:31 pm »
As a rule of thumb, FM with modulation index \$\beta\$ will give you an SNR that is better than analog baseband transmission by \$ 20 \log \beta + 1.76 \textrm{dB}\$. So you can trade off bandwidth for SNR, however there are limits: you need to maintain an RF SNR at the receiver of about 10dB, below that performance degrades rapidly (threshold effect). De-emphasis would give you an additional improvement.

A proper analysis can be quite complicated because of the non-linearity involved. If you want to study this in more detail, "Communication Systems" by Carlson and Crilly may be a good starting point.
 
The following users thanked this post: radiolistener

Online radiolistener

  • Super Contributor
  • ***
  • Posts: 4011
  • Country: ua
Re: Generate FM using IQ inputs?
« Reply #17 on: July 03, 2023, 05:52:52 pm »
Thanks interesting book. I didn't read it before.
 

Offline engrmasood2002

  • Newbie
  • Posts: 1
  • Country: pk
Re: Generate FM using IQ inputs?
« Reply #18 on: May 06, 2024, 07:23:36 am »
Thanks for providing the code for understanding the I Q generation process. Can you tell what the values of 'Scale'variable should be used ? Also do we need to check if  'phasePrev' values crosses 360 and reset it ?. please tell which variable is responsible for achieving deviation in the code ?


 

Online ch_scr

  • Frequent Contributor
  • **
  • Posts: 868
  • Country: de
Re: Generate FM using IQ inputs?
« Reply #19 on: May 06, 2024, 10:55:00 am »
In general, you want to scale the digital to maximize dynamic range (use all of the n bits your specific DAC provides). If you leave room for adjustment there, ask "why and how much" (making a guess: IQ balance / offset adjustment, maybe allow +-5% full scale?). In the analog, you then need to scale the DAC voltage (e.g. 0-3.3V) to match the input of the generator (e.g. 0-10V).
 

Online radiolistener

  • Super Contributor
  • ***
  • Posts: 4011
  • Country: ua
Re: Generate FM using IQ inputs?
« Reply #20 on: May 08, 2024, 12:06:22 am »
scale depends on audio sample range and frequency deviation.
sin/cos functions already can handle any angle, but if your implementation don't know how to wrap it, you're needs to do it manually.
« Last Edit: May 08, 2024, 02:02:30 am by radiolistener »
 

Online jbb

  • Super Contributor
  • ***
  • Posts: 1231
  • Country: nz
Re: Generate FM using IQ inputs?
« Reply #21 on: May 08, 2024, 01:46:27 am »
On sin and cos functions: these can be a bit expensive in computational terms. Check the documentation for your microcontroller to see if it has a recommended maths library.

As an example: in a previous role I used a Texas Instruments Delfino part, and it had a library which included a sincos() function (or maybe cossin…). This took roughly the same number of cycles as a single cos(); I got the sin() term nearly for free :-)
 

Offline vk6zgo

  • Super Contributor
  • ***
  • Posts: 7699
  • Country: au
Re: Generate FM using IQ inputs?
« Reply #22 on: May 08, 2024, 02:25:01 am »
My sig-gen (R&S SMIQ06L) doesn't have a built-in FM modulation capability, but it has IQ inputs (red circled in attached image). Is it possible to generate FM by feeding two baseband audio signals, at the same frequency and in quadrature phase (90 deg. difference) to the IQ inputs? I think the quadrature audio waveforms could be generated by one of those low-cost function generator with dual outputs.
Is my assumption correct? Did I overlook something? TIA.

That is similar to how Marconi generated FM in their "FMQ" FM exciters back in the 1950s, though it was all done in the analog domain.
The advantage was that the generator was crystal locked, which was a bit messier to obtain using simpler circuits.
 

Online radiolistener

  • Super Contributor
  • ***
  • Posts: 4011
  • Country: ua
Re: Generate FM using IQ inputs?
« Reply #23 on: May 08, 2024, 03:07:21 am »
You can use discrete FM modulator to combine FM modulation and frequency shift together

For example, here is Octave script it use FM modulation with 6 kHz deviation and frequency shift for 10 kHz carrier:
Code: [Select]
pkg load audio;

kf = 6000;   % frequency deviation
fc = 10000;  % carrier frequency (frequency shift)

fs = 384000; % sample rate
sampleCount = fs;   % duration 1 second
yi = sin(2 * pi * 500 * ((0:sampleCount - 1) / fs)); % modulation signal (500 Hz sine)

Ts = 1 / fs;
ka = 2 * pi * kf * Ts;
kb = 2 * pi * fc * Ts;

phase = 0;
I = zeros(1, length(yi));
Q = zeros(1, length(yi));
for i = 1:length(yi)
  phase += yi(i) * ka + kb;
  phase = mod(phase, 2 * pi);
  I(i) = cos(phase);
  Q(i) = sin(phase);
end

audiowrite("test-iq-out.wav", [I(:), Q(:)], fs, "BitsPerSample", 32);

or more fast vectorized version:
Code: [Select]
pkg load audio;

kf = 6000;    % frequency deviation
fc = 10000;   % carrier frequency (frequency shift)

fs = 384000;      % sample rate
sampleCount = fs; % duration 1 second
yi = sin(2 * pi * 500 * ((0:sampleCount - 1) / fs)); % modulation signal (500 Hz sine)

Ts = 1 / fs;
ka = 2 * pi * kf * Ts;
kb = 2 * pi * fc * Ts;

phase = cumsum(yi * ka + kb);
phase = mod(phase, 2 * pi);
I = cos(phase);
Q = sin(phase);

audiowrite("test-iq-out.wav", [I(:), Q(:)], fs, "BitsPerSample", 32);
« Last Edit: May 08, 2024, 11:41:26 pm by radiolistener »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf