IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C Discussion :

Programmation siteplayer avec PIC : envoi de donnée


Sujet :

C

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2006
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Août 2006
    Messages : 61
    Points : 26
    Points
    26
    Par défaut Programmation siteplayer avec PIC : envoi de donnée
    Bonjour à tous,

    j'ai un PIC16F877A et un site player, je visualise les données du PIC grâce au site player sans pouvoir les modifier or je voudrais pouvoir les modifers.

    Donc depuis la page web du site player modifier une variable du PIC.

    Voici le code "officiel" :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    /****************************************************************************
    *****************************************************************************
     
           PROGRAMME DE LA CARTE "CONTROLE" DU SYSTEME maison intelligente
                    dialogue webserver
                    =+=+=+= Lycée Louis Armand - Villefranche =+=+=+=
     
                    Version  9-4-2009 par A. DELORE
     
     
     
    *****************************************************************************
    *****************************************************************************/
     
    #include <16F877A.h>
    #device icd=true             // Autorisation debugger
     
    #FUSES NOWDT                 // No Watch Dog Timer
    #FUSES HS                    // High speed Osc (> 4mhz)
    #FUSES NOPUT                 // No Power Up Timer
    #FUSES NOPROTECT             // Code not protected from reading
    #FUSES NODEBUG               // No Debug mode for ICD
    #FUSES BROWNOUT              // Reset when brownout detected
    #FUSES NOLVP                 // No low voltage prgming, B3(PIC16) used for I/O
    #FUSES NOCPD                 // No EE protection
    #FUSES NOWRT                 // Program memory not write protected
     
    #use delay(clock=20000000)       // Fréquence du quartz 20MHz
     
    /* Définition des paramètres pour la liaison série webserver */
    #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
    /* définition de la liaison I2c*/
    #use i2c(Master,Fast=100000,sda=PIN_C4,scl=PIN_C3) //Fast=xxxxx permet de diminuer la vitesse de l'horloge
                                                       //pour assurerla communication en fonction de la longueur
     
    // Adresse des esclaves
    #define	adALARM	0xF0
    #define	adVOLET	0xF2
    #define	adTEMP   0xF4
     
    // Définition des E/S TOR sur carte CONTROLE
     
    #define resetSP1        PIN_D1   // Reset du module SitePlayer
    #define comm            PIN_D3   // LED communication
    #define led_chauffage   pin_d4
    #define led_volet       pin_d5
    #define led_alarme      pin_d6
    #define bouton_chauffage pin_b2
    #define bouton_volet    pin_b1
    #define bouton_alarme   pin_b0
     
    // Déclaration des fonctions utilisées (utile pour le compilateur)
    void initialisation();
    void trait_bouton();
    void trait_alarme();
    void marche_carte();
     
    void ecri_mot_sp1();
     
    /*****************************************************************************/
    void I2C_Envoie_Octet(int _adESCLAVE, int _adInterne, int _Donnee);
    int I2C_Lit_Octet(int adESCLAVE, int adInterne);
    void I2C_Lit_Octet_temp(int adESCLAVE, int adInterne);
     
     
     
     
    // Déclarations du type des variables globales
    // int1 : 1 bit
       int1 timeout_error;
     
       int1 bouton_appuye_chauffage,bouton_appuye_volet,bouton_appuye_alarme;
     
    // int : 8 bits (-128 à 127)
       int nboctet, i, etape, timeout;
       int retard = 50;
       int lit_char();
       int  data;
       int chauffage,volet,alarme;   //memo etat carte
       int posvolet,etat_al;
     
    // char : 8 bits (0 à 255)
       char sp1_tx[16];
       char sp1_rx[16];
       char etat_temp[4]={"***"};
       char etat_alarme[4]={"***"};
       char etat_volet[4]={"***"};
       char pos_volet[7]={"******"};
       char al_porte[7]={"******"};
       char al_garage[7]={"******"};
       char al_exter[7]={"******"};
     
     
       char temp_salon[2], temp_cuisine[2] , temp_chambre1[2], temp_chambre2[2];
     
       // int16 = 16 bits
     
    // float = virgule flottante
     
     
     
     
    /* =============   PROGRAMME PRINCIPAL   ==================*/
     
     
    void main()
    {
       initialisation();
     
       do
          {
     
     
     
             trait_bouton();         //acquisition boutons tactiles
             marche_carte();         //texte pour SP1 On/OFF
     
             I2C_Envoie_Octet(adVOLET, 0x80, volet);    //emission marche carte volet
             if(volet)
             {
                posvolet=I2C_Lit_Octet(adVOLET,0x80);      //volet ouvert,ferme?
                if (posvolet)
                   strcpy(pos_volet,"FERME ");
                else
                   strcpy(pos_volet,"OUVERT");
             }
             else
                strcpy(pos_volet,"******");
     
              I2C_Envoie_Octet(adALARM, 0x80, alarme);    //emission marche alarme
     
             if(alarme)
             {
              etat_al=I2C_Lit_Octet(adALARM,0x80);      //etat des alarmes
              trait_alarme();
             }
             else
             {
                strcpy(al_porte,"******");
                strcpy(al_garage,"******");
                strcpy(al_exter,"******");
             }
     
             I2C_Envoie_Octet(adTEMP, 0x80, chauffage);    //emission marche carte temperature
            if(chauffage)
                I2C_Lit_Octet_temp(adTEMP,0x80);      //lecture température 8 octets
                else
                {
                   temp_salon[0]=0;
                   temp_salon[1]=0;
                   temp_cuisine[0]=0;
                   temp_cuisine[1]=0;
                   temp_chambre1[0]=0;
                   temp_chambre1[1]=0;
                   temp_chambre2[0]=0;
                   temp_chambre2[1]=0;
                }
     
             ecri_mot_sp1();         // Ecriture des mots dans SP1
             //delay_ms(retard);
             if(etape==1)    //cligno led
             {
                output_high(comm);
                etape=0;
             }
             else
             {
                output_low(comm);
                etape=1;
             }
     
     
          }
       while(1);                     // Le programme reboucle indéfiniment.
    }
    /*   ==============   FIN DU PROGRAMME PRINCIPAL  ========== */
     
     
    /*   ======   FONCTIONS APPELEES PAR LE PROGRAMME PRINCIPAL  ======= */
     
    /* Configuration du microcontroleur */
    void initialisation()
    {
       /* Initialisation des variables */
       chauffage=0;
       volet=0;
       alarme=0;
       etat_al=0;
       bouton_appuye_chauffage=0;
       bouton_appuye_volet=0;
       bouton_appuye_alarme=0;
       etape=0;
     
       /* Reset du Webserveur SP1 */
       output_high(resetSP1);
       delay_ms(100);
       output_low(resetSP1);
     
       /* Attente démarrage du Web serveur SP1 (mini 150 ms) */
       for (i = 0 ; i < 5 ; i++)
       {
       output_low(comm);           // Clignotement rapide de la LED communication
       delay_ms(100);
       output_high(comm);
       delay_ms(100);
       }
     
       /* Init communication avec Web Serveur SP1 */
     
       for (i = 0 ; i < 20 ; i++)
       {
          putc(0);                      // Init communication SP1 (20 NOP)
       }
       delay_ms(50);
                                     //init temperature
       temp_salon[0]=0;
       temp_salon[1]=0;
       temp_cuisine[0]=0;
       temp_cuisine[1]=0;
       temp_chambre1[0]=0;
       temp_chambre1[1]=0;
       temp_chambre2[0]=0;
       temp_chambre2[1]=0;
     
    }
     
     
     
     
     
    /********** Ecriture mots dans Web Serveur SP1 ************/
    void ecri_mot_sp1()
    {
       int j;
     
       sp1_tx[0] = 0x87;                // Code écriture 8 octets
       sp1_tx[1] = 0x0;                 // à l'adresse 0000
       sp1_tx[2] = temp_salon[0];
       sp1_tx[3] = temp_salon[1];
       sp1_tx[4] = temp_cuisine[0];
       sp1_tx[5] = temp_cuisine[1];
       sp1_tx[6] = temp_chambre1[0];
       sp1_tx[7] =temp_chambre1[1];
       sp1_tx[8] = temp_chambre2[0];
       sp1_tx[9] =temp_chambre2[1];
     
        for (nboctet = 0 ; nboctet < 10 ; nboctet++)
       {
          putc(sp1_tx[nboctet]);        // écriture sur liaison série
       }
       delay_ms(50);
             sp1_tx[0] = 0x8B;          //12 octets
             sp1_tx[1] = 0x0F;          //adresse 0F
          for (j = 0 ; j< 4 ; j++)
             sp1_tx[2+j] = etat_temp[j];
          for (j = 0 ; j< 4 ; j++)
             sp1_tx[6+j] = etat_alarme[j];
          for (j = 0 ; j< 4 ; j++)
             sp1_tx[10+j] = etat_volet[j];
     
          for (nboctet = 0 ; nboctet < 14 ; nboctet++)
          {
            putc(sp1_tx[nboctet]);        // écriture sur liaison série
          }
          delay_ms(50);
     
          sp1_tx[0] = 0x8C;            //13 octets
          sp1_tx[1] = 0x1f;          //adresse 1F
          for (j = 0 ; j< 7 ; j++)
             sp1_tx[2+j] = pos_volet[j];
          for (j = 0 ; j< 7 ; j++)
             sp1_tx[9+j] = al_porte[j];
          for (nboctet = 0 ; nboctet < 15 ; nboctet++)
          {
             putc(sp1_tx[nboctet]);        // écriture sur liaison série
          }
       delay_ms(50);
     
          sp1_tx[0] = 0x8c;            //13 octets
          sp1_tx[1] = 0x2F;             //adresse 2F
          for (j = 0 ; j< 7 ; j++)
             sp1_tx[2+j] = al_garage[j];
          for (j = 0 ; j< 7 ; j++)
             sp1_tx[9+j] = al_exter[j];
           for (nboctet = 0 ; nboctet < 15 ; nboctet++)
          {
             putc(sp1_tx[nboctet]);        // écriture sur liaison série
          }
       delay_ms(50);
     
    }
     
     
    /*traitement des boutons tactiles*/
    void trait_bouton()
    {
     
       //***** detection appui sur bouton chauffage*******
     
          if (input(bouton_chauffage) && (bouton_appuye_chauffage==0))
          {
             bouton_appuye_chauffage=1;
             if (chauffage==0)
             {
                chauffage=1;
                output_high (led_chauffage);
             }
             else
             {
                chauffage=0;
                output_low (led_chauffage);
             }
          }
          if (!input(bouton_chauffage))
          {
             bouton_appuye_chauffage=0;
          }
     
       //******** detection appui sur bouton volet
     
    	if (input(bouton_volet) && (bouton_appuye_volet==0))
          {
             bouton_appuye_volet=1;
             if (volet==0)
             {
                volet=1;
                output_high (led_volet);
             }
             else
             {
                volet=0;
                output_low (led_volet);
             }
          }
          if (!input(bouton_volet))
          {
             bouton_appuye_volet=0;
          }
     
     //*************** detection appui sur bouton alarme
     
     
    	if (input(bouton_alarme) && (bouton_appuye_alarme==0))
          {
             bouton_appuye_alarme=1;
             if (alarme==0)
             {
                alarme=1;
                output_high (led_alarme);
             }
             else
             {
                alarme=0;
                output_low (led_alarme);
             }
          }
          if (!input(bouton_alarme))
          {
             bouton_appuye_alarme=0;
          }
    }
     
    //**********texte ON/OFFpour affichage SP1***************
     
    void marche_carte()
    {
     
       If(chauffage)
        strcpy(etat_temp,"ON ");
        else
          strcpy(etat_temp,"OFF");
       If(alarme)
         strcpy(etat_alarme,"ON ");
        else
          strcpy(etat_alarme,"OFF");
       If(volet)
        strcpy(etat_volet,"ON ");
        else
          strcpy(etat_volet,"OFF");
     
    }
    //*******************traitement des alarmes********************
     
    void trait_alarme()
    {
       if(etat_al & 0b00000001)
          strcpy(al_porte,"INTRUS");
          else
             strcpy(al_porte,"NEANT ");
       if(etat_al & 0b00000010)
          strcpy(al_garage,"INTRUS");
          else
             strcpy(al_garage,"NEANT ");
       if(etat_al & 0b00000100)
          strcpy(al_exter,"INTRUS");
          else
             strcpy(al_exter,"NEANT ");
    }
     
    /****************emission octets I2C*******************************************/
    void I2C_Envoie_Octet(int _adESCLAVE, int _adInterne, int _Donnee)
    {
          i2c_start();
          i2c_write(_adESCLAVE);
          i2c_write(_Donnee);
          i2c_stop();
     
    }
    /*****************************************************************************/
    /*****************************************************************************/
    int I2C_Lit_Octet(int adESCLAVE, int adInterne)
    {
          int retour;
     
          i2c_start();
          i2c_write(adESCLAVE + 1);     // On ajoute 1 pour mettre à 1 le bit R/W
          retour = i2c_read(0);
          i2c_stop();
     
          return retour;
    }
    /*******************lecture temperature*/
    void I2C_Lit_Octet_temp(int adESCLAVE, int adInterne)
    {
     
          i2c_start();
          i2c_write(adESCLAVE + 1);     // On ajoute 1 pour mettre à 1 le bit R/W
          temp_salon[0]= i2c_read(1);
          temp_salon[1]= i2c_read(1);
          temp_cuisine[0]= i2c_read(1);
          temp_cuisine[1]= i2c_read(1);
          temp_chambre1[0]= i2c_read(1);
          temp_chambre1[1]= i2c_read(1);
          temp_chambre2[0] = i2c_read(1);
          temp_chambre2[1]= i2c_read(0);
          i2c_stop();
    }
    merci d'avance pour votre aide,

    j'aurais aimer pouvoir modifier par exemple l'état du volet et je me demandais si il existait une fonction comme "strcpy" qui me permettrait de mettre directement la valeur du formulaire reçu à l'intérieur de la variable du PIC.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    strcpy(volet_form, etat_volet)
    Je vous remercie d'avance

    EDIT :

    Voici ce que j'ai codé qui me semble pouvoir fonctionné :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    void gestion_ethernet
    { 
    data = i2c_lit_donne(0x80);
    // data = 1 ; 0 (ferme / ouvert)
    if ( data )
    {
    i2c_envoi(0);
    }
    else
    {
    i2c_envoi(1);
    }
    }
    Voila cette fonctionne devrait en gros me controler l'ouverture et fermeture des volets depuis la page html, il faudrait juste que je puisse detecté l'action sur la page HTML pour ensuite appelé cette fonction.

    Merci

  2. #2
    Membre régulier Avatar de Bucketpc
    Inscrit en
    Août 2008
    Messages
    98
    Détails du profil
    Informations personnelles :
    Âge : 36

    Informations forums :
    Inscription : Août 2008
    Messages : 98
    Points : 118
    Points
    118
    Par défaut
    Bonjour,

    Je me demande pourquoi n'êtes vous pas aller chercher la fonction dans l'include de ton PIC
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    //////// Standard Header file for the PIC16F877A device ////////////////
    #device PIC16F877A
    #nolist
    //////// Program memory: 8192x14  Data RAM: 367  Stack: 8
    //////// I/O: 33   Analog Pins: 8
    //////// Data EEPROM: 256
    //////// C Scratch area: 77   ID Location: 2000
    //////// Fuses: LP,XT,HS,RC,NOWDT,WDT,NOPUT,PUT,PROTECT,DEBUG,NODEBUG
    //////// Fuses: NOPROTECT,NOBROWNOUT,BROWNOUT,LVP,NOLVP,CPD,NOCPD,WRT_50%
    //////// Fuses: NOWRT,WRT_25%,WRT_5%
    //////// 
    ////////////////////////////////////////////////////////////////// I/O
    // Discrete I/O Functions: SET_TRIS_x(), OUTPUT_x(), INPUT_x(),
    //                         PORT_B_PULLUPS(), INPUT(),
    //                         OUTPUT_LOW(), OUTPUT_HIGH(),
    //                         OUTPUT_FLOAT(), OUTPUT_BIT()
    // Constants used to identify pins in the above are:
     
    #define PIN_A0  40
    #define PIN_A1  41
    #define PIN_A2  42
    #define PIN_A3  43
    #define PIN_A4  44
    #define PIN_A5  45
     
    #define PIN_B0  48
    #define PIN_B1  49
    #define PIN_B2  50
    #define PIN_B3  51
    #define PIN_B4  52
    #define PIN_B5  53
    #define PIN_B6  54
    #define PIN_B7  55
     
    #define PIN_C0  56
    #define PIN_C1  57
    #define PIN_C2  58
    #define PIN_C3  59
    #define PIN_C4  60
    #define PIN_C5  61
    #define PIN_C6  62
    #define PIN_C7  63
     
    #define PIN_D0  64
    #define PIN_D1  65
    #define PIN_D2  66
    #define PIN_D3  67
    #define PIN_D4  68
    #define PIN_D5  69
    #define PIN_D6  70
    #define PIN_D7  71
     
    #define PIN_E0  72
    #define PIN_E1  73
    #define PIN_E2  74
     
    ////////////////////////////////////////////////////////////////// Useful defines
    #define FALSE 0
    #define TRUE 1
     
    #define BYTE int
    #define BOOLEAN short int
     
    #define getc getch
    #define fgetc getch
    #define getchar getch
    #define putc putchar
    #define fputc putchar
    #define fgets gets
    #define fputs puts
     
    ////////////////////////////////////////////////////////////////// Control
    // Control Functions:  RESET_CPU(), SLEEP(), RESTART_CAUSE()
    // Constants returned from RESTART_CAUSE() are:
    #define WDT_FROM_SLEEP  0     
    #define WDT_TIMEOUT     8     
    #define MCLR_FROM_SLEEP 16    
    #define NORMAL_POWER_UP 24    
     
     
    ////////////////////////////////////////////////////////////////// Timer 0
    // Timer 0 (AKA RTCC)Functions: SETUP_COUNTERS() or SETUP_TIMER0(),
    //                              SET_TIMER0() or SET_RTCC(),
    //                              GET_TIMER0() or GET_RTCC()
    // Constants used for SETUP_TIMER0() are:
    #define RTCC_INTERNAL   0
    #define RTCC_EXT_L_TO_H 32
    #define RTCC_EXT_H_TO_L 48
     
    #define RTCC_DIV_1      8
    #define RTCC_DIV_2      0
    #define RTCC_DIV_4      1
    #define RTCC_DIV_8      2
    #define RTCC_DIV_16     3
    #define RTCC_DIV_32     4
    #define RTCC_DIV_64     5
    #define RTCC_DIV_128    6
    #define RTCC_DIV_256    7
     
     
    #define RTCC_8_BIT      0     
     
    // Constants used for SETUP_COUNTERS() are the above
    // constants for the 1st param and the following for
    // the 2nd param:
     
    ////////////////////////////////////////////////////////////////// WDT
    // Watch Dog Timer Functions: SETUP_WDT() or SETUP_COUNTERS() (see above)
    //                            RESTART_WDT()
    //
    #define WDT_18MS        8   
    #define WDT_36MS        9   
    #define WDT_72MS       10   
    #define WDT_144MS      11   
    #define WDT_288MS      12   
    #define WDT_576MS      13   
    #define WDT_1152MS     14   
    #define WDT_2304MS     15   
     
    ////////////////////////////////////////////////////////////////// Timer 1
    // Timer 1 Functions: SETUP_TIMER_1, GET_TIMER1, SET_TIMER1
    // Constants used for SETUP_TIMER_1() are:
    //      (or (via |) together constants from each group)
    #define T1_DISABLED         0
    #define T1_INTERNAL         0x85
    #define T1_EXTERNAL         0x87
    #define T1_EXTERNAL_SYNC    0x83
     
    #define T1_CLK_OUT          8
     
    #define T1_DIV_BY_1         0
    #define T1_DIV_BY_2         0x10
    #define T1_DIV_BY_4         0x20
    #define T1_DIV_BY_8         0x30
     
    ////////////////////////////////////////////////////////////////// Timer 2
    // Timer 2 Functions: SETUP_TIMER_2, GET_TIMER2, SET_TIMER2
    // Constants used for SETUP_TIMER_2() are:
    #define T2_DISABLED         0
    #define T2_DIV_BY_1         4
    #define T2_DIV_BY_4         5
    #define T2_DIV_BY_16        6
     
    ////////////////////////////////////////////////////////////////// CCP
    // CCP Functions: SETUP_CCPx, SET_PWMx_DUTY
    // CCP Variables: CCP_x, CCP_x_LOW, CCP_x_HIGH
    // Constants used for SETUP_CCPx() are:
    #define CCP_OFF                         0
    #define CCP_CAPTURE_FE                  4
    #define CCP_CAPTURE_RE                  5
    #define CCP_CAPTURE_DIV_4               6
    #define CCP_CAPTURE_DIV_16              7
    #define CCP_COMPARE_SET_ON_MATCH        8
    #define CCP_COMPARE_CLR_ON_MATCH        9
    #define CCP_COMPARE_INT                 0xA
    #define CCP_COMPARE_RESET_TIMER         0xB
    #define CCP_PWM                         0xC
    #define CCP_PWM_PLUS_1                  0x1c
    #define CCP_PWM_PLUS_2                  0x2c
    #define CCP_PWM_PLUS_3                  0x3c
    long CCP_1;
    #byte   CCP_1    =                      0x15        
    #byte   CCP_1_LOW=                      0x15        
    #byte   CCP_1_HIGH=                     0x16        
    long CCP_2;
    #byte   CCP_2    =                      0x1B        
    #byte   CCP_2_LOW=                      0x1B        
    #byte   CCP_2_HIGH=                     0x1C        
    ////////////////////////////////////////////////////////////////// PSP
    // PSP Functions: SETUP_PSP, PSP_INPUT_FULL(), PSP_OUTPUT_FULL(),
    //                PSP_OVERFLOW(), INPUT_D(), OUTPUT_D()
    // PSP Variables: PSP_DATA
    // Constants used in SETUP_PSP() are:
    #define PSP_ENABLED                     0x10
    #define PSP_DISABLED                    0
     
    #byte   PSP_DATA=                       8   
     
    ////////////////////////////////////////////////////////////////// SPI
    // SPI Functions: SETUP_SPI, SPI_WRITE, SPI_READ, SPI_DATA_IN
    // Constants used in SETUP_SSP() are:
    #define SPI_MASTER       0x20
    #define SPI_SLAVE        0x24
    #define SPI_L_TO_H       0
    #define SPI_H_TO_L       0x10
    #define SPI_CLK_DIV_4    0
    #define SPI_CLK_DIV_16   1
    #define SPI_CLK_DIV_64   2
    #define SPI_CLK_T2       3
    #define SPI_SS_DISABLED  1
     
    #define SPI_SAMPLE_AT_END 0x8000
    #define SPI_XMIT_L_TO_H  0x4000
     
    ////////////////////////////////////////////////////////////////// UART
    // Constants used in setup_uart() are:
    // FALSE - Turn UART off
    // TRUE  - Turn UART on
    #define UART_ADDRESS 2
    #define UART_DATA    4
    // TRUE  - Turn UART on
    ////////////////////////////////////////////////////////////////// COMP
    // Comparator Variables: C1OUT, C2OUT
    // Constants used in setup_comparators() are:
    #define A0_A3_A1_A3  0xfff04
    #define A0_A3_A1_A2_OUT_ON_A4_A5  0xfcf03
    #define A0_A3_A1_A3_OUT_ON_A4_A5  0xbcf05
    #define NC_NC_NC_NC  0x0ff07
    #define A0_A3_A1_A2  0xfff02
    #define A0_A3_NC_NC_OUT_ON_A4  0x9ef01
    #define A0_VR_A1_VR 0x3ff06
    #define A3_VR_A2_VR 0xcff0e
     
    #bit C1OUT = 0x9c.6      
    #bit C2OUT = 0x9c.7      
     
    ////////////////////////////////////////////////////////////////// VREF
    // Constants used in setup_vref() are:
    //
    #define VREF_LOW  0xa0
    #define VREF_HIGH 0x80
    // Or (with |) the above with a number 0-15
    #define VREF_A2   0x40
     
     
    ////////////////////////////////////////////////////////////////// ADC
    // ADC Functions: SETUP_ADC(), SETUP_ADC_PORTS() (aka SETUP_PORT_A),
    //                SET_ADC_CHANNEL(), READ_ADC()
    // Constants used for SETUP_ADC() are:
    #define ADC_OFF                 0              // ADC Off
    #define ADC_CLOCK_DIV_2   0x10000
    #define ADC_CLOCK_DIV_4    0x4000
    #define ADC_CLOCK_DIV_8    0x0040
    #define ADC_CLOCK_DIV_16   0x4040
    #define ADC_CLOCK_DIV_32   0x0080
    #define ADC_CLOCK_DIV_64   0x4080
    #define ADC_CLOCK_INTERNAL 0x00c0              // Internal 2-6us
     
    // Constants used in SETUP_ADC_PORTS() are:
    #define NO_ANALOGS                           7    // None
    #define ALL_ANALOG                           0    // A0 A1 A2 A3 A5 E0 E1 E2 Ref=Vdd 
    #define AN0_AN1_AN2_AN4_AN5_AN6_AN7_VSS_VREF 1    // A0 A1 A2 A5 E0 E1 E2 Ref=A3     
    #define AN0_AN1_AN2_AN3_AN4                  2    // A0 A1 A2 A3 A5 Ref=Vdd          
    #define AN0_AN1_AN2_AN4_VSS_VREF             3    // A0 A1 A2 A5 Ref=A3              
    #define AN0_AN1_AN3                          4    // A0 A1 A3 Ref=Vdd
    #define AN0_AN1_VSS_VREF                     5    // A0 A1 Ref=A3
    #define AN0_AN1_AN4_AN5_AN6_AN7_VREF_VREF 0x08    // A0 A1 A5 E0 E1 E2 Ref=A2,A3     
    #define AN0_AN1_AN2_AN3_AN4_AN5           0x09    // A0 A1 A2 A3 A5 E0 Ref=Vdd       
    #define AN0_AN1_AN2_AN4_AN5_VSS_VREF      0x0A    // A0 A1 A2 A5 E0 Ref=A3           
    #define AN0_AN1_AN4_AN5_VREF_VREF         0x0B    // A0 A1 A5 E0 Ref=A2,A3           
    #define AN0_AN1_AN4_VREF_VREF             0x0C    // A0 A1 A5 Ref=A2,A3              
    #define AN0_AN1_VREF_VREF                 0x0D    // A0 A1 Ref=A2,A3
    #define AN0                               0x0E    // A0
    #define AN0_VREF_VREF                     0x0F    // A0 Ref=A2,A3
    #define ANALOG_RA3_REF         0x1         //!old only provided for compatibility
    #define A_ANALOG               0x2         //!old only provided for compatibility  
    #define A_ANALOG_RA3_REF       0x3         //!old only provided for compatibility  
    #define RA0_RA1_RA3_ANALOG     0x4         //!old only provided for compatibility
    #define RA0_RA1_ANALOG_RA3_REF 0x5         //!old only provided for compatibility
    #define ANALOG_RA3_RA2_REF              0x8   //!old only provided for compatibility
    #define ANALOG_NOT_RE1_RE2              0x9   //!old only provided for compatibility  
    #define ANALOG_NOT_RE1_RE2_REF_RA3      0xA   //!old only provided for compatibility  
    #define ANALOG_NOT_RE1_RE2_REF_RA3_RA2  0xB   //!old only provided for compatibility  
    #define A_ANALOG_RA3_RA2_REF            0xC   //!old only provided for compatibility  
    #define RA0_RA1_ANALOG_RA3_RA2_REF      0xD   //!old only provided for compatibility
    #define RA0_ANALOG                      0xE   //!old only provided for compatibility
    #define RA0_ANALOG_RA3_RA2_REF          0xF   //!old only provided for compatibility
     
     
    // Constants used in READ_ADC() are:
    #define ADC_START_AND_READ     7   // This is the default if nothing is specified
    #define ADC_START_ONLY         1
    #define ADC_READ_ONLY          6
     
     
     
    ////////////////////////////////////////////////////////////////// INT
    // Interrupt Functions: ENABLE_INTERRUPTS(), DISABLE_INTERRUPTS(),
    //                      EXT_INT_EDGE()
    //
    // Constants used in EXT_INT_EDGE() are:
    #define L_TO_H              0x40
    #define H_TO_L                 0
    // Constants used in ENABLE/DISABLE_INTERRUPTS() are:
    #define GLOBAL                    0x0BC0
    #define INT_RTCC                  0x0B20
    #define INT_RB                    0x0B08
    #define INT_EXT                   0x0B10
    #define INT_AD                    0x8C40
    #define INT_TBE                   0x8C10
    #define INT_RDA                   0x8C20
    #define INT_TIMER1                0x8C01
    #define INT_TIMER2                0x8C02
    #define INT_CCP1                  0x8C04
    #define INT_CCP2                  0x8D01
    #define INT_SSP                   0x8C08
    #define INT_PSP                   0x8C80
    #define INT_BUSCOL                0x8D08
    #define INT_EEPROM                0x8D10
    #define INT_TIMER0                0x0B20
    #define INT_COMP                  0x8D40
     
    #list
    Pourquoi chercher vous une fonction toute faite pour faire le strcpy() ? alors que vous pourrez la coder très facilement vous même ?

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2006
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Août 2006
    Messages : 61
    Points : 26
    Points
    26
    Par défaut
    Désolé si je ne vois pas bien quelle fonction utilisé... ?

    En faite j'aimerais simplement pouvoir définir une valeur dans une variable sur le SP1 et que j'envoie dans une variable sur le PIC que je puisse traité, et que du pic je puisse aussi envoyé et donc modifier cette valeur dans le SP1...

  4. #4
    Membre régulier Avatar de Bucketpc
    Inscrit en
    Août 2008
    Messages
    98
    Détails du profil
    Informations personnelles :
    Âge : 36

    Informations forums :
    Inscription : Août 2008
    Messages : 98
    Points : 118
    Points
    118
    Par défaut
    SP1 = Serial Port 1 ?

    Si oui, il y a des APIs qui permettent de communiquer a travers le port serial.

  5. #5
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2006
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Août 2006
    Messages : 61
    Points : 26
    Points
    26
    Par défaut
    SP1 => Site Player 1 ou Web Serveur

  6. #6
    Membre régulier Avatar de Bucketpc
    Inscrit en
    Août 2008
    Messages
    98
    Détails du profil
    Informations personnelles :
    Âge : 36

    Informations forums :
    Inscription : Août 2008
    Messages : 98
    Points : 118
    Points
    118
    Par défaut
    tout simplement, il faut controller ton PIC avec le PC

    Si c'est du 16F alors la control se fait avec le port Sérial, tu le relies avec ton PIC avec un MAX232, par la suite, en fonction de la donné envoyée, le PIC controllera ton matériel.

    Ceci peut être fait avec le port parallèle, mais ... vaut mieux un PIC

  7. #7
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2006
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Août 2006
    Messages : 61
    Points : 26
    Points
    26
    Par défaut
    pas possible de contrôler le PIC à travers le web serveur et ca page HTML ?

    ci joint le schéma de la carte
    Images attachées Images attachées  

  8. #8
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2006
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Août 2006
    Messages : 61
    Points : 26
    Points
    26
    Par défaut
    up

Discussions similaires

  1. Saut de programme incompris avec PIC
    Par arzew dans le forum MPLAB
    Réponses: 1
    Dernier message: 24/05/2011, 15h50
  2. Réponses: 7
    Dernier message: 09/04/2008, 05h13
  3. Comment on connecte un programme Java avec une base de données FireBird?
    Par Gomez dans le forum Connexion aux bases de données
    Réponses: 1
    Dernier message: 16/02/2007, 11h21
  4. Réponses: 3
    Dernier message: 21/11/2006, 18h59

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo