Besoin d'aide programmation mikroC pro
Répondre à la discussion
Affichage des résultats 1 à 3 sur 3

Besoin d'aide programmation mikroC pro



  1. #1
    invitec927b324

    Thumbs up Besoin d'aide programmation mikroC pro


    ------

    Bonjour,

    J'ai un projet je veut l'améliorer par l'ajout d'un thermomètre.. et faire une liaison RS232.
    La fonction faite est testé elle permet de vérifier l'état actuel du moteur (fonction déja faite et testé et simulé)..
    La liaison RS232 me permet de lire la température en VB.NET ainsi l'état actuel de moteur
    voici çi joint mon projet:
    #########################
    Fichiers hébergés sur serveur externe supprimée
    Merci de suivre ces consignes

    -----
    Dernière modification par Jack ; 17/05/2012 à 23h32.

  2. #2
    invitec927b324

    Re : Besoin d'aide programmation mikroC pro

    VOICI LE CODE à améliorer

    sbit LCD_RS at RB0_bit;
    sbit LCD_EN at RB1_bit;
    sbit LCD_D4 at RB2_bit;
    sbit LCD_D5 at RB3_bit;
    sbit LCD_D6 at RB4_bit;
    sbit LCD_D7 at RB5_bit;
    sbit LCD_RS_Direction at TRISB0_bit;
    sbit LCD_EN_Direction at TRISB1_bit;
    sbit LCD_D4_Direction at TRISB2_bit;
    sbit LCD_D5_Direction at TRISB4_bit;
    sbit LCD_D6_Direction at TRISB2_bit;
    sbit LCD_D7_Direction at TRISB5_bit;


    char *txt1 = "vitesse 3 ok";
    char *txt2 = "vitesse 1 ok";
    char *txt3 = "vitesse 2 ok";
    char *txt4 = "insuffisant";
    char *txt5 = "VK140";
    char *txt6 = "Test Station";
    unsigned int mesure_tension_precision(unsig ned short channel)
    {
    unsigned int result_tension;
    char a,i;
    int Tab_tension[10];
    Tab_tension[0]=0;
    result_tension=0;
    for (a=0,i=0;a<9;a++,i++)
    {
    result_tension = Adc_Read(0);
    Delay_ms(5);
    Tab_tension[i] = result_tension;
    if (i==9)
    {
    while(i>0)
    {
    i--;
    result_tension = (result_tension + Tab_tension[i])/2;
    }
    }
    Delay_ms(10);
    }
    return(result_tension);
    }


    ///****************************** ****************************** ******************/
    ///************** conversion des niveaux (V) en nbre d'échantillons ***********/
    ///* nivo1=4.7V -> (5V -> 1024 bits) => 4.7V -> (1024*4.7) /5 = 962 ech.
    // nivo2=3.42V -> (5V -> 1024 bits) => 3.42V -> (1024*3.42)/5 = 700 ech.
    // nivo1=1.7V -> (5V -> 1024 bits) => 1.7V -> (1024*1.7) /5 = 348 ech.
    ///****************************** ****************************** ******************/
    void aff_niveaux(void) //niv1=4.7v ; niv2=3.42v ; nivo3=1.7v
    {
    unsigned int nivo_1 = 348, nivo_2 = 700, nivo_3 = 962, mes ;

    mes = mesure_tension_precision(0); // mesure tension sur canal ADC An0
    if (mes >= nivo_3)
    Lcd_Out(1, 3, txt1);
    delay_ms(300);
    if (mes >= nivo_2 && mes < nivo_3)
    Lcd_Out(1, 3, txt2);
    delay_ms(300);
    if (mes >= nivo_1 && mes < nivo_2)
    Lcd_Out(1, 3, txt3);
    delay_ms(300);
    if (mes < nivo_1)
    Lcd_Out(1, 3, txt4);
    delay_ms(300);
    }
    void welcome_msg()
    {
    Lcd_Out(1, 6, txt5);
    Lcd_Out(2, 3, txt6);
    delay_ms(1500);
    Lcd_Cmd(_LCD_CLEAR);

    }

    void main()
    {
    TRISA = 0xFF;
    TRISB = 0x00;
    ADCON1 = 0x8E; // Configure analog input A0 et le reste en digital (Vref+=Vdd / Vref-=Vss)
    Lcd_Init(); // Initialise LCD
    do
    {
    Lcd_Cmd(_LCD_CLEAR); // Clear display
    Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
    //init_pic();
    welcome_msg();
    delay_ms(1000);
    aff_niveaux();
    delay_ms(5000);
    Lcd_Out(2, 1, "Reset");
    delay_ms(5000);
    }
    while (1);
    }

  3. #3
    invitec927b324

    Re : Besoin d'aide programmation mikroC pro

    J'ai le code suivant d'un thermomètre affiché en 7 segments je veut la concaténer dans un seul code avec le code précédent:
    //----------------------------------------------------------------------------------------------------------
    //define the table of constant 0-9 (mask)
    const char TABLE[]={0xC0,0xF9,0xA4,0xB0,0x99,0x9 2,0x82,0xF8,0x80,0x90};
    unsigned int result=0x00; //define ADC convert result register
    unsigned short i; // for loop counter

    void init(); //I/O PORT initialize function declare
    void display(int result); //display function declare

    //---------------------------------------------------------------------------------------------------------------
    //main program
    void main()
    {
    init(); //call initialize function
    while(1)
    {
    result=0x00; //clear the convert result
    result = ADC_Read(0);// read and stor ADCresult as "0-1023"
    //result=result/2; // covert from "0-1023" to "temperature in degree
    result=result/2.05; // exact conversion from "0-1023" to "temperature in degree
    display(result); //call display function

    }
    }
    //-----------------------------------------------
    //initialize function

    void init()
    {
    ADCON1=0X8E; //set RA0 pin > ADC input ,the others general I/O
    TRISA=0X01; //set RA0 INPUT,the others OUTPUT
    TRISD=0X00; //set D PORT all OUTPUT
    TRISB.B0=0; //For LED
    TRISC.B2=0; //For Buzzer
    PORTD=0XFF; //close all display
    }
    //-----------------------------------------------
    //display function
    void display(int result)
    {
    int TEN,ONE,temp; //define 3 temporary variable
    temp=result; //temporary keep AD convert result
    TEN = temp/10 ; //get display tens bit
    ONE = (temp % 10) ; //get display ones bit
    //-----------------------------
    for (i = 0; i<=50; i++) {

    PORTD=TABLE[TEN]; //get the display tens bit code from table
    PORTA=0x2F; //RA4 OUTPUT low,light tens bit display
    Delay_ms(1); //delay some time,ensure display brightness

    PORTD=TABLE[ONE]; //get the display ones bit code from table
    PORTA=0x1F; //RA5 OUTPUT low,light ones bit display
    Delay_ms(1); //delay some time,ensure display brightness
    }
    //-------------------------------------------
    }


    SVP c'est urgent

Discussions similaires

  1. besoin d'aide (microcontroleur - mikroc)
    Par blacklord70 dans le forum Électronique
    Réponses: 5
    Dernier message: 20/04/2012, 23h45
  2. besoin d'aide [programmation en C]
    Par invite39a3aa53 dans le forum Programmation et langages, Algorithmique
    Réponses: 1
    Dernier message: 29/03/2011, 22h04
  3. {MikroC} Besoin d'aide pour petit programme
    Par invite3e8637a7 dans le forum Électronique
    Réponses: 4
    Dernier message: 09/02/2010, 10h00
  4. besoin d'aide programmation en c
    Par invitef04611f7 dans le forum Logiciel - Software - Open Source
    Réponses: 4
    Dernier message: 29/04/2009, 13h39
  5. Besoin d'aide programmation C/C++
    Par invite39b52509 dans le forum Logiciel - Software - Open Source
    Réponses: 6
    Dernier message: 11/12/2008, 20h28
Découvrez nos comparatifs produits sur l'informatique et les technologies.