Tags:
view all tags
---+ Le convertisseur Numérique Analogique ---++ Introduction Dans le manuel !MicroPython le convertisseur numérique analogique (Digital to Analogue Converter: DAC) n'est pas décrit. Pourtant, l'ESP32 possède 2 DAC d'une résolution de 8 bits et il existe un pilote dans Micropython permettant de contrôler ces interfaces. Les DAC sont accessibles sur les pins GPIO 25 et 26. Voilà un petit programme qui montre comment accéder à ce pilote : <literal>from machine import Pin,DAC<br />from time import sleep_ms<br /><br />dac = DAC(Pin(26))<br />print("Running a triangular wave form with a frequency of ~ 1 Hz on pin 26")<br />while True:<br /> for i in range(256):<br /><span class='WYSIWYG_HIDDENWHITESPACE' style='{encoded: 's7'};'> </span>dac.write(i)<br /><span class='WYSIWYG_HIDDENWHITESPACE' style='{encoded: 's7'};'> </span>sleep_ms(2)<br /><span class='WYSIWYG_HIDDENWHITESPACE' style='{encoded: 's3'};'> </span>for i in range(256):<br /><span class='WYSIWYG_HIDDENWHITESPACE' style='{encoded: 's7'};'> </span>dac.write(256-i-1)<br /> sleep_ms(2)</literal> Le programme génère une onde triangulaire lente, qui peut être observé avec un multimètre. ---++ Exercice 1 : Modifier le programme en dessus pour générer une onde rectangulaire de la même fréquence. ---++ Exercice 2 : Créer un générateur d'impulsion qui permet de produit un signal : * rectangulaire * triangulaire * dent de scie * sinusoïdal Observer ces signaux à l'aide d'un oscilloscope. ---++ Exercice 3 : Connecter la sortie du DAC sur l'entrée d'un canal du convertisseur analogique numérique (Analogue to Digital Converter). Lire l'ADC pour chaque valeur du DAC et tracer le résultat. L'ADC possède une résolution de 12 bits. Quelle courbe est-ce que vous attendez ? Qu'est-ce que vous mesurez ? -- %USERSIG{UliRaich - 2021-11-16}% ---++ Comments %COMMENT%
Edit
|
Attach
|
Watch
|
P
rint version
|
H
istory
:
r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r2 - 2021-11-27
-
UliRaich
Home
Site map
AFNOG web
Embedded_Systems web
IoT_Course_English web
IoT_Course_French web
Main web
Sandbox web
TWiki web
IoT_Course_French Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
Edit
Attach
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback