salut...
comment peut-on corriger ce prog afin qu'il puisse mesurer la consommtion de la carte (DUT1 ET DUT2) à travers le pic et affiche le résultat sur l'afficheur lcd .mon compilateur est le mikroc pro for pic que je suis pas familier avec, les erreur sont toujour de declaration de usart_init,lcd_config
ce le code:
//****************************** ****************************** *****************/
//DECLARATION DES VARIABLES GLOBALES
/****************************** ****************************** ******************/
char strInput;
unsigned int i;
unsigned char VAL[4]={'\0','\0','\0','\0'};
unsigned char VAL1[4]={'\0','\0','\0','\0'};
unsigned char msg1[15]={' ',' ',' ',' ','S','A','G','E','M','C','O', 'M',' ',' ',' '};
unsigned char msg2[15]={' ',' ','S','E','R','V','I','C','E', ' ',' ','T','E','S','T'};
void Init_Main()
{
/****************************** ***************/
INTCON=0;//disactivation des interruptions
/****************************** ***************/
ADCON1 = 0x80; // Configure analog inputs and Vref 88
TRISA = 0xFF; // PORTA is input DE PREFERENCE PIN4 "RA02"
TRISD = 0x00; //portD is output
TRISE = 0x00; //portE is output
TRISB = 0x00; //portB is output
PORTD = 0x00; //INITIALISATION PORTD=0
TRISD=0x00; //PORTD IS OUTPUT EXEPTION
Usart_Init(9600); // Configuration du Beaud
Lcd_Config(&PORTD, 1, 3, 2, 7, 6, 5, 4); //EXEPTION
Lcd_Init(&PORTD); // EXEPTION
lcd_cmd(LCD_CLEAR);
lcd_cmd(LCD_CURSOR_OFF);
Delay_ms(500);
}
/****************************** ****************************** ******************/
// FONCTION N°2 DE CONVERSION DECIMALE TO CHAINE DE CARACTERE
/****************************** ****************************** ******************/
void DecToChar (unsigned int ValDec,unsigned char *ValChar)
{
ValChar[0]='0'+(ValDec/1000);
ValChar[1]='0'+(ValDec%1000)/100;
ValChar[2]='0'+((ValDec%1000)%100)/10;
ValChar[3]='0'+((ValDec%1000)%100)%10;
}
/****************************** ****************************** ******************/
//fonction de conversion analogique numerique calcul de COURANT continue
/****************************** ****************************** ******************/
void Courant_DC ()
{
unsigned int valeur=0;
long int accum=0;
unsigned int moy=0;
int k;
for(k=0;k<500;k++)
{
valeur=Adc_Read(0);
valeur=((ADRESH << 8) + ADRESL);
accum=accum+valeur;
}
moy=(accum/500);
DecToChar (moy,VAL);
}
/****************************** ****************************** ******************/
//FONCTION D'AFFICHAGE hyperterminal tension RS232
/****************************** ****************************** ******************/
void hypertension ()
{
Usart_Write(VAL[0]);
Delay_ms(100);
Usart_Write(VAL[1]);
Delay_ms(100);
Usart_Write(VAL[2]);
Delay_ms(100);
Usart_Write(VAL[3]);
}
/****************************** ****************************** ******************/
// FONCTION AFFICHAGE LCD tension
/****************************** ****************************** ******************/
void LCDTENSION ()
{
unsigned char volt;
unsigned int volt_oku;
// char *text;
long tlong;
LCD_Cmd(LCD_CURSOR_OFF);
LCD_Cmd(LCD_CLEAR);
// text = "CURRENT:";
Lcd_Out(1,1,"CURRENT:");
// Lcd_Out(2,1,"POWER:");
volt_oku=Adc_Read(0);
volt_oku=((ADRESH << 8) + ADRESL);
tlong = ((long)volt_oku * 60000) - 10240000;
tlong = tlong /18944 ;
volt = tlong / 1000;
Lcd_Chr(1, 9,48+volt); // X,...
LCD_Chr_CP('.'); // .,...
volt = (tlong / 100)%10;
LCD_Chr_CP(48+volt); // .,X..
volt = (tlong / 10) % 10;
LCD_Chr_CP(48+volt); // .,.X.
volt = tlong % 10;
LCD_Chr_CP(48+volt); // .,..X
Lcd_Out(1,14," A");
Lcd_Cmd(Lcd_CURSOR_OFF);
}
/****************************** ****************************** ******************/
//PROGRAMME PRINCIPAL
/****************************** ****************************** ******************/
void main()
{
Init_Main();
/*
for (i=0;i<=15;i++){
lcd_chr_cp(msg1[i]);
delay_ms(100);
}
Lcd_Cmd(LCD_SECOND_ROW);
for (i=0;i<=15;i++){
lcd_chr_cp(msg2[i]);
delay_ms(100);
}
delay_ms(1000);
lcd_cmd(LCD_CLEAR);
*/
// Lcd_Chr(1, 1,'A');
// lcd_chr_cp('&');
// lcd_chr_cp('S');
// lcd_chr_cp(msg2[i]);
// lcd_chr_cp(msg2[i]);
while(1)
{
if (Usart_Data_Ready())// If data is received
{
strInput = Usart_Read();
switch (strInput)
{
case '2': // DUT2
intcon=0x00;// disactivation d'interruption
/* PORTD.F0=1;
PORTD.F1=1;
PORTD.F2=0;
PORTD.F3=0; */
Courant_DC ();
hypertension ();
LCDTENSION();
break;
case '1': // DUT1
intcon=0x00;// disactivation d'interruption
/*PORTD.F0=0;
PORTD.F1=0;
PORTD.F2=0;
PORTD.F3=0; */
Courant_DC ();
hypertension ();
LCDTENSION();
break;
}
}
}
}
pleaaaaase help.
-----