encodeur_rotatif_a_effet_hall_pandauto_p3022_avec_puce_as5048a
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
encodeur_rotatif_a_effet_hall_pandauto_p3022_avec_puce_as5048a [2022/09/06 08:37] – [Branchement sur ESP32 et Com en SPI avec Raspi] serge | encodeur_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** | ||
</ | </ | ||
+ | {{ : | ||
=====AS5048A de AWS===== | =====AS5048A de AWS===== | ||
* **[[https:// | * **[[https:// | ||
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 | ||
import pigpio | import pigpio | ||
CE = 8 | CE = 8 | ||
+ | |||
pi = pigpio.pi() | pi = pigpio.pi() | ||
sensor = pi.spi_open(0, | sensor = pi.spi_open(0, | ||
- | dt = 0.0001 | + | |
+ | dt = 0.00001 | ||
pi.write(CE, | pi.write(CE, | ||
sleep(dt) | sleep(dt) | ||
+ | t0 = time() | ||
n = -1 | n = -1 | ||
nbr = 1000 | nbr = 1000 | ||
Ligne 77: | Ligne 96: | ||
pi.write(CE, | pi.write(CE, | ||
sleep(dt) | sleep(dt) | ||
- | # Envoi de 0b1111111111111111 | + | |
c, d = pi.spi_xfer(sensor, | c, d = pi.spi_xfer(sensor, | ||
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) | ||
- | | + | |
- | print(angle) | + | # #if n % 20 == 0: |
+ | | ||
pi.write(CE, | pi.write(CE, | ||
- | # Pour simuler la fréquence d' | + | |
- | sleep(0.03) | + | sleep(tempo) |
pi.stop() | pi.stop() | ||
+ | |||
+ | periode = (((time() - t0) / nbr) - tempo)*1000 | ||
+ | print(" | ||
+ | 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 | ||
+ | |||
+ | """ | ||
+ | |||
</ | </ | ||
**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===== | ||
{{tag> | {{tag> |
encodeur_rotatif_a_effet_hall_pandauto_p3022_avec_puce_as5048a.1662453479.txt.gz · Dernière modification : 2022/09/06 08:37 de serge