Outils pour utilisateurs

Outils du site


encodeur_rotatif_a_effet_hall_pandauto_p3022_avec_puce_as5048a

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
encodeur_rotatif_a_effet_hall_pandauto_p3022_avec_puce_as5048a [2022/09/06 07:43] – [Capteur sur la Pi en SPI] sergeencodeur_rotatif_a_effet_hall_pandauto_p3022_avec_puce_as5048a [2022/09/07 09:33] (Version actuelle) – [Encodeur rotatif à Effet Hall Pandauto P3022 avec puce AS5048A] serge
Ligne 4: Ligne 4:
 **Avec Communication en SPI** **Avec Communication en SPI**
 </WRAP> </WRAP>
 +{{ :media_16:2_codeurs_ok.png?600 |}}
 =====AS5048A de AWS===== =====AS5048A de AWS=====
   * **[[https://ams.com/as5048a|AS5048A High-Resolution Position Sensor 14-bit rotary position sensor with digital angle (interface) and PWM output]]** Sortie SPI et PWM.   * **[[https://ams.com/as5048a|AS5048A High-Resolution Position Sensor 14-bit rotary position sensor with digital angle (interface) and PWM output]]** Sortie SPI et PWM.
Ligne 60: Ligne 60:
  
 <code python> <code python>
-from time import sleep+ 
 +""" 
 +De Arduino en debug: 
 + 
 +Read (0x3FFF) with command: 0b1111111111111111 avec un transfert16 
 +Read returned: 1101110100001010 
 +Setting error bit 
 +3433 
 +Read (0x3FFF) with command: 0b1111111111111111 
 +Read returned: 101110100000111 
 +Setting error bit 
 +3432 
 + 
 +""" 
 + 
 +from time import time, sleep
 import pigpio import pigpio
  
 CE = 8 CE = 8
 +
 pi = pigpio.pi() pi = pigpio.pi()
 sensor = pi.spi_open(0, 1000000, 1) sensor = pi.spi_open(0, 1000000, 1)
-dt = 0.0001+ 
 +dt = 0.00001 
 pi.write(CE, 1) pi.write(CE, 1)
 sleep(dt) sleep(dt)
  
 +t0 = time()
 n = -1 n = -1
 nbr = 1000 nbr = 1000
Ligne 77: Ligne 96:
     pi.write(CE, 0)     pi.write(CE, 0)
     sleep(dt)     sleep(dt)
-    # Envoi de 0b1111111111111111+
     c, d = pi.spi_xfer(sensor, int.to_bytes(65535, 2, 'big'))     c, d = pi.spi_xfer(sensor, int.to_bytes(65535, 2, 'big'))
     if c == 2:     if c == 2:
         val = (d[0] & 0b00111111) << 8 | d[1]         val = (d[0] & 0b00111111) << 8 | d[1]
         angle = int(val/4)         angle = int(val/4)
-    if n % == 0: + 
-        print(angle)+    # #if n % 20 == 0: 
 +        # #print(angle) 
     pi.write(CE, 1)     pi.write(CE, 1)
-    # Pour simuler la fréquence d'appel par furuta + 
-    sleep(0.03)+    sleep(tempo)
  
 pi.stop() pi.stop()
 +
 +periode = (((time() - t0) / nbr) - tempo)*1000  # ms
 +print("periode =", round(periode, 2), "ms")
 +sleep(1)
 +
 +"""
 +periode = 1.9 ms
 +il y a quelques incohérences dans les valeurs
 +
 +sans print
 +periode = 1.3 ms
 +periode = 1.19 ms
 +
 +"""
 +
 </code> </code>
  
-Sans print, le temps de récupération de la valeur est de 1.3 ms à 1 MHz et 1.2 ms à 3 MHz. +**Sans print, le temps de récupération de la valeur est de 1.3 ms à 1 MHz et 1.2 ms à 3 MHz.**
-=====Recherche sur ESP32===== +
-====Branchement sur ESP32 et Com en SPI avec Raspi==== +
-{{:media_16:branchements_esp32.png?500|}}{{:media_16:com_spi_esp32_pi.png?400|}}+
  
-===Ressources=== 
-  * **[[https://www.best-microcontroller-projects.com/rotary-encoder.html|best-microcontroller-projects.com]]** Rotary Encoder: Immediately Tame your Noisy Encoder! Find out how to Instantly Stop Switch Bounce using one of 2 software methods. Easily get Reliable Operation from your Encoder. 
-  * Voir la page dédiée: **[[rotary_encoder_controller]]** 
  
 {{tag>arduino raspberry_pi sb spi}} {{tag>arduino raspberry_pi sb spi}}
encodeur_rotatif_a_effet_hall_pandauto_p3022_avec_puce_as5048a.1662450206.txt.gz · Dernière modification : 2022/09/06 07:43 de serge