Archives par mot-clé : energia

Code source ultra-simpliste pour Arduino/MSP430 d’un VFO à AD9850/AD9851

Prototype kit Balise WSPR DDS XV4Y (http://xv4y NULL.radioclub NULL.asia/wp-content/uploads/2012/12/100_3339 NULL.jpg)Dans un commentaire Sylvain F6GGX m’a demandé après ce bout de code. Il était disponible gratuitement dans la boutique mais comme j’ai désactivé cette dernière il a disparu du site…
Voici donc le code source d’un VFO très simpliste à base de AD9850/AD9851 qui utilise les librairies que j’ai écrites ou adaptées (http://xv4y NULL.radioclub NULL.asia/docs/). Honnêtement je pense pas que ce code soit très utile, rien de particulièrement compliqué et l’ergonomie à 4 boutons n’est pas super. C’est utile en dépannage avec le kit balise WSPR que je produisais mais c’est tout. Le code est écrit pour Energia sur MSP430, le porter sur Arduino (ATMega328) ne devrait poser aucun problème.

/* Simple VFO with DDS for MSP430G2553
 * Code for Energia 009
 
 * By Yannick DEVOS - XV4Y - March 2013
    http://xv4y.radioclub.asia/

    Copyright 2012-2013 Yannick DEVOS under GPL 3.0 license
    Any commercial use or inclusion in a kit is subject to author approval

====
 * Agile Frequency generation using AD9850/9851 DDS
 * Output to Nokia 5110 compatible LCD
 * Check if P2_2 has changed state and switch VFO (like when PTT is pressed to operate split)

Usage for short press of buttons :
- Up / Down      increase or decrease the frequency following the choosen digit
- Left / Right   increase or decrease the digit
- OK             validate the frequency and send it to the DDS
Long press of buttons :
- Left           Set the current VFO to the next band bottom frequency
- Right          VFO A = VFO B
- OK             Switch between VFO A and VFO B

====
Revision history :
v1.00    2013-03-18
         First release

====
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You can download a copy of the GNU General Public License at <http://www.gnu.org/licenses/>
*/

// Here modify to your taste or needs

#define PTT_key          P2_2
#define ANALOG_BUTTONS   A5
#define AUTO_VALID       // Uncomment if you want the DDS frequency to be udapted automatically after each value change

#define DEFAULT_FREQ    8            // Value 8 in Frequencies array is 14000000
// Here under don't touch anything unless you know what you do

#include <legacymsp430.h>
#include <AD9850.h> // Library for AD9850 control by MSP430

#include <LCD_5110.h>

              // Frequencies (1 Hz precision) you can select
const unsigned long int frequencies[] = {
  137000, 471000, 501000, 1830000, 3500000, 5200000, 7000000, 10100000,
  14000000, 18068000, 21000000, 24890000, 28000000, 50000000, 70000000};
  
const byte Analog_Noise = 5;    // Margins for reading analog buttons

boolean   vfo=0, saved_PTT;  // VFO A or B and PTT input state
char      multiplier, aff_multiplier, freq_select=DEFAULT_FREQ;
unsigned  long int frequency_A=frequencies[DEFAULT_FREQ], frequency_B=frequencies[DEFAULT_FREQ], debounce;

char chaine_txt[6] = {' ', ' ', ' ', ' ', ' ', 0x00};


AD9850 myDDS (P1_0, P1_1, P1_2, P1_4);  // Call the AD9850 Library, AD9850 pins for CLOCK, LOAD, DATA and RESET
//AD9850 myDDS (P1_1, P1_2, P1_0, P1_4);  // Call the AD9850 Library, AD9851 pins for CLOCK, LOAD, DATA and RESET

LCD_5110 myScreen(P2_3,    // Chip Select *
         P1_6,    // Serial Clock *
         P2_5,    // Serial Data *
         P2_4,    // Data/Command *
         NULL,    // Reset *
         P1_7,    // Backlight
         NULL);  // Push Button 0

//******************************************************************
// Defining pins mode and initializing hardware

void setup() {
  pinMode(PTT_key, INPUT_PULLUP);

  myDDS.begin();
  
   
  pinMode(ANALOG_BUTTONS, INPUT);

  myScreen.begin();
  myScreen.setBacklight(1);
    
  myScreen.setFont(1);
  myScreen.text(0, 0, "sVFO");
  myScreen.text(0, 2, "AD9850");
  myScreen.setFont(0);
  myScreen.text(0, 4, "v1.00 - XV4Y");
  myScreen.text(0, 5, "Init...");
  
  delay(1000);
  
  myDDS.reset();
  
  myDDS.SetFrequency( frequency_A, 0, false );

  digitalWrite( PTT_key, LOW );

};

//******************************************************************
// Here starts the actual sequence sending

void loop() {
    myScreen.clear();
    myScreen.setBacklight(1);
    myScreen.setFont(1);
    if (vfo == 0) {
      myScreen.text(0, 0, "VFO A");
      myDDS.SetFrequency( frequency_A, 0, false );
    } else {
      myScreen.text(0, 0, "VFO B");
      myDDS.SetFrequency( frequency_B, 0, false );
    };

    myScreen.setFont(0);
    display_freq (frequency_A, 3);
    display_freq (frequency_B, 5);

    while (read_buttons()==5 || read_buttons()==4 || read_buttons()==2) delay(10); // Debounce except for UP/DWN

    while (1) {
      // Update the frequencies display
      if (multiplier > 5) {
        aff_multiplier = multiplier + 2;
      } else if (multiplier > 2) {
        aff_multiplier = multiplier + 1;
      } else {
        aff_multiplier = multiplier;
      };
      myScreen.text(0, 4, "          ");
      if (vfo == 0) {
        myScreen.text(9-aff_multiplier, 4, "^");
      } else {
        myScreen.text(9-aff_multiplier, 4, "v");
      }
      display_freq (frequency_A, 3);
      display_freq (frequency_B, 5);
  
      // Read the analog buttons input
      if(read_buttons()==1) {            // Up we increase frequency
        delay(200);  // Debounce
        if (vfo == 0) {
          frequency_A = frequency_A + powf(10,(float)multiplier);
        } else {
          frequency_B = frequency_B + powf(10,(float)multiplier);
        };
#if defined AUTO_VALID
        break;
#endif

      } else if (read_buttons()==3) {    // Down we decrease frequency
        delay(200);  // Debounce
        if (vfo == 0) {
          frequency_A = frequency_A - powf(10,(float)multiplier);
        } else {
          frequency_B = frequency_B - powf(10,(float)multiplier);
        };
#if defined AUTO_VALID
        break;
#endif

      } else if (read_buttons()==2) {    // Left we increase multiplier
        debounce = millis();
        while (read_buttons()==2) {  //Debounce
          if ((millis()-debounce)>1000) {  // Long press we do "Band UP"
            freq_select++;
            if (freq_select > 14) freq_select = 0;
            if (vfo == 1) frequency_B = frequencies[freq_select]; else frequency_A=frequencies[freq_select];
            multiplier--;
            break;
          };
        };
        multiplier++;
        if (multiplier > 7) multiplier = 7;

      } else if (read_buttons()==4) {    // Right we decrease multiplier
        debounce = millis();
        while (read_buttons()==4) {  //Debounce
          if ((millis()-debounce)>1000) {  // Long press we do VFO A=B
            if (vfo == 1) frequency_A = frequency_B; else frequency_B=frequency_A;
            multiplier++;
            break;
          };
        };
        multiplier--;
        if (multiplier < 0) multiplier = 0;

      } else if (read_buttons()==5) {    // OK we go out
        debounce = millis();
        while (read_buttons()==5) {  //Debounce
          if ((millis()-debounce)>1000) {  // Long press we switch VFO A/B
            if (vfo == 1) vfo=0; else vfo=1;
            break;
          };
        };
        break;   // Short press we just leave the loop so the frequency is transmitted to the AD9850
      }

      // Check if we are transmitting split (momentaneous VFO A->B switch)
      if (saved_PTT != digitalRead(PTT_key)) {
        saved_PTT = digitalRead(PTT_key);
        if (vfo == 1) vfo=0; else vfo=1;
        break;
      };
    }

};


//******************************************************************
// Display the frequency
void display_freq (unsigned long freq, char ligne) {
  myScreen.text(10, ligne, " Hz ");
  chaine_txt[5] = 0x00;
  chaine_txt[4] = 0x30 + (((freq)/1)%10);
  chaine_txt[3] = 0x30 + (((freq)/10)%10);
  chaine_txt[2] = 0x30 + (((freq)/100)%10);
  chaine_txt[1] = '.';
  chaine_txt[0] = 0x30 + (((freq)/1000)%10);
  myScreen.text(5, ligne, chaine_txt);
  chaine_txt[5] = 0x00;
  chaine_txt[4] = 0x30 + (((freq)/10000)%10);
  chaine_txt[3] = 0x30 + (((freq)/100000)%10);
  chaine_txt[2] = '.';
  chaine_txt[1] = 0x30 + (((freq)/1000000)%10);
  chaine_txt[0] = 0x30 + (((freq)/10000000)%10);
  myScreen.text(0, ligne, chaine_txt); 
}

//******************************************************************
// Display a 2 digits number
void display_number (byte number, char column, char ligne) {
  chaine_txt[2] = 0x00;
  chaine_txt[1] = 0x30 + (number%10);
  chaine_txt[0] = 0x30 + ((number/10)%10);
  myScreen.text(column, ligne, chaine_txt);
}

//******************************************************************
// Return a button value depending on the analog reading
byte read_buttons () {
  int value = analogRead(ANALOG_BUTTONS);
  if ( value<(1+Analog_Noise) ) {
    return 1;
  } else if ( value<(78+Analog_Noise) ) {
    return 2;
  } else if ( value<(146+Analog_Noise) ) {
    return 3;
  } else if ( value<(205+Analog_Noise) ) {
    return 4;
  } else if ( value<(255+Analog_Noise) ) {
    return 5;
  } else {
    return 0;
  }
}

Nouvelle version de l’IDE Energia qui supporte nouveaux LaunchPad

Texas Instruments LaunchPad Tiva C port Ethernet (http://43oh NULL.com/2014/03/energia-ve0012-release-adds-iot-and-fram-launchpad-support/)Une nouvelle version de l’IDE Energia, portage de l’environnement de développement Arduino pour les plateformes Texas Instruments, vient d’être annoncée. Cette release 0101E0012 apporte le support de deux cartes supplémentaires ainsi que la correction de nombreux bogues (http://energia NULL.nu/download/). Ces cartes Texas Instruments sont :

  • La nouvelle LaunchPad Tiva C (http://www NULL.ti NULL.com/ww/en/launchpad/launchpads-tivac-ek-tm4c1294xl NULL.html)EK-TM4C1294XL (http://www NULL.ti NULL.com/tool/ek-tm4c1294xl) avec processeur Cortex-M4 à 120Mhz, 1 Mo de Flash, 256Ko de SRAM et surtout un port Ethernet 10/100 pour moins de 20$!
  • La LaunchPad MSP-EXP430FR5969LP (http://www NULL.ti NULL.com/ww/en/launchpad/launchpads-msp430-msp-bndl-fr5969lcd NULL.html) avec 64Ko de FRAM qui est disponible dans un bundle avec un BoosterPack écran LCD pour moins de 30$.

Autre nouveauté très importante sur Energia, le support des DriverLib API de Texas Instruments qui apporte de nombreuses facilité de programmation pour les LaunchPad à MSP430 et Tiva C.

Nouvelle version de l’IDE Energia

Logo Energia (http://xv4y NULL.radioclub NULL.asia/wp-content/uploads/2013/09/energia NULL.png)La dernière information de la série MSP430 c’est la disponibilité au téléchargement d’une nouvelle version de l’environnement de développement Energia (http://energia NULL.nu/download/) (basé sur l’application Arduino). Celle-ci corrige plusieurs bogues et apporte des améliorations diverses, mais surtout, elle ajoute le support de la nouvelle carte LaunchPad MSP430F5529 (http://xv4y NULL.radioclub NULL.asia/2013/09/20/texas-instruments-lance-le-nouveau-launchpad-msp430f5529/) annoncée récemment. Cette concomitance des deux annonces montre que la collaboration entre Texas Instruments et l’équipe qui développe Energia est plutôt efficace. Deux autres nouveautés importantes à noter dans l’application sont le support du BoosterPack Wi-Fi CC3000 et du BoosterPack Anaren AIR (communication sans-fil).

Texas Instruments lance le nouveau LaunchPad MSP430F5529

La première mouture du LaunchPad MSP430 de chez Texas Instruments utilise dans ses dernières versions des micro-contrôleurs MSP430G2452 et MSP430G2553. De la gamme Value, ils ont le gros avantage d’être en boîtier DIL, ce qui permet de les intégrer facilement à des projets externes à la carte LaunchPad. Ils sont aussi bon marché (en grosse quantité). La plus grosse de leur lacune concerne la capacité mémoire, principalement avec la SRAM limitée à 512o et la Flash à 16Ko. Pour de nombreux projets ça va, mais gérer des chaînes de caractères pour l’affichage sur un écran LCD peut rapidement devenir très compliqué. Mon contrôleur de balise à DDS pour WSPR/QRSS (http://xv4y NULL.radioclub NULL.asia/2013/06/21/montage-dun-amplificateur-5w-classe-c-de-chez-kitsandparts-com/) arrive d’ailleurs à la limite de Flash et de SRAM ce qui m’empêche d’y intégrer de nouvelles fonctionnalités. Ceci est en partie compensé par le fait qu’on peut le reprogrammer très facilement via le port USB.

LaunchPad MSP430F5529 source 43oh.com (http://xv4y NULL.radioclub NULL.asia/wp-content/uploads/2013/09/LaunchPad-MSP430F5529_43ohcom NULL.jpg)Il y a quelques jours, Texas Instruments a annoncé un nouveau produit avec le LaunchPad MSP430F5529 (http://www NULL.43oh NULL.com/2013/09/ti-releases-new-msp430f5529-usb-launchpad-for-12-99/) proposé à 12,9$ et qui vient redistribuer les cartes dans la gamme de cartes expérimentales LaunchPad. En effet, cette fois-ci plus question de boîtier DIL, le circuit MSP430F5529 est un CMS soudé définitivement sur le carte, mais c’est nécessaire pour ce type de puce et c’est déjà le cas pour les cartes LaunchPad C2000 Piccolo (http://xv4y NULL.radioclub NULL.asia/2012/12/30/launchpad-c2000-experimenter-avec-un-dps/), LaunchPad Hercules (http://xv4y NULL.radioclub NULL.asia/2013/08/12/texas-instruments-annonce-les-nouveaux-launchpad-hercules-sous-la-barre-des-20/) et LaunchPad Tiva C (Stellaris (http://xv4y NULL.radioclub NULL.asia/2013/04/15/le-stellaris-launchpad-rebaptise-tiva-c/)). Il reprend d’ailleurs la disposition des connecteurs 40 broches de ceux-ci ce qui permet d’utiliser les mêmes Booster Packs. Aussi, comme plusieurs de ses grand-frères, il dispose d’un port USB attaché au micro-contrôleur et non plus simplement au circuit de Programmation/Debug. Ceci vous permet de concevoir des périphériques USB comme par exemple un circuit qui va chercher des informations sur un serveur web et les “tapes” au clavier sur une autre machine (quelqu’un se reconnaît-il dans la foule?).

Tout le détail est disponible sur 43oh.com ici (http://www NULL.43oh NULL.com/2013/09/ti-releases-new-msp430f5529-usb-launchpad-for-12-99/)là (http://www NULL.43oh NULL.com/2013/09/new-msp430f5529-launchpad-in-pictures/) et encore là (http://www NULL.43oh NULL.com/2013/09/msp430f2559-launchpad-first-impressions/), mais voici ce qu’il faut en retenir :

  • Port USB 2.0 connecté directement au micro-contrôleur
  • Processeur cadencé à 25MHz (contre 16MHz pour le G2553)
  • 128Ko de Flash et 8Ko de SRAM (c’est beaucoup)
  • Convertisseur analogique-numérique 12bits SAR
  • Convertisseur de tension DC-DC pour disposer facilement de 5V et 3,3V via l’USB

Texas Instruments met à disposition les outils de développement et les librairies y compris pour concevoir des périphériques USB de classes CDC, HID et MSC. Vous pouvez tout aussi bien choisir de programmer ce circuit via l’Environnement Energia qui reprend la syntaxe Arduino. Les premières impressions que livre “spirillis” (membre très actif de la communauté 43oh.com) sont très positives même si quelques limitations sont notées et que TI travaille pour les lever. Une bonne nouvelle c’est que la section USB comporte 2Ko de RAM que vous pouvez utiliser conjointement aux 8Ko de la mémoire principale si vous n’activez pas l’USB. Autre point intéressant, à la livraison le LaunchPad est programmé avec une démo qui le fait agir comme périphériques HID (un clavier) et comme mémoire de masse simultanément. Cela ouvre la porte à pas mal d’applications!

 

Contrôler un Si570 avec le LaunchPad MSP430 par F4DTR

Intérieur Si570 - Photo http://hifiduino.wordpress.com/2012/10/17/inside-the-silicon-labs-si570-programmable-xo/ (http://xv4y NULL.radioclub NULL.asia/wp-content/uploads/2013/09/Inside_Si570 NULL.jpg)Vous allez le voir, aujourd’hui, c’est un peu la journée du MSP430 avec 3 billets sur le sujet…

Tout d’abord, Jean-Yves de F4DTR a partagé sur le forum de 43oh.com son travail autour du Si570 (http://forum NULL.43oh NULL.com/topic/4380-change-frequency-to-si570-dxo-on-i2c-not-fully-fonctionnal/). C’est un travail en cours et malheureusement il manque de temps pour le faire aboutir. Si vous êtes à l’aise avec l’écriture de code pour le MSP430 sur Energia et que vous souhaitez bénéficier d’un oscillateur agile, stable et de très large gamme couverte, alors donnez-lui un coup de main.

Le Stellaris LaunchPad rebaptisé Tiva C

Texas Instruments Tiva C LaunchPad (http://xv4y NULL.radioclub NULL.asia/wp-content/uploads/2013/04/2013-04-12_Tiva_Launchpad_angle NULL.jpg)Texas Instruments a apporté quelques modifications à sa plateforme hardware pour micro-contrôleurs haute performance. En plus d’être renommée Tiva C LaunchPad, le composant soudé sur la carte est un TM4C123GH6PM qui ajoute des capacités de PWM, QEI, Hôte USB avec OTG. Cette dernière fonctionnalité USB On-The-Go est un peu ce qui manquait à la précédente version et permet de connecter beaucoup plus facilement un clavier ou un autre périphérique de saisie et surtout d’accéder aux mémoires de masse sur port USB (disque dur, Flash…). Le prix est toujours de 13 USD ce qui le rend très très attractif face aux 10 USD auxquels est passé le LaunchPad MSP430 de TI.

Station météo avec serveur web – code source

Prototype station météo (http://xv4y NULL.radioclub NULL.asia/wp-content/uploads/2013/02/100_3440 NULL.jpg)J’ai continué mes travaux autour de ma mini-station météo avec serveur web. J’ai atteint les objectifs de fonctionnalités que je m’étais fixés, même s’il me reste à enrichir de quelques indicateurs les statistiques. Ensuite il me faudra repasser toutes les valeurs en type float car je les avais mises en entier pour gagner de la place mémoire et parce que l’espace d’affichage sur l’écran LCD était limité. Il me faudra aussi faire un peu de gestion de la cohérence des valeurs pour éviter d’afficher 255°C quand mon capteur distant n’a plus de piles (comme actuellement). A propos du capteur distant, il faudra aussi que je travaille sur son code pour gérer la mise en veille afin d’économiser les batteries. Dernier point important, j’attends toujours mes capteurs de pression atmosphérique (ils sont assez chers donc j’ai hésité à les inclure dans les kits) pour pouvoir gérer ce type de mesures. L’architecture générale étant présente ça ne devrait pas prendre trop de temps à mettre en place.

Vous pouvez donc le voir par vous-même sur ce prototype de mini serveur web météo (http://cairang NULL.radioclub NULL.asia:8080/), cela fonctionne et plutôt bien à mon goût. Ne vous étonnez pas si parfois il y a peu de valeurs affichées car je continue à faire des tests et à remettre à zéro les mémoires…

J’ai même eu ma première commande, car XYL a trouvé cela pratique (pour une fois à propos de mes montages) et en aura besoin d’un pour son café-restaurant. Les services de l’hygiène demande de relever ces valeurs chaque jour en principe, même si dans la réalité peu de monde le fait… Comme elle ne prévoit pas d’ouvrir le service de restauration avant avril, j’ai le temps de mettre tout cela au point.

Je dois encore faire une étude précise, mais je pense pouvoir proposer ces stations météos autour de 70$, le prix variant suivant les options (écran, contrôleur Ethernet, capteur de pression…). Dès que je peux, je mets les informations à jour sur la page produit de la boutique (http://xv4y NULL.radioclub NULL.asia/boutique/?slug=product_info NULL.php&products_id=31). Les composants sont en fait assez chers si on veut une précision correcte (les capteurs DHT-11 par exemple ne sont bons que pour des mesures relatives) et il y a deux micro-contrôleurs (un pour la station et un pour le capteur distant). Dans tous les cas ça ne sera pas avant mi-mars prochain car les approvisionnements vont être bloqués pour plusieurs semaines à partir du week-end prochain avec le nouvel an lunaire.

En attendant je partage avec vous le code source du premier programme de test que j’avais fait pour mon prototype de mini station météo web (http://xv4y NULL.radioclub NULL.asia/2013/02/01/mini-station-meteo-web/). Il a évolué depuis mais celui-ci en principe fonctionne et offre le service de base… Il est prévu pour un Arduino Nano (ATMega328) et se compile avec Arduino 1.0.1. Je vous conseille d’utiliser mes packages librairies (http://xv4y NULL.radioclub NULL.asia/boutique/docs/) pour pouvoir les compiler.

/*
Arduino Thermometer and Humidity mini web server using internal and remote DHT11 sensors
By Yannick DEVOS - XV4Y
http://xv4y.radioclub.asia/

Copyright 2013 Yannick DEVOS under GPL 3.0 license
Any commercial use or inclusion in a kit is subject to author approval

====
This program sense and displays the current temperature and relative humidity for a local and remote sensors
It serve the values to a mini web server thanks to an ENC28J60 Ethernet module

In order to compile this program with Arduino 1.0.1, you will need to install 3 libraries :
- DHT-sensor Library by Adafruit
https://github.com/adafruit/DHT-sensor-library
- VirtualWire Library by Mike McCauley
http://www.open.com.au/mikem/arduino/VirtualWire.pdf
- Ethercard Library by JeeLabs
http://jeelabs.net/pub/docs/ethercard/index.html
====
Revision history :
v1.00    2013-02-02
         First release with mini web server test
====
This program needs at least 2KB of SRAM, that means an ATMega328...

The DHT11 Sensor need to be connected as described here below
- Connect pin 1 (on the left) of the sensor to +5V
- Connect pin 2 of the sensor to whatever your DHTPIN is (here pin D12)
- Connect pin 4 (on the right) of the sensor to GROUND
- Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor
We also need a push button on pin D2.

For RF modules, please see the VirtualWire documentation

====
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You can download a copy of the GNU General Public License at <http://www.gnu.org/licenses/>
*/

#include <EtherCard.h>
#include "DHT.h"
#include <VirtualWire.h>

// Here some parameters you would like to edit

#define RXPIN  A1        // What pin we use for Remote Sensor RX module
#define BAUDRATE 2000    // Transmission speed in bps, 1000-2000 is ok a give similar ranges, higher is useless
#define RX_LOST 60       // Max time in seconds without the sensor is considered lost
#define DHTPIN A2        // What pin we have connected the DHT sensor
#define DHTTYPE DHT22

// ethernet interface ip address
static byte myip[] = { 192,168,1,100 };
// gateway ip address
static byte gwip[] = { 192,168,1,254 };

// ethernet mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

const byte header[4] = {0x01,'D','H','T'};

// Here you should not be touching it

const char http_OK[] PROGMEM =
    "HTTP/1.0 200 OK\r\n"
    "Content-Type: text/html\r\n"
    "Pragma: no-cache\r\n\r\n";

const char http_Found[] PROGMEM =
    "HTTP/1.0 302 Found\r\n"
    "Location: /\r\n\r\n";

const char http_Unauthorized[] PROGMEM =
    "HTTP/1.0 401 Unauthorized\r\n"
    "Content-Type: text/html\r\n\r\n"
    "<h1>401 Unauthorized</h1>";

DHT dht(DHTPIN, DHTTYPE);

byte Ethernet::buffer[700]; // tcp/ip send and receive buffer
BufferFiller bfill;

int hi=0xFF, ti=0xFF, hr=0xFF, tr=0xFF;
int last_rx;
unsigned int counter=0;

float tf=1;

byte buf[VW_MAX_MESSAGE_LEN];
byte buflen = VW_MAX_MESSAGE_LEN;

void setup(){
  ether.begin(sizeof Ethernet::buffer, mymac);  // Start the Ethernet module
  ether.staticSetup(myip, gwip);

  vw_set_rx_pin(RXPIN);
  vw_setup(BAUDRATE);

  vw_rx_start();       // Start the RF receiver PLL running
}

void loop() {

  hi = int(dht.readHumidity());    // we convert to integer since the DHT11 has not enough precision anyway
  ti = int(dht.readTemperature());

  if (vw_have_message()) {  // If we have a message from the RF module
    if (vw_get_message(buf, &buflen) && !memcmp(&buf, &header,4)) // If it is checked and the header is the same
    {
      // First temp, the RF module send a float but we only display an integer
      memcpy(&tf, &buf[4], 4);
      tr = int(tf);

      // THen humidity
      memcpy(&tf, &buf[8], 4);
      hr = int(tf);

      last_rx = millis()/1000;  // We save when was the last data received
    }
  }

  if ((millis()/1000) > (last_rx+RX_LOST)) {    // Without signal from the sensor for more than RX_LOST seconds, the sensor is considered out of reach
    hr = 0xFF;
    tr = 0xFF;
  }  

  // wait for an incoming TCP packet, but ignore its contents
  word len = ether.packetReceive();
  word pos = ether.packetLoop(len); 
  if (pos) {
    delay(1);
       bfill = ether.tcpOffset();
       char *data = (char *) Ethernet::buffer + pos;
    if (strncmp("GET /", data, 5) != 0) {
       // Unsupported HTTP request
       // 304 or 501 response would be more appropriate
       bfill.emit_p(http_Unauthorized);
    } else {
       data += 5;

       if (data[0] == ' ') {
           // Return home page
           homePage();
           counter++;
       } else {
           // Page not found
           bfill.emit_p(http_Unauthorized);
       }
    }
        ether.httpServerReply(bfill.position());    // send http response
  }
}

void homePage()
{
    bfill.emit_p(PSTR("$F"
        "<meta http-equiv='refresh' content='5'/>"
        "<title>Mini web météo v1.0 XV4Y</title>" 
        "<h1>Le temps du delta du mékong chez <a href=\"http://xv4y.radioclub.asia\">XV4Y</a></h1>"
        "<h2>Capteur interne</h2>"
        "Temp : $D°C</br>"
        "Hum. : $D%</br>"
        "<h2>Capteur distant</h2>"
        "Temp : $D°C</br>"
        "Hum. : $D%"
        "<h6>$Dème connexion.</h6>"
        "<h5>Copyright(C)2013 - <a href=\"http://xv4y.radioclub.asia/\">Yannick DEVOS XV4Y</a></h5>"
        ),
        http_OK,
        ti,
        hi,
        tr,
        hr,
        counter);
}

Voici aussi le code pour le capteur distant. Il fonctionne lui sur un MSP430G2452 et est écrit avec Energia 009.

/* Remote Temperature/Humidity sensor for MSP430G2452
 * Code for Energia 009

 * By Yannick DEVOS - XV4Y - December 2012
    http://xv4y.radioclub.asia/

    Copyright 2012-2013 Yannick DEVOS under GPL 3.0 license
    Any commercial use or inclusion in a kit is subject to author approval

====
  * Run on MSP430G2452
  * Hook a DHT sensor module to pin P2_1
  * Hook a 433MHz TX module to P2_4
  * Several pins are available for LED debugging
====
Revision history :
v1.00    2012-12-18
         First release, without MCU power saving features

====
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You can download a copy of the GNU General Public License at <http://www.gnu.org/licenses/>
*/

#include "DHT.h"
#include <VirtualWire.h>

#define DHTTYPE DHT11
#define DHTPIN   P2_1     // DATA Pin pour le DHT
#define TXPIN    P2_4     // DATA Pin pour le module TX RF
#define BAUDRATE 2000     // Transmission speed in bps, 1000-2000 is ok a give similar ranges, higher is useless
#define PWRPIN   P1_6     // Pin to turn ON/OFF power to the modules
#define LEDERR   P1_0     // This LED will turn on when DHT is not ok

float h, t;
byte trame[12] = {0x01,'D','H','T',0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};  // The frame to be transmitted with "DHT" as header

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  pinMode(PWRPIN, OUTPUT);     
  pinMode(LEDERR, OUTPUT);     

  vw_set_tx_pin(TXPIN);
  vw_setup(BAUDRATE);

  dht.begin();
}

void loop() {
  digitalWrite(PWRPIN, HIGH);  // Apply power to the modules
  delay (1000);                // We have to wait 1 second to let the DHT sensor stabilize

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  t = dht.readTemperature();
  h = dht.readHumidity();

  // Check if returns are valid, if they are both 0 then something went wrong!
  if (t == 0 && h == 0) {
    digitalWrite(LEDERR, HIGH);
  } else {
    // First temperature
    memcpy(&trame[4], &t, 4);
    // Then humidity
    memcpy(&trame[8], &h, 4);
    vw_send((byte *)trame, 12);
    digitalWrite(LEDERR, LOW);
  }
  vw_wait_tx(); // Wait until the whole message is gone

  digitalWrite(PWRPIN, LOW);  // We turn off power to save batteries
  delay(5000);                // We rest 5 seconds before the next reading, longer wait time will save more batteries...

}

 

Librairie VirtualWire 1.12 pour le MSP430 [MAJ2]

[GTranslate]

Pour une fois, je ne cache pas ma fierté. En environ 2 heures de travail, j’ai réussi mon premier vrai portage d’une libairie conçue pour l’Arduino, la librairie VirtualWire (http://www NULL.open NULL.com NULL.au/mikem/arduino/), vers le MSP430 avec Energia. Sans être un exploit, c’est un succès personnel car cela demande de se plonger dans le travail des autres, ce qui n’est jamais facile.

La difficulté technique était, je l’avoue, faible, car la seule spécificité matérielle était liée aux Timer de l’AVR qui sont différents du MSP430. Par contre, une certaine dose de réécriture de code a été nécessaire pour que cela se compile convenablement car il y a toute de même quelques différences entre les deux environnements Arduino et Energia dès qu’on commence à écrire en C.

Pour mémoire, le but de cette librairie et de pouvoir utiliser des petits modules de communication sans-fil sur 433 MHz ou 2,4 GHz pour relier deux micro-contrôleurs. Ces modules étant souvent très sommaires au niveau matériel avec une transmission du signal bande de base en On-Off Keying (tout ou rien), il faut que le logiciel apporte quelques subtilités supplémentaires pour rendre la transmission fiable. On peut ensuite obtenir des débits de 9000 bps ou plus souvent environ 2000 bps si on s’éloigne de 150 mètres. C’est suffisant pour faire un capteur de station météo (http://xv4y NULL.radioclub NULL.asia/boutique/?slug=product_info NULL.php&products_id=31) par exemple…

Le code n’est pas complètement testé mais compile correctement et les premiers essais que j’ai pu faire s’avèrent très concluants. J’ai entre autres fait communiquer un Arduino et un MSP430 par liaison sans-fil ce qui prouve que les timings sont stables!

Je mets à disposition le code source tel qu’il est aujourd’hui avec peut-être encore des bugs. N’hésitez pas à me faire parvenir vos commentaires pour l’améliorer! La documentation d’origine (http://www NULL.open NULL.com NULL.au/mikem/arduino/VirtualWire NULL.pdf) reste valable pour cette version du code.

MAJ :   (http://xv4y NULL.radioclub NULL.asia/ftp/VirtualWire_110_EnergiaMSP430_20120109 NULL.zip)L’auteur a intégré mes modifications et publié une nouvelle version de la librairie, la 1.12, qui devrait fonctionner à la fois sur Arduino et Energia. Elle est téléchargeable ici (http://www NULL.open NULL.com NULL.au/mikem/arduino/VirtualWire/).

MAJ2 :   (http://xv4y NULL.radioclub NULL.asia/ftp/VirtualWire_110_EnergiaMSP430_20120109 NULL.zip)Il semblerait que l’auteur de la librairie originale a bien intégré mes apports mais n’a pas testé la librairie et celle-ci ne fonctionne pas. Voici mon portage de VirtualWire 1.10 pour Energia/MSP430 tel que je l’utilise (http://xv4y NULL.radioclub NULL.asia/ftp/VirtualWire110_Energia_XV4Y NULL.zip).

Prototype balise WSPR à DDS

Prototype kit Balise WSPR DDS XV4Y (http://xv4y NULL.radioclub NULL.asia/2012/12/21/prototype-balise-wspr-a-dds/100_3339/)Je suis plutôt satisfait de ma semaine! En grappillant quelques heures entre mes occupations professionnelles j’ai réussi à finaliser la mise au point de ma balise WSPR avec un DDS AD9850 (http://xv4y NULL.radioclub NULL.asia/boutique/?slug=product_info NULL.php&products_id=33). Le prototype fonctionne parfaitement et les séquences sont reçues à 100% sur mon ordinateur de contrôle. Les tests sur l’air se sont révélés décevant mais avec moins de 10mW sur 20 mètres, les conditions hivernales et aucune station proche il ne fallait pas non plus rêver. Je vais essayer de bricoler un petit PA d’appoint pour valider les tests.

Un des points sur lequel je bloquais était la quantité de mémoire très restreinte du MSP430G2553. Avec 512 octets on est vite à cours de place pour les variables, d’autant plus que la génération de la séquence de symboles WSPR en consomme plus de 350 à elle seule! Devoir contrôler calculer la séquence WSPR, contrôler le DDS, et l’écran graphique posait pas mal de stress sur le micro-contrôleur. J’ai du réécrire une partie du code et économiser les variables. Les méthodes de programmation moderne nous apprennent à favoriser la lisibilité et la réutilisabilité du code en découpant en fonction ou en créant des classes d’objets. C’est bien beau mais même si les compilateurs modernes optimisent tout cela très bien, cela consomme quand même beaucoup de mémoire. Pas grave sur un micro-ordinateur, mais vite contraignant sur un micro-contrôleur. Les purs et durs programment toujours en assembleur, pour ma part même après 20 ans en ayant débuté à 11 ans sur le microprocesseur 6803 de mon Alice 90 (http://alice NULL.system-cfg NULL.com/) monté à partir de pièces en vrac par F1GUM, la mayonnaise n’a jamais pris…

100_3341

Si maintenant le code fonctionne parfaitement et que le hardware rempli son rôle, il me reste maintenant à voir comment tout agencer pour en faire un kit facile à reproduire et à monter, et à écrire la documentation! Dernier point technique à valider, l’ajout de 4 boutons pour pouvoir le transformer facilement en VFO ou générateur de signal.

Balise QRSS synchrone avec le LaunchPad/MSP430

Modifications de la balise QRSS QRP Labs pour WSPR - XV4Y (http://xv4y NULL.radioclub NULL.asia/2012/10/18/balise-wspr-autonome-avec-msp430-le-code-source/kit-wspr-mod-balise/)

[GTranslate]

Voici le code que j’ai écrit et qui permet de modifier l‘émetteur original de QRP Labs (http://xv4y NULL.radioclub NULL.asia/2010/08/16/kit-balise-qrss/) pour en faire une balise transmettant régulièrement toutes les minutes paires. Cela est nécessaire si vous voulez que votre transmission soit “superposable” dans les captures du grabber. En effet, de plus en plus d’OM effectuent des compositages de captures sur une base de 10 minutes. En effectuant un traitement de moyenne ou d’interpolation on peut ainsi faire sortir du bruit un signal qui n’était pas visible autrement. Ce traitement est similaire à celui fait en astronomie planétaire avec Lynkeos (http://lynkeos NULL.sourceforge NULL.net/french/index NULL.html) par exemple.

Un kit préparé avec votre indicatif permettant de modifier le circuit de la balise pour fonctionne avec ce programme (ou la version WSPR) est disponible dans la boutique (http://xv4y NULL.radioclub NULL.asia/boutique/?slug=product_info NULL.php&cPath=22&products_id=30).

Ce programme se compile avec Energia (http://energia NULL.nu/) pour un LaunchPad avec MSP430G2553. Il nécessite ma librairie sRTC (http://xv4y NULL.radioclub NULL.asia/2012/12/19/bibliotheque-rtc-pour-energia-version-1-02/).

/* QRSS beacon with 10 minutes frame for MSP430G2553
 * Code for Energia 008

 * By Yannick DEVOS - XV4Y - May-October 2012
    http://xv4y.radioclub.asia/

    Copyright 2012 Yannick DEVOS under GPL 3.0 license
    Any commercial use or inclusion in a kit is subject to author approval

====
 * Ouput on 2 bits PinA and PinB
 * PTT_key output allows to turn on/off the TX PA while sending
 * Mirror on LED1 and LED2 du LaunchPad for testing
 * Output to Serial for testing
 * Using an R-2R ladder it makes the G0UPL/G0XAR beacon frequency shift

====
Revision history :
v1.00    2012-10-26
         First release
v1.01    2012-12-01
         Cleaning and commenting
v1.02    2012-12-19
         Changes to support version 1.02 of RTC library
         Correction for better time accuracy with Serial output enabled

====
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You can download a copy of the GNU General Public License at <http://www.gnu.org/licenses/>
*/

// Here under don't touch anything unless you know what you do

#include <legacymsp430.h>
#include <sRTC.h> // Library for RTC clock with MSP430

// Alphabet binary coding by G0UPL
// 0 = dot, 1 = dash
const int _A	=	0b11111001;
const int _B	=	0b11101000;
const int _C	=	0b11101010;
const int _D	=	0b11110100;
const int _E	=	0b11111100;
const int _F	=	0b11100010;
const int _G	=	0b11110110;
const int _H	=	0b11100000;
const int _I	=	0b11111000;
const int _J	=	0b11100111;
const int _K	=	0b11110101;
const int _L	=	0b11100100;
const int _M	=	0b11111011;
const int _N	=	0b11111010;
const int _O	=	0b11110111;
const int _P	=	0b11100110;
const int _Q	=	0b11101101;
const int _R	=	0b11110010;
const int _S	=	0b11110000;
const int _T	=	0b11111101;
const int _U	=	0b11110001;
const int _V	=	0b11100001;
const int _W	=	0b11110011;
const int _X	=	0b11101001;
const int _Y	=	0b11101011;
const int _Z	=	0b11101100;
const int _SPC	=       0b11101111;
const int _0	=	0b11011111;
const int _1	=	0b11001111;
const int _2	=	0b11000111;
const int _3	=	0b11000011;
const int _4	=	0b11000001;
const int _5	=	0b11000000;
const int _6	=	0b11010000;
const int _7	=	0b11011000;
const int _8	=	0b11011100;
const int _9	=	0b11011110;
const int _BRK	 =      0b11010010;
const int _WAIT  =	0b10000000;

byte begin_sec;
int begin_chunk;

// Déclaration et initilisation des variables
byte msgIndex = 1;
byte inc_bit = 8;
byte character = _SPC;
boolean start = false;

byte key = 0;
byte etat = 0;

// *** PARAMETERS
// Here modify to your taste or needs

#define PTT_key 8
#define wsprPinA 10
#define wsprPinB 9
#define LEDPinA 14
#define LEDPinB 2
#define StartBtn 5

const int msg[] = {5, _X, _V, _4, _Y, _WAIT};  // Format, is lenght in decimal and then the character constants including the _WAIT for the end of the sequence

int vitesse = 6;    // Number of seconds per dot (QRSS6 = 6)

// Be carefull, this is only for debugging.
// If you enable this in production, the clock will drift to much (5 seconds in 10 minutes)
#define SERIAL_OUT_INFO

// This is in case you use a MSP430 that does not have Hardwart UART. TimerSerial works great but bring a lot of clock drift. Replace each "Serial" object call in the code by mySerial.
/*
#ifdef SERIAL_OUT_INFO
#include <TimerSerial.h> 
TimerSerial mySerial;
#endif
*/

// *** END OF PARAMETERS

#ifdef SERIAL_OUT_INFO
#endif
RealTimeClock myClock;

//******************************************************************
// Defining pins mode
// Encoding the WSPR sequence

void setup() {
  pinMode(PTT_key, OUTPUT);
  pinMode(wsprPinA, OUTPUT);
  pinMode(wsprPinB, OUTPUT);
  pinMode(LEDPinA, OUTPUT);
  pinMode(LEDPinB, OUTPUT);
  pinMode(StartBtn, INPUT_PULLUP);

  myClock.begin();

  #ifdef SERIAL_OUT_INFO
  Serial.begin(9600);
  Serial.println("\n* MSP430 QRSS beacon"); 
  #endif

  digitalWrite( PTT_key, LOW );
  digitalWrite( wsprPinA, LOW );
  digitalWrite( wsprPinB, LOW );

  digitalWrite( LEDPinA, HIGH );
  digitalWrite( LEDPinB, HIGH );

  #ifdef SERIAL_OUT_INFO
  Serial.println("* Wait clock is set. Sending test sequence.");
  #endif
  begin_chunk = myClock.RTC_chunk;
  begin_sec = myClock.RTC_sec;
  while(digitalRead(StartBtn)) {
    // This is for blinking LED fast
    if ((myClock.RTC_chunk-(begin_chunk+15))%60==0)
      digitalWrite( LEDPinA, HIGH );
    if ((myClock.RTC_chunk-(begin_chunk+30))%60==0)
      digitalWrite( LEDPinB, HIGH );
    if ((myClock.RTC_chunk-(begin_chunk+45))%60==0)
      digitalWrite( LEDPinA, LOW );
    if ((myClock.RTC_chunk-(begin_chunk+60))%60==0)
      digitalWrite( LEDPinB, LOW );

    // We also send a test sequence to help calibrate the transmitter
    if ((myClock.RTC_chunk-(begin_chunk+0))%240==0) 
      send_test(begin_sec);

   };
  //randomSeed(myClock.RTC_chunk);
  myClock.Set_Time(0,0,0);
};

//******************************************************************
// Here starts the actual sequence sending

void loop() {
  #ifdef SERIAL_OUT_INFO
  Serial.print("Time:");
  Serial.print(myClock.RTC_min, DEC);
  Serial.print(":");
  Serial.print(myClock.RTC_sec, DEC);
  Serial.print(".");
  Serial.println(myClock.RTC_chunk, DEC);
  #endif

  digitalWrite( PTT_key, LOW );

  digitalWrite( wsprPinB, LOW );
  digitalWrite( LEDPinB, LOW );

  digitalWrite( wsprPinA, LOW );
  digitalWrite( LEDPinA, LOW );

  begin_chunk = myClock.RTC_chunk;

  #ifdef SERIAL_OUT_INFO
  Serial.println("* Waiting 1st sec of every 2 mins.");
  #endif

  while (!(myClock.RTC_sec==1 && (myClock.RTC_min%2)==0)) {  // We start each first second of even minutes
    if ((myClock.RTC_chunk-(begin_chunk+10))%20==0) digitalWrite( LEDPinA, HIGH );
    if ((myClock.RTC_chunk-(begin_chunk+20))%20==0) digitalWrite( LEDPinA, LOW );
  };

  #ifdef SERIAL_OUT_INFO
  Serial.println("\n* Sequence begin");
  #endif
  digitalWrite( PTT_key, HIGH );
  send_sequence();
  #ifdef SERIAL_OUT_INFO
  Serial.println("\n* End");
  #endif
};

//******************************************************************
// Function to send the test sequence
void send_test(char begin_sec) {
    if ((myClock.RTC_sec-(begin_sec+0))%30==0) {
      digitalWrite( PTT_key, LOW );
      digitalWrite( wsprPinA, LOW );
      digitalWrite( wsprPinB, LOW );
      #ifdef SERIAL_OUT_INFO
      Serial.println("* TX Low, Send 00 *");
      #endif
    }

    if ((myClock.RTC_sec-(begin_sec+6))%30==0) {
      digitalWrite( PTT_key, HIGH );
      digitalWrite( wsprPinA, LOW );
      digitalWrite( wsprPinB, LOW );
      #ifdef SERIAL_OUT_INFO
      Serial.println("* TX High, Send 00 *");
      #endif
    }

    if ((myClock.RTC_sec-(begin_sec+12))%30==0) {
      digitalWrite( PTT_key, HIGH );
      digitalWrite( wsprPinA, HIGH );
      digitalWrite( wsprPinB, LOW );
      #ifdef SERIAL_OUT_INFO
      Serial.println("* TX High, Send 01 *");
      #endif
    }

    if ((myClock.RTC_sec-(begin_sec+18))%30==0) {
      digitalWrite( PTT_key, HIGH );
      digitalWrite( wsprPinA, LOW );
      digitalWrite( wsprPinB, HIGH );
      #ifdef SERIAL_OUT_INFO
      Serial.println("* TX High, Send 10 *");
      #endif
    }

    if ((myClock.RTC_sec-(begin_sec+24))%30==0) {
      digitalWrite( PTT_key, HIGH );
      digitalWrite( wsprPinA, HIGH );
      digitalWrite( wsprPinB, HIGH );
      #ifdef SERIAL_OUT_INFO
      Serial.println("* TX High, Send 11 *");
      #endif
    }

};

//******************************************************************
// Function to send the sequence
void send_sequence() {

  while (character != _WAIT) {
    msgIndex = 1;

    while (msgIndex < msg[0]+1) {
      // We read each character in the array
      character = msg[msgIndex];

      inc_bit = 8;

      // Special characters
      if (character == _SPC) {  // For inter-words spacing, we need 5 dots, since we already have 1+2, we need 2 more
         begin_sec = myClock.RTC_sec;
         #ifdef SERIAL_OUT_INFO
         Serial.println("\n* Inter word Space *");
         #endif
         while ( ((60+myClock.RTC_sec-begin_sec)%60)<(2*vitesse) ) {
            delay(0);
         };
         inc_bit = 0;
      };
      if (character == _WAIT) {  // For WAIT or end of sequence, we just skip sending
         #ifdef SERIAL_OUT_INFO
         Serial.println("\n* Enf of sequence *");
         #endif
         inc_bit = 0;
      };

      while (inc_bit) {

        // We read each bit of the character
        etat = bitRead(character,inc_bit-1);

        if (start) {
          if (etat) {
            key=3; // If the bit is 1 then it is a dash
            #ifdef SERIAL_OUT_INFO
            Serial.print("-");
            #endif
          } else {
            key=1; // If the bit is 0 then it is a dot
            #ifdef SERIAL_OUT_INFO
            Serial.print(".");
            #endif
          }

          while (key) {

            digitalWrite( wsprPinB, HIGH );
            digitalWrite( LEDPinB, HIGH );
            digitalWrite( wsprPinA, HIGH );
            digitalWrite( LEDPinA, HIGH );

            // We wait 1 second x VITESSE parameter
            begin_sec = myClock.RTC_sec;
            while ( ((60+myClock.RTC_sec-begin_sec)%60)<(1*vitesse) ) {
              delay(0);
            };

            key--;
          }

          digitalWrite( wsprPinB, LOW );
          digitalWrite( LEDPinB, LOW );
          digitalWrite( wsprPinA, LOW );
          digitalWrite( LEDPinA, LOW );
            // We wait 1 second x VITESSE parameter
          begin_sec = myClock.RTC_sec;
          while ( ((60+myClock.RTC_sec-begin_sec)%60)<(1*vitesse) ) {
            delay(0);
          };
        }

        if (!etat && !start) start=true;

        inc_bit--;

      }
      // We add one space between each characteur (lenght is 3 dots, including the one in the here above loop)
      begin_sec = myClock.RTC_sec;
      #ifdef SERIAL_OUT_INFO
      Serial.print(" ");
      #endif
      while ( ((60+myClock.RTC_sec-begin_sec)%60)<(2*vitesse) ) {
        delay(0);
      };

      start = false;
      msgIndex++;
    };
   };
   character = _SPC;
};

//******************************************************************
// Interruption for the RTC clock
interrupt(TIMER1_A0_VECTOR) Tic_Tac(void) {
  myClock.Inc_chunk();		      // Update chunks
};