# How can I graph a simulation of a FM 16 bits codification?

I have to develop a software where the user inputs a 16 bits binary sequence, which is supposed to be the codification of a FM (or even AM) signal, then I should graph it according to Frequence / Time ....

What procedure I should take to treat such input?

-

## migrated from physics.stackexchange.comFeb 5 at 5:52

This question came from our site for active researchers, academics and students of physics.

It's hard to tell what you're asking here, but it sounds like you have a discrete-time frequency-modulated signal with 16 bits per sample. In order to convert this to a frequency-versus-time signal, you want to demodulate the FM. One way to do this is with an FM discriminator. A digital implementation could look like this (assuming a complex input signal $x[n]$ sampled at a rate of $f_s$ Hz):
$$x_{d}[n] = x[n]x^*[n-1]$$
$$f[n] = \text{atan2}\left(\text{Im}[x_d[n]], \text{Re}[x_d[n]]\right) \frac{f_s}{2\pi}$$
This simple implementation estimates the frequency of the signal $x[n]$ using a first-order phase difference. The phase of the product $x_d[n]$ is equal to the phase difference between successive samples $x[n]$ and $x[n-1]$. This phase difference can be used as an approximation of the frequency of the signal at time $n$. To extract the phase of $x_d[n]$, we use the atan2 function, then scale it appropriately so that $f[n]$ is measured in Hz. $f[n]$ is then the estimated frequency modulation input.
Note: As I said before, this technique assumes a complex input signal. If what you have is real-valued, you'll want to convert $x[n]$ to analytic signal format first.