issue139:great_cow_basic
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 | ||
issue139:great_cow_basic [2018/12/09 09:10] – d52fr | issue139:great_cow_basic [2018/12/15 09:32] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 5: | Ligne 5: | ||
Dans le FCM n° 138, j'ai montré comment acquérir des informations sur la luminosité ambiante avec une photo-résistance (LDR), comment la transmettre à un dispositif éloigné et comment paramétrer un minuteur de watchdog (surveillance temporelle - WDT) pour économiser l' | Dans le FCM n° 138, j'ai montré comment acquérir des informations sur la luminosité ambiante avec une photo-résistance (LDR), comment la transmettre à un dispositif éloigné et comment paramétrer un minuteur de watchdog (surveillance temporelle - WDT) pour économiser l' | ||
- | Dans ce numéro, je vous montrerai comment coder des sous-routines du WDT pour rendre la réfection du code un peu plus facile et pour étendre | + | Dans ce numéro, je vous montrerai comment coder des sous-routines du WDT pour rendre la réfection du code un peu plus facile et pour compléter |
**Expanding the sleep time | **Expanding the sleep time | ||
Ligne 13: | Ligne 13: | ||
Étendre la durée de veille | Étendre la durée de veille | ||
- | Une transmission toutes les 8 secondes correspondrait à une grande quantité d'information. En chiffres : un jour fait environ 86 400 secondes ; si la transmission a lieu toutes les 8 secondes, il y aurait 10 800 transmissions par jour. Ceci serait largement trop : le niveau de la luminosité que nous mesurerons ne devrait pas changer trop souvent | + | Une transmission toutes les 8 secondes correspondrait à une grande quantité d'informations. En chiffres : un jour fait environ 86 400 secondes ; si la transmission a lieu toutes les 8 secondes, il y aurait 10 800 transmissions par jour. Ce serait largement trop : le niveau de la luminosité que nous mesurerons ne devrait pas changer trop souvent, peut-être |
**So it would be great to have the microcontroller sleep longer than this 8 seconds to minimize the data transfers and to save power. Due to the limitations of the WDT, this can be achieved only with a loop condition. For an overview, see this simplified diagram of the following software. At the very beginning of the program, we define a timeout variable; the device will wake up every 8 s, check if the timeout has occurred first. If not, it decreases the timeout by one and immediately goes to sleep again. This should only take a very little amount of power. The reading of the ADC, the measuring of the battery level, etc, will take place only after the timeout. To determine the timeout, just think of the time frame you want your transmitter to send data. One minute has around 8 wakeups of the device (8 x 8 s = 64 sec. roughly 1 minute). To save some program space, I suggest to stay in the range of a byte value (max. 255). Setting the timeout to 225 will give a time frame of 30 minutes. ** | **So it would be great to have the microcontroller sleep longer than this 8 seconds to minimize the data transfers and to save power. Due to the limitations of the WDT, this can be achieved only with a loop condition. For an overview, see this simplified diagram of the following software. At the very beginning of the program, we define a timeout variable; the device will wake up every 8 s, check if the timeout has occurred first. If not, it decreases the timeout by one and immediately goes to sleep again. This should only take a very little amount of power. The reading of the ADC, the measuring of the battery level, etc, will take place only after the timeout. To determine the timeout, just think of the time frame you want your transmitter to send data. One minute has around 8 wakeups of the device (8 x 8 s = 64 sec. roughly 1 minute). To save some program space, I suggest to stay in the range of a byte value (max. 255). Setting the timeout to 225 will give a time frame of 30 minutes. ** | ||
- | Aussi, il serait bien que le microcontrôleur reste en veille plus longtemps que 8 secondes pour réduire les transferts de données et économiser l' | + | Aussi, il serait bien que le microcontrôleur reste en veille plus longtemps que 8 secondes pour réduire les transferts de données et économiser l' |
Ligne 30: | Ligne 30: | ||
Mesure du niveau de la batterie | Mesure du niveau de la batterie | ||
- | Le ATtiny13a peut mesurer sa propre tension de batterie via l'ADC et diviseur de tension. Malheureusement, | + | Le ATtiny13a peut mesurer sa propre tension de batterie via l'ADC et un diviseur de tension. Malheureusement, |
**Data logging and evaluation | **Data logging and evaluation | ||
To know when a certain light level occurs, the data has to include the actual time and date for further examination. To save some space on the hard disk, we read the data from the serial line and strip the unnecessary or false information. Maybe you have the FreeBasic-Installation from Issue 127 still intact, so you can compile the following yourself. Otherwise take this as an idea to be implemented in the programming language of your choice. ** | To know when a certain light level occurs, the data has to include the actual time and date for further examination. To save some space on the hard disk, we read the data from the serial line and strip the unnecessary or false information. Maybe you have the FreeBasic-Installation from Issue 127 still intact, so you can compile the following yourself. Otherwise take this as an idea to be implemented in the programming language of your choice. ** | ||
+ | |||
+ | Enregistrement des données et évaluation | ||
+ | |||
+ | Pour savoir quand arrive un certain niveau de luminosité, | ||
**Sample results in the serialdata.raw file; shows timestamp, LDR value (brightness), | **Sample results in the serialdata.raw file; shows timestamp, LDR value (brightness), | ||
Ligne 46: | Ligne 50: | ||
13.11.2018, 22: | 13.11.2018, 22: | ||
13.11.2018, 22: | 13.11.2018, 22: | ||
+ | |||
+ | Des échantillons de résultats sont dans le fichier serialdata.raw ; il montre les horodatages, | ||
+ | |||
+ | (Le Vcc, ou plutôt l'ADC, était flottant ici, le circuit n' | ||
+ | |||
+ | 13.11.2018, 22: | ||
+ | 13.11.2018, 22: | ||
+ | 13.11.2018, 22: | ||
+ | 13.11.2018, 22: | ||
+ | 13.11.2018, 22: | ||
+ | 13.11.2018, 22: | ||
**Breadboard circuitry | **Breadboard circuitry | ||
Ligne 52: | Ligne 67: | ||
The transmitter program has 928 Bytes and so the program memory of the ATtiny13a is almost full, but it is a good starting point for your own experiments - maybe you change the LDR and measure temperatures with a negative temperature coefficient thermistor or short: NTC. Or if the code can be sized down, you could try a temperature and humidity sensor, such as a DHT11 or DHT22. As the time got short on this article I haven’t gathered a full day of data - but I will publish it in the github-repo, | The transmitter program has 928 Bytes and so the program memory of the ATtiny13a is almost full, but it is a good starting point for your own experiments - maybe you change the LDR and measure temperatures with a negative temperature coefficient thermistor or short: NTC. Or if the code can be sized down, you could try a temperature and humidity sensor, such as a DHT11 or DHT22. As the time got short on this article I haven’t gathered a full day of data - but I will publish it in the github-repo, | ||
+ | |||
+ | Circuit d' | ||
+ | |||
+ | (Voir en bas de la page précédente.) | ||
+ | |||
+ | Conclusion | ||
+ | |||
+ | Le programme d' | ||
**Sources | **Sources | ||
If you want to download the source instead of copy-pasting it, you can now check it out with git or an SVN client. See goo.gl/ | If you want to download the source instead of copy-pasting it, you can now check it out with git or an SVN client. See goo.gl/ | ||
+ | |||
+ | Sources | ||
+ | |||
+ | Si vous préférez télécharger les sources plutôt que les copier/ | ||
+ | |||
Ligne 61: | Ligne 89: | ||
Microchip AVR AN2447: Measure VCC/Battery http:// | Microchip AVR AN2447: Measure VCC/Battery http:// | ||
+ | |||
+ | Références | ||
+ | |||
+ | Micro-composant AVR AN2447 : Mesure du Vcc ou de la batterie http:// | ||
**Acknowledgement | **Acknowledgement | ||
I wish to thank Evan Venn (Anobium) from the Great Cow BASIC Team for his insights and valuable hints. And my appreciation to Michael Kennedy from the Full Circle Magazine Editorial Team who proofread and tweaked the FreeBASIC code.** | I wish to thank Evan Venn (Anobium) from the Great Cow BASIC Team for his insights and valuable hints. And my appreciation to Michael Kennedy from the Full Circle Magazine Editorial Team who proofread and tweaked the FreeBASIC code.** | ||
+ | |||
+ | Remerciements | ||
+ | |||
+ | Je souhaite remercier Evan Venn (Anobium) de l' | ||
issue139/great_cow_basic.1544343031.txt.gz · Dernière modification : 2018/12/09 09:10 de d52fr