Pages

Salut sujet

vendredi 28 mars 2014




j'ai programmé en Micro C commande du moteur pas à pas unipolaires avec afficheur sur ecran LCD du nombre de pas et j'ai trouvé un problème dés que le moteur s'arrête l'afficheur afficheur le nombre de pas. Aidez- moi s'il vous plait à ce problème et vous me dites d'aprés mon programme l'afficheur doit affiché la séquence de pas 01 2 3 ou bien 1 2 4 8. et merci d'avance.


sbit LCD_RS at RC0_bit;
sbit LCD_EN at RC1_bit;
sbit LCD_D4 at RC2_bit;
sbit LCD_D5 at RC3_bit;
sbit LCD_D6 at RC4_bit;
sbit LCD_D7 at RC5_bit;


sbit LCD_RS_Direction at TRISC0_bit;
sbit LCD_EN_Direction at TRISC1_bit;
sbit LCD_D4_Direction at TRISC2_bit;
sbit LCD_D5_Direction at TRISC3_bit;
sbit LCD_D6_Direction at TRISC4_bit;
sbit LCD_D7_Direction at TRISC5_bit;
unsigned int adc;
unsigned int txt[4];
unsigned int txt00[4];
unsigned char txt0[] = "Stepper Motor";
unsigned char txt2[] = "Nbre pas:";
unsigned char Tab[4];

void Init_PIC(void);
void Init_LCD(void);
void Move_Moteur_Droite( unsigned int nbre_pas, unsigned int temps);
void Move_Moteur_Gauche(void);
void Affiche_Intro_LCD(void);
void Conversion_Tab_Entier(void);


void main()
{

Init_PIC();
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);


Lcd_Out(1, 3, txt0);
delay_ms(500);


delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);

Lcd_Out(1, 2, txt2);
while(1){
adc = Tab[(i%4)];
i++;
inttostr(adc,txt2);
Lcd_Out(1, 13, txt2);
Delay_ms(200);
}
}
void Init_PIC(void)
{
TRISB=0x00;
TRISC=0x00;
PORTB=0x00;
PORTC=0x00;
Tab[0]=1;
Tab[1]=2;
Tab[2]=4;
Tab[3]=8;
for(i=0; i<24; i++)
{
PORTB=Tab[i%4];
PORTC=Tab[i%4];
Delay_ms(200);
}
}
void Move_Moteur_Droite(unsigned int Nbre_Pas, unsigned int temps)
{
unsigned char i;


for(i = 0; i < 24; i++)
{


PORTC = Tab[i%4];
Delay_ms(200);



}

}




Aucun commentaire:

Enregistrer un commentaire