Fonction Traiter – Conversions numériques
1) Objet du chapitre
La conversion numérique couvre la représentation des nombres (binaire/hex, signé non-signé), la conversion A/N (ADC), la conversion N/A (DAC/PWM), la quantification, l’échantillonnage et les grandeurs de performance (LSB, SNR, ENOB, bande).
- LSB : \(\mathrm{LSB}=\dfrac{V_{\text{FS}}}{2^n}\).
- Erreur de quantification (pas de dithering) : bruit blanc approx. \(q=\mathrm{LSB}/\sqrt{12}\).
- SNR quantif. (sinus pleine échelle) : \( \mathrm{SNR_{q}} \approx 6.02\,n + 1.76\ \mathrm{dB} \).
- ENOB : \( n_\mathrm{eff} = \dfrac{\mathrm{SNR_{mes}} - 1.76}{6.02}\).
- Nyquist : \(f_s \ge 2 f_{\max}\) (filtre anti-repliement avant ADC).
2) Représentation numérique (bases & signes)
| Thème | Formule / Règle | Remarque |
|---|---|---|
| Décimal → Binaire | Division par 2, lire les restes à l’envers | Groupes de 4 bits → Hex |
| Complément à deux (n bits) | Si négatif: inverser bits +1 | Plage: \([-2^{n-1}, 2^{n-1}-1]\) |
| Q-format | Qm.n → valeur = entier / \(2^n\) | Ex: Q1.15 pour angles/coeffs |
| Saturation | Limiter au min/max du format | Évite l’enroulement (overflow) |
3) Simulateur A — Conversions binaire/hex/décimal & complément à 2
| Binaire (n bits) | Hex | Valeur décodée | Plage autorisée |
|---|---|---|---|
| — | — | — | — |
4) ADC — Résolution, code & erreur de quantification
- LSB : \(\mathrm{LSB}=\dfrac{V_\mathrm{FS}}{2^n}\).
- Code idéal (unipolaire) : \( \mathrm{code}=\left\lfloor \dfrac{V_\mathrm{in}}{V_\mathrm{FS}} \cdot (2^n-1) \right\rfloor\).
- Code (bipolaire ±Vref) : \( \mathrm{code}=\operatorname{round}\!\left( \dfrac{V_\mathrm{in}}{2V_\mathrm{ref}} \cdot 2^n \right) + 2^{n-1}\).
| LSB (mV) | Code (décimal) | Code (hex) | Erreur quantif. (mV) | SNR quantif. (dB) |
|---|---|---|---|---|
| — | — | — | — | — |
5) DAC — Sortie analogique & PWM+RC
- DAC idéal (unipolaire) : \( V_o = \dfrac{\text{code}}{2^n-1}\,V_\mathrm{FS}\).
- PWM (rapport \(D\)) filtré RC : \( \overline{V} \approx D\,V_\mathrm{DD}\). Atténuation ondulation \(\approx \dfrac{1}{\sqrt{1+(2\pi f_\mathrm{PWM}RC)^2}}\).
| DAC \(V_o\) (V) | PWM \(\overline{V}\) (V) | fc=1/(2πRC) (Hz) | Ondulation rel. (≈) |
|---|---|---|---|
| — | — | — | — |
6) Échantillonnage, aliasing & filtres
- Nyquist : \(f_s \ge 2 f_{\max}\). Sinon, aliasing : \(f_\text{alias}=|f - k f_s|\) (choix de \(k\) pour minimiser).
- Filtre anti-repliement : \(f_c \lt f_s/2\).
| Nyquist \(f_s/2\) | \(f_\text{alias}\) (Hz) | Proposition \(f_c\) (Hz) | Avis |
|---|---|---|---|
| — | — | — | — |
7) SNR mesuré, ENOB & suréchantillonnage
- SNR mesuré → ENOB : \( n_\mathrm{eff} = \dfrac{\mathrm{SNR}-1.76}{6.02} \).
- Suréchantillonnage (bruit blanc) : gain de résolution \( \Delta n \approx \tfrac{1}{2}\log_2(\mathrm{OSR}) \).
| ENOB (bits) | Gain théorique (bits) | n total estimé |
|---|---|---|
| — | — | — |
8) Exercices (12) + solutions
1 — LSB 10 bits @ 5 V
Calculer la LSB.
\(5/1024=4.883\) mV.
2 — Code ADC
n=12, VFS=3.3 V, \(V_{in}=2.0\) V (unipolaire). Code ?
\(\lfloor(2/3.3)·4095\rfloor=2481\) (0x9B1).
3 — DAC
n=8, VFS=2.5 V, code=128 ⇒ \(V_o\) ?
\(128/255·2.5≈1.255\) V.
4 — Complément à 2
Représenter −37 sur 8 bits.
37=0b0010 0101 → inverser 1101 1010 +1 → 1101 1011 (0xDB).
5 — Q-format
En Q1.15, quelle valeur pour 0.25 ?
0.25×2^15=8192 ⇒ 0x2000.
6 — Nyquist
Signal 3 kHz, choisir \(f_s\) minimal (terrain)?
≥ 2×3k = 6 kHz ; viser 8–10 kHz + anti-repliement.
7 — Aliasing
f=1.8 kHz, \(f_s=2.0\) kHz ⇒ \(f_{alias}\) ?
\(|1800 - 1·2000|=200\) Hz.
8 — SNR quantif.
SNR quantif. théorique pour n=12 ?
\(6.02·12+1.76≈74.0\) dB.
9 — ENOB
On mesure 60 dB ⇒ ENOB ?
\((60-1.76)/6.02≈9.65\) bits.
10 — PWM+RC
Vdd=5 V, D=0.3, f=20 kHz, RC=1 ms ⇒ \(\overline{V}\) et atténuation ?
\(\overline{V}=1.5\) V ; \(2\pi f RC≈125.7\) ⇒ ondulation très faible.
11 — Saturation
En 8 bits signé, plage ?
−128 … +127.
12 — Suréchantillonnage
OSR=64 ⇒ gain bits ?
\(0.5·\log_2 64 = 0.5·6 = 3\) bits.
9) Récapitulatif
- Formats : non-signé / C2 / Qm.n — attention aux saturations.
- ADC/DAC : LSB, code/valeur, erreurs de quantification.
- Échantillonnage : \(f_s \ge 2f_{\max}\), filtre anti-repliement ; ENOB & SNR guident la qualité.
- PWM+RC : alternative simple au DAC pour tensions lentes.
Fonction Traiter — Conversions numériques — © neobac