1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| sbit TRIPODE at RC2_bit;
sbit TRIPODE_Direction at TRISC2_bit;
sbit A at RC4_bit;
sbit A_Direction at TRISC4_bit;
sbit B at RC5_bit;
sbit B_Direction at TRISC5_bit;
sbit Passage_OK at RC0_bit;
sbit Passage_OK_Direction at TRISC0_bit;
sbit CDE_ELECTROAIMANT at RA0_bit;
sbit CDE_ELECTROAIMANT_Direction at TRISA0_bit;
void main() {
unsigned char Fin_Cycle;
/************ Configuration des ports utilisés en I/O numériques ********/
ANSEL = 0;
CMCON0 = 7;
/********** Configuration (sens de transfert) des entrées numériques *****/
A_Direction = ?;
B_Direction = ?;
TRIPODE_Direction = ?;
/********** Configuration (sens de transfert) des sorties numériques *****/
CDE_ELECTROAIMANT_Direction = TRISA0_bit;
Passage_OK_Direction = TRISC0_bit;
CDE_ELECTROAIMANT = RA0_bit?;
Passage_OK = TRISC0_bit;
Delay_ms(2000);
while(1){
Fin_Cycle = 0;
while(TRIPODE == RC2_bit);
do{
CDE_ELECTROAIMANT = RA0_bit;
while (!(A == && B == ); // Attente de la Phase 1
CDE_ELECTROAIMANT = RA0_bit; // Deverouillage
while (A == && B == ); // Phase 1 attente phase suivante
if (!(A == ? && B == ?)) // Test verification passage à la phase 2
{
continue; // Retour au verouillage
}
while (A == ? && B == ?); // Phase 2 attente phase suivante
if (!(A == ? && B == ?)) // Test verification passage à la phase 3
{
continue; // Retour au verouillage
}
while (A == ? && B == ?); // Phase 3 attente phase suivante
if (!(A == ? && B == ?)) // Test verification passage à la phase 1
{
continue; // Retour au verouillage
}
Fin_Cycle = 1;
}while (??);
CDE_ELECTROAIMANT = ?;
Passage_OK = ?;
Delay_ms(1000);
Passage_OK = ?;
}
} |
Partager