perturbation sur un signal (PWM)
Répondre à la discussion
Affichage des résultats 1 à 6 sur 6

perturbation sur un signal (PWM)



  1. #1
    invite24219bec

    perturbation sur un signal (PWM)


    ------

    j'ai une problème dans mon code et j'arrive pas a comprendre la problème exactement . il y a une perturbation sur la signal PWM . Lorsque j’exécute que la partie de signal ,il n'a y pas une problème mais lorsque j'ajoute la suite de mon programme il y a une problème . Avez vous une idée svp

    -----

  2. #2
    luc_1049

    Re : perturbation sur un signal (PWM)

    bonjour

    Regardez les sources d'interruption sont elles bien gérées, autrement dit considérez tout ce qui peut interrompre votre programme ?

    Dites en plus sinon sur votre programme que fait il ?
    Vérifiez aussi qu'aucune condition de reset n'est enclenché, par exemple watchdog ou reset si chute de l'alimentation consécutive à un mauvais découplage ou une alimentation faible ne fournissant pas assez de courant...

    cdlt

  3. #3
    invite24219bec

    Re : perturbation sur un signal (PWM)

    Merci pour votre aide mon code pour but:

    1) lire 6 valeurs de température sur AN0.... AN5 , 3 températures réelles et 3 températures consignes, comparer la valeur réelle a la valeur consigne si elle est < la LED sera allumée et afficher les 6 valeurs avec afficheur LCD. j'ai terminé cette partie il n'y a pas aucune problème.
    2) variation d'un signal PWM par une tension analogique j'utilise AN6 pour lire la tension (état on de signal). j'ai terminé cette partie il n'y a pas aucune problème aussi . Mais la problème lorsque j’exécute les deux parte ensemble, il y a une perturbation . j'ai bien vérifier la configuration des registres mais je ne peux pas trouver la solution . je peux vous envoyer mon code est ce que vous pouvez m'aider et merci d'avance

  4. #4
    luc_1049

    Re : perturbation sur un signal (PWM)

    Bonsoir

    Vous pouvez par dichotomie trouvez votre bug, en supprimant le reste de votre code et en ajoutant une partie au fur et à mesure en faisant des essais progressivement.

    Mais je pense que vous devriez déja relire votre code à tête reposée, utiliser le debugger pour voir les valeurs des registres.

    Vérifiez en particulier dans votre soft que vous faites bien les bons masques et opérations lorsque vous modifiez les valeurs des registres.
    Utilisation de valeur reflet du port micro , de valeur volatile si besoin, ...

    cdlt

  5. A voir en vidéo sur Futura
  6. #5
    invite24219bec

    Re : perturbation sur un signal (PWM)

    sbit LCD_RS at RB2_bit ;
    sbit LCD_EN at RB3_bit;
    sbit LCD_D4 at RB4_bit;
    sbit LCD_D5 at RB5_bit;
    sbit LCD_D6 at RB6_bit;
    sbit LCD_D7 at RB7_bit;
    sbit LCD_RS_Direction at TRISB2_bit;
    sbit LCD_EN_Direction at TRISB3_bit;
    sbit LCD_D4_Direction at TRISB4_bit;
    sbit LCD_D5_Direction at TRISB5_bit;
    sbit LCD_D6_Direction at TRISB6_bit;
    sbit LCD_D7_Direction at TRISB7_bit;
    unsigned char msgZ1[20],msgZ2[20],msgZ3[20],msgZ6[20];
    unsigned char consigneZ1[20],consigneZ2[20],consigneZ3[20];
    unsigned int adc_rdZ1 , adc_rdZ2,adc_rdZ3,valeur6;
    unsigned int adc_rdconsZ1,adc_rdconsZ2,adc_ rdconsZ3;
    float tZ1=0,tZ2=0,tZ3=0,pourcent=0;
    float TconsZ1=0,TconsZ2=0,TconsZ3=0;
    unsigned int signe;
    unsigned int cycle=0;
    unsigned int periode=0;
    void init(){
    T0IF_bit= 0;
    TRISA=0XFF;
    TRISB=0X00;
    TRISD=0XFF;
    TRISE &= 0b11110111; // Met à 0 le bit PSPMODE
    TRISE |=0b00000111; //Met à 1 les 3 premiers bi
    TRISC=0X00;
    PORTD=0X00;
    ADCON0=0b111111001;
    ADCON1=0b00000000;
    Lcd_Init();
    Lcd_Cmd(_LCD_CURSOR_OFF);
    Lcd_Cmd(_LCD_CLEAR);
    Lcd_Out(1, 1, "ZX:Tconsgne Treel");
    Lcd_Out(2, 1, "Z1:");
    Lcd_Out(3, 1, "Z2:");
    Lcd_Out(4, 1, "Z3:");
    }
    // partie 1 : lire et affichage de temp
    void rabiaa() {
    tZ1=(adc_rdZ1*0.004882*1000*12 00)/(71.94244*69.5) ;
    floattostr(tZ1,msgZ1);
    TconsZ1=(adc_rdconsZ1*0.004882 *500)/(5) ;
    floattostr(TconsZ1,consigneZ1) ;
    tZ2=(adc_rdZ2*0.004882*1000*12 00)/(71.94244*69.5) ;
    floattostr(tZ2,msgZ2);
    TconsZ2=(adc_rdconsZ2*0.004882 *500)/(5) ;
    floattostr(TconsZ2,consigneZ2) ;
    tZ3=(adc_rdZ3*0.004882*1000*12 00)/(71.94244*69.5) ;
    floattostr(tZ3,msgZ3);
    TconsZ3=(adc_rdconsZ3*0.004882 *400)/(5) ;
    floattostr(TconsZ3,consigneZ3) ;
    }
    void affichage(){
    if (PORTD.F6==0){
    Lcd_Out(2,4, consigneZ1);
    Lcd_Out(2,13, msgZ1);}
    Lcd_Out(3,4, consigneZ2);
    Lcd_Out(3,13, msgZ2);
    Lcd_Out(4,4, consigneZ1);
    Lcd_Out(4,13, msgZ3);
    delay_ms(2000); }
    void affichagemanuelle(){
    Lcd_Cmd(_LCD_CLEAR);
    if (PORTD.F6==0){
    Lcd_Out(2,4,"affichage");
    Lcd_Out(3,4, consigneZ2);
    Lcd_Out(3,13, msgZ2);
    Lcd_Out(4,4, consigneZ1);
    Lcd_Out(4,13, msgZ3);
    delay_ms(2000); }
    }
    void condition(){
    if(tZ1 < TconsZ1) PORTC.F7=1; else PORTC.F7=1;
    if(tZ2 < TconsZ2) PORTC.F5=1; else PORTC.F5=1;
    if(tZ3 < TconsZ2) PORTC.F4=1; else PORTC.F4=1; }

    // PARTIE PWM
    void InitTimer0(){
    OPTION_REG= 0x88;
    TMR0 = 254;
    INTCON= 0xA0;}
    void mars(){
    if (portd.f6==1) {
    cycle--;
    if(cycle==0){RC6_bit=0;}
    periode--;
    if(periode==0){
    RC6_bit=1 ;
    periode=1000; //4/4
    cycle=signe; //3/4
    TMR0= 254;
    }} }
    void Interrupt(){ // il se repéte chaque 1us ( tu peux avoir Ton de 0% 1000% de resolution 1000)
    mars();
    T0IF_bit= 0;
    }
    // fin de partie PWM

    void main()
    {
    init();
    InitTimer0();
    while(1)
    {

    adc_rdZ1=ADC_read(0); delay_ms(20);
    adc_rdconsZ1=ADC_read(1); delay_ms(20);
    adc_rdZ2=ADC_read(2); delay_ms(20);
    adc_rdconsZ2=ADC_read(3); delay_ms(20);
    adc_rdZ3=ADC_read(4); delay_ms(20);
    adc_rdconsZ3=ADC_read(5); delay_ms(20);
    signe=ADC_read(6); delay_ms(20);
    signe=signe/100;
    rabiaa();
    affichage ();
    condition();
    }
    }

  7. #6
    invite24219bec

    Re : perturbation sur un signal (PWM)

    nn voila j’envoie un code incorrecte voila le code juste :
    sbit LCD_RS at RB2_bit ;
    sbit LCD_EN at RB3_bit;
    sbit LCD_D4 at RB4_bit;
    sbit LCD_D5 at RB5_bit;
    sbit LCD_D6 at RB6_bit;
    sbit LCD_D7 at RB7_bit;
    sbit LCD_RS_Direction at TRISB2_bit;
    sbit LCD_EN_Direction at TRISB3_bit;
    sbit LCD_D4_Direction at TRISB4_bit;
    sbit LCD_D5_Direction at TRISB5_bit;
    sbit LCD_D6_Direction at TRISB6_bit;
    sbit LCD_D7_Direction at TRISB7_bit;
    unsigned char msgZ1[20],msgZ2[20],msgZ3[20],msgZ6[20];
    unsigned char consigneZ1[20],consigneZ2[20],consigneZ3[20];
    unsigned int adc_rdZ1 , adc_rdZ2,adc_rdZ3,valeur6;
    unsigned int adc_rdconsZ1,adc_rdconsZ2,adc_ rdconsZ3;
    float tZ1=0,tZ2=0,tZ3=0,pourcent=0;
    float TconsZ1=0,TconsZ2=0,TconsZ3=0;
    unsigned int signe;
    unsigned int cycle=0;
    unsigned int periode=0;
    void init(){
    T0IF_bit= 0;
    TRISA=0XFF;
    TRISB=0X00;
    TRISD=0XFF;
    TRISE &= 0b11110111; // Met à 0 le bit PSPMODE
    TRISE |=0b00000111; //Met à 1 les 3 premiers bi
    TRISC=0X00;
    PORTD=0X00;
    ADCON0=0b111111001;
    ADCON1=0b00000000;
    Lcd_Init();
    Lcd_Cmd(_LCD_CURSOR_OFF);
    Lcd_Cmd(_LCD_CLEAR);
    Lcd_Out(1, 1, "ZX:Tconsgne Treel");
    Lcd_Out(2, 1, "Z1:");
    Lcd_Out(3, 1, "Z2:");
    Lcd_Out(4, 1, "Z3:");
    }
    // partie 1 : lire et affichage de temp
    void rabiaa() {
    tZ1=(adc_rdZ1*0.004882*1000*12 00)/(71.94244*69.5) ;
    floattostr(tZ1,msgZ1);
    TconsZ1=(adc_rdconsZ1*0.004882 *500)/(5) ;
    floattostr(TconsZ1,consigneZ1) ;
    tZ2=(adc_rdZ2*0.004882*1000*12 00)/(71.94244*69.5) ;
    floattostr(tZ2,msgZ2);
    TconsZ2=(adc_rdconsZ2*0.004882 *500)/(5) ;
    floattostr(TconsZ2,consigneZ2) ;
    tZ3=(adc_rdZ3*0.004882*1000*12 00)/(71.94244*69.5) ;
    floattostr(tZ3,msgZ3);
    TconsZ3=(adc_rdconsZ3*0.004882 *400)/(5) ;
    floattostr(TconsZ3,consigneZ3) ;
    }
    void affichage(){
    Lcd_Out(2,4, consigneZ1);
    Lcd_Out(2,13, msgZ1);
    Lcd_Out(3,4, consigneZ2);
    Lcd_Out(3,13, msgZ2);
    Lcd_Out(4,4, consigneZ1);
    Lcd_Out(4,13, msgZ3);
    delay_ms(2000); }

    void condition(){
    if(tZ1 < TconsZ1) PORTD.F7=1; else PORTC.F7=1;
    if(tZ2 < TconsZ2) PORTD.F5=1; else PORTC.F5=1;
    if(tZ3 < TconsZ2) PORTD.F4=1; else PORTC.F4=1; }

    // PARTIE PWM
    void InitTimer0(){
    OPTION_REG= 0x88;
    TMR0 = 254;
    INTCON= 0xA0;}
    void mars(){
    if (portc.f5==1) {
    cycle--;
    if(cycle==0){RC6_bit=0;}
    periode--;
    if(periode==0){
    RC6_bit=1 ;
    periode=1000; //4/4
    cycle=signe; //3/4
    TMR0= 254;
    }} }
    void Interrupt(){ // il se repéte chaque 1us ( tu peux avoir Ton de 0% 1000% de resolution 1000)
    mars();
    T0IF_bit= 0;
    }
    // fin de partie PWM

    void main()
    {
    init();
    InitTimer0();
    while(1)
    {

    adc_rdZ1=ADC_read(0); delay_ms(20);
    adc_rdconsZ1=ADC_read(1); delay_ms(20);
    adc_rdZ2=ADC_read(2); delay_ms(20);
    adc_rdconsZ2=ADC_read(3); delay_ms(20);
    adc_rdZ3=ADC_read(4); delay_ms(20);
    adc_rdconsZ3=ADC_read(5); delay_ms(20);
    signe=ADC_read(6); delay_ms(20);
    signe=signe/100;
    rabiaa();
    affichage ();
    condition();
    }
    }

Discussions similaires

  1. Perturbation d'un signal
    Par invite3ef5285d dans le forum Électronique
    Réponses: 4
    Dernier message: 22/03/2013, 15h32
  2. Perturbation radio
    Par BastienBastien dans le forum Électronique
    Réponses: 3
    Dernier message: 11/11/2012, 11h01
  3. perturbation électromagnétique.
    Par invitefba467f4 dans le forum Physique
    Réponses: 3
    Dernier message: 30/09/2010, 19h30
  4. Perturbation d'orbite
    Par invite0172d289 dans le forum Physique
    Réponses: 3
    Dernier message: 14/06/2007, 19h52
  5. Traitement par perturbation en RG
    Par inviteccb09896 dans le forum Physique
    Réponses: 1
    Dernier message: 03/02/2007, 21h42
Dans la rubrique Tech de Futura, découvrez nos comparatifs produits sur l'informatique et les technologies : imprimantes laser couleur, casques audio, chaises gamer...