Generate FM using IQ inputs? - Page 1
Forum section: electronics / rf-microwave

author: biastee
author_rank: Regular Contributor
timestamp: June 01, 2023, 05:09:27 am
content: 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 thoselow-cost function generator with dual outputs.Is my assumption correct? Did I overlook something? TIA.

author: Berni
author_rank: Super Contributor
timestamp: June 01, 2023, 05:24:22 am
content: 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.

author: xmo
author_rank: Regular Contributor
timestamp: June 01, 2023, 07:55:56 pm
content: See the R&S Application note:

author: radiolistener
author_rank: Super Contributor
timestamp: June 01, 2023, 09:25:32 pm
content: you can generate IQ WAV file with required FM modulation signal and play it with sound card into IQ inputFM modulation is pretty easy, you can do it in the following way:Code:var iq = new complexd[audio.Length];for (int i = 0; i < iq.Length; i++){// calculate phase increment based on input audio signalvar phaseIncrement = audio * scale;// update current phasephasePrev += phaseIncrement;// calculate IQ streamvar re = Math.Cos(phasePrev);var im = Math.Sin(phasePrev);iq = 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:IQDSP.exe fmmod 100000 input.wav output.wavwhere 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:IQDSP.exe fqshift 20000 iqfmdc.wav output.wavIt 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.

author: biastee
author_rank: Regular Contributor
timestamp: June 04, 2023, 06:00:37 am
content: Quote from: xmo on June 01, 2023, 07:55:56 pmThe R&S Application note requires option B60 (ARB generator) which I don't have.Quote from: radiolistener on June 01, 2023, 09:25:32 pmDoes 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.

author: xmo
author_rank: Regular Contributor
timestamp: June 04, 2023, 04:59:37 pm
content: 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."

author: biastee
author_rank: Regular Contributor
timestamp: June 05, 2023, 06:37:08 am
content: 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.

author: LeLyfa
author_rank: Newbie
timestamp: June 09, 2023, 05:31:29 pm
content: 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).

author: EggertEnjoyer123
author_rank: Frequent Contributor
timestamp: July 01, 2023, 07:00:37 am
content: 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).

author: radiolistener
author_rank: Super Contributor
timestamp: July 01, 2023, 07:24:47 am
content: Quote from: EggertEnjoyer123 on July 01, 2023, 07:00:37 amyes, 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?

author: gf
author_rank: Super Contributor
timestamp: July 01, 2023, 09:29:11 am
content: Quote from: radiolistener on July 01, 2023, 07:24:47 amWhat 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.

author: Berni
author_rank: Super Contributor
timestamp: July 01, 2023, 10:59:04 am
content: 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.

author: gf
author_rank: Super Contributor
timestamp: July 01, 2023, 11:44:06 am
content: Quote from: gf on July 01, 2023, 09:29:11 amThe 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).

author: radiolistener
author_rank: Super Contributor
timestamp: July 01, 2023, 02:27:36 pm
content: 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

author: gf
author_rank: Super Contributor
timestamp: July 01, 2023, 09:42:51 pm
content: A rule of thumb for the approximate bandwidth is Carson's bandwidth rule:https://en.wikipedia.org/wiki/Carson_bandwidth_ruleRetracted - After reading again I think this is not what you are after.

author: radiolistener
author_rank: Super Contributor
timestamp: July 02, 2023, 04:04:34 am
content: 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...

author: switchabl
author_rank: Frequent Contributor
timestamp: July 02, 2023, 05:22:31 pm
content: 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.

author: radiolistener
author_rank: Super Contributor
timestamp: July 03, 2023, 05:52:52 pm
content: Thanks interesting book. I didn't read it before.

author: engrmasood2002
author_rank: Newbie
timestamp: May 06, 2024, 07:23:36 am
content: 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 ?

author: ch_scr
author_rank: Frequent Contributor
timestamp: May 06, 2024, 10:55:00 am
content: 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).

author: radiolistener
author_rank: Super Contributor
timestamp: May 08, 2024, 12:06:22 am
content: 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.

author: jbb
author_rank: Super Contributor
timestamp: May 08, 2024, 01:46:27 am
content: 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 :-)

author: vk6zgo
author_rank: Super Contributor
timestamp: May 08, 2024, 02:25:01 am
content: Quote from: biastee on June 01, 2023, 05:09:27 amThat 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.

author: radiolistener
author_rank: Super Contributor
timestamp: May 08, 2024, 03:07:21 am
content: You can use discrete FM modulator to combine FM modulation and frequency shift togetherFor example, here is Octave script it use FM modulation with 6 kHz deviation and frequency shift for 10 kHz carrier:Code:pkg load audio;kf = 6000; % frequency deviationfc = 10000; % carrier frequency (frequency shift)fs = 384000; % sample ratesampleCount = fs; % duration 1 secondyi = 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);endaudiowrite("test-iq-out.wav", [I(:), Q(:)], fs, "BitsPerSample", 32);or more fast vectorized version:Code:pkg load audio;kf = 6000; % frequency deviationfc = 10000; % carrier frequency (frequency shift)fs = 384000; % sample ratesampleCount = fs; % duration 1 secondyi = 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);