4
$\begingroup$

I want to convert the two's complement, 16-bit output from an ADC into a generic fixed-point format, $\rm Qm.n$, where $\rm m$ is the number of integer bits and $\rm n$ is the number of fraction bits.

Any hints/procedure to do this job would be appreciated.

$\endgroup$
14
$\begingroup$

You don't have anything to do, because $\rm Qm.n$ is just an "interpretation" of an integer. The only thing that really matters is that you need to correctly apply a shift operation when multiplying numbers; or when adding/subtracting numbers with different values of $\rm (m, n)$ - You can think of the $\rm Qm.n$ representation as a "tag" you attach to number, a bit like physical units.

In your case, the output of your ADC is an integer between $-32768$ and $32767$. This number can be interpreted as a $\rm Q15$ fixed-point number between $-1.0$ and $0.99997$. Or as a $\rm Q2.14$ fixed-point number between $-4.0$ and $3.99987$. Or as a $\rm Q8.8$ number between $-256.0$ and $255.992$. You don't have to do any arithmetic operation.

$\endgroup$

protected by jojek Jul 10 '17 at 10:22

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.