From aabb33958e1c24b5f755d2a72965f1d5cec33172 Mon Sep 17 00:00:00 2001 From: Jonathan BAUDIN Date: Sat, 9 Sep 2023 14:02:14 +0200 Subject: [PATCH] Add readme --- readme.md | 24 ++++++++++++++++++++++++ readme_fr.md | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 readme.md create mode 100644 readme_fr.md diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..912b781 --- /dev/null +++ b/readme.md @@ -0,0 +1,24 @@ +# DHT PIO Rust Library + +_[french version](readme_fr.md)_ + +## Why? +The DHT (22 or 11) uses a 1-Wire protocol, which is not compatible with the [Dallas Semicondutors](https://en.wikipedia.org/wiki/1-Wire) protocol of the same name. The [Raspberry Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) (like other microcontrollers) has no dedicated peripherals for this protocol. + +Numerous crates exist for using DHT via a digital pin, but after testing several of them, they don't work reliably. The main problem is the implementation of the [embedded_hal](https://crates.io/crates/embedded-hal) by [rp2040_hal](https://crates.io/crates/rp2040-hal). Manipulating the state and direction of a pin takes too long (I measured between 2µs and 6µs depending on the action requested). This is due, among other things, to the impossibility of placing a pin in open drain, which requires "simulating" this feature + +## The PIO ❤️ +The RP2040 chip (used for the Pico) has a rather atypical peripheral called PIO (Programmable Input/Output), [Chapter 3 of the DataSheet](https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf). In simple terms, the idea is to be able to run a small program (max. 32 instructions), which executes independently. It can manipulate GPIOs and share information with the main program. + +The PIO is programmed using an assembler called `pioasm`, with just a few very basic instructions. What's interesting is that each instruction takes (usually) 1 cycle to execute. What's more, it's possible to divide the clock at which the program executes. In our case, we divide the main clock of 125 MHz by 125, giving us one instruction per microsecond. + +## Example +todo!()` + +## Support +### Board +For the moment, the crates have only been tested on a Raspberry Pico. + +### DHT +✅ DHT22 +❌ DHT11 \ No newline at end of file diff --git a/readme_fr.md b/readme_fr.md new file mode 100644 index 0000000..0471ed7 --- /dev/null +++ b/readme_fr.md @@ -0,0 +1,24 @@ +# DHT PIO Rust Library + +_[english version](readme.md)_ + +## Pourquoi ? +Les DHT (22 ou 11) utilisent un protocole 1-Wire, qui n'est pas compatible avec le protocole du même nom de [Dallas Semicondutors](https://en.wikipedia.org/wiki/1-Wire). Le [Raspberry Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) (comme d'autres microcontrôleurs) ne possède pas de périphérique dédié à ce protocole. + +De nombreuses crates existes pour utiliser le DHT via un pin digital, mais après en avoir testée plusieurs, leur fonctionnement n'est pas fiable. Le problème vient de l'implémentation de la [embedded_hal](https://crates.io/crates/embedded-hal) par [rp2040_hal](https://crates.io/crates/rp2040-hal). La manipulation de l'état et de la direction d'une pin, prend trop de temps (j'ai pu mesure entre 2µs et 6µs suivant l'action demandée). Venant, entre autre, de l'impossibilité de mettre une pin en drain ouvert ("open drain"), ce qui nécessite de "simuler" ce comportant. + +## Le PIO ❤️ +Le chip RP2040 (utilisé pour le Pico), possède un périphérique un peu atypique nommée PIO (Programmable Input/Output), [Chapitre 3 de la DataSheet](https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf). En simplifiant, le principe est de pouvoir faire tourner un petit programme (32 instruction max), qui s'éxécutera de manière indépendante. Il peut manipuler les GPIO et partager des informations avec le programme principal. + +Le PIO se programme à l'aide d'un assembleur nommé `pioasm`, il ne comporte que quelques instructions très basiques. Le plus intéressant est que chaque instruction prends (en général), 1 cycle pour s'exécute. De plus il est possible de diviser la clock à laquelle le programme s'éxécute. Dans le notre cas, on disive la clock principale, de 125 MHz, par 125, ce qui nous donne une instruction par microsecondes. + +## Exemple +`todo!()` + +## Support +### Board +Pour le moment le crates n'a été testé que sur un Raspberry Pico. + +### DHT +✅ DHT22 +❌ DHT11 \ No newline at end of file