CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

capacimetre *** Locked

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
fure88



Joined: 29 May 2012
Posts: 1

View user's profile Send private message

capacimetre *** Locked
PostPosted: Tue May 29, 2012 10:16 am     Reply with quote


+++++++++++++++++++++
Locked.

Reason: Please use English on the CCS forum.

La langue de ce forum est l'anglais.
S'il vous plaît utiliser le traducteur de Google pour convertir votre explication à l'anglais.
http://translate.google.com
Ne pas poser des questions dans le Forum Code Library.
Poster questions dans le forum de discussion général.

- Forum Moderator
+++++++++++++++++++++


bonjour,
je suis un débutant au CCS, j'ai le projet "capacimètre".
mon programme consiste à calculer la période à l'entré du CCP1 puis déduire la taille de la capacité( T=ln2*C*(R1+2R2))
malheureusement mon programme ne fonctionne pas, il affiche une fausse valeur.
aider moi svp!!!
[#include "18F2550.h"
#device ADC=10
#use delay(clock=20M)
#byte CCP1CON=0xFBD
#word TMR1=0x0FC
#byte PORTB=0xF81
#byte TRISB=0xF93
#byte PORTC=0xF82
#byte TRISC=0xF94
#bit RC0=PORTC.0
#bit RC1=PORTC.1
#bit RC6=PORTC.6
#bit RC7=PORTC.7
int i;
char calibre='f',text[3]="C=",val[6];
float const log2=0.6931471805599453;
float C=0;
int32 T=0;
#int_ccp1
void front_montant()
{float ancien=0;
T=CCP_1-ancien;
ancien=CCP_1;
}

////// commande d'affichage sur LCD///////////
void envoie_commande(int commande)
{
RC6=0; //RS=0 ==> mode commande
PORTB=commande;
RC7=1; //Enable ==> lecture de la commande
delay_us(80); // temps necessaire pour l'execution de la commande
RC7=0; // fin du mode commande
}
void init_LCD (void)
{
delay_ms(20); // temps de 20 ms necessaire pour demarrer le LCD
envoie_commande(0x3C); //8bit 2 lignes 5*10character
delay_ms(5);
envoie_commande(0x0C);// affichage ON, Curseur Off, Blink Off
envoie_commande(0x01); // efface lCD
delay_ms(5);
}
void aff_LCD(char text)
{
RC6=1; //RS=1 ==> mode ecriture
delay_us(80);
PORTB=text;// ==> envoie code ASCII du caractère
RC7=1;//Enable ==> lecture de la commande
delay_us(80);// temps necessaire pour l'execution de la commande
RC7=0;// fin du mode ecriture
}
///////////////////////////////////////////
void calcul_temps(void)
{
front_montant();
}
void calcul_cap(void)
{
C=T/(log2*200000);//R1+2R2=200000
if(C<=1)
{ C=C*1000.0
calibre='p';
}
else
{
calibre='n';
}
}
void affichage(void)
{
sprintf(val,"%6.2f",C);
envoie_commande(0x83);
for(i=0;i<6;i++) aff_LCD(val[i]);
envoie_commande(0x8A);
aff_LCD(calibre);
}

void main(void)
{
TRISB=0x00;// portb est lié à LCD
TRISC=0b00111110;///
RC0=1;/// alimentation du timer 555
init_LCD();
envoie_commande(0x80);
for(i=0;i<2;i++) aff_LCD(text[i]);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8 );
enable_interrupts(INT_TIMER1);
setup_ccp1(CCP_CAPTURE_FE);
enable_interrupts(INT_CCP1);
enable_interrupts(GLOBAL);
while(true)
{
calcul_temps();
calcul_cap();
affichage();
}
}]
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue May 29, 2012 10:40 am     Reply with quote

I understand a little of your post, the forum language is English.

Post a schematic of the relevant components.

Mike
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group