//rev 19/09/2024 void Dialogue_NEMA(void) { RAZ_UART1_Buffer1(); // et arme interrupt UART RX __delay_ms(1000); if(Flag_Buffer1==1) { CPrint("Recu :"); Print(Buffer1); CRLF1(); p0=&Buffer1[0]; if ( (*(p0)=='H') && (*(p0+1)=='e') && ( *(p0+2)=='l') && ( *(p0+3)=='p') ) { CPrint("\r\n Help Commandes : Help\r\n"); CPrint(" Mod=x avec x=0=> Keyboard, x=1 Potar\r\n"); CPrint(" pour Marche pour Arret ( Enable)\r\n"); CPrint(" Frequence F=xxxx avec xxxx = 0006 \0xE0 6000\r\n"); CPrint(" Sens de rotation pour Horaire pour Trigo \r\n"); CPrint(" RAZ pour RAZ du comprteur d eTour Count_RB0\r\n"); CPrint(" BAV=02 print datas asynchrone\r\n"); CPrint(" BAV=04 print at interrupt RB0\r\n"); CPrint(" BAV=00 pas de print\r\n"); //CPrint(" valeur PWM 0 à 10123 P=xxxx \r\n"); CPrint(" Help \r\n"); Print(Buffer1); CRLF1(); p0=0 ; } // Sens de rotation if (*(p0)=='H') { NEMA_Rotation=0; Sens_Rotation=0; //Horaire p0=0; } if (*(p0)=='T') { Sens_Rotation=1; // trigo NEMA_Rotation=1; p0=0; } // Mod=0 Keyboard 1=Potar if ((*(p0)=='M') && (*(p0+1)=='o') && ( *(p0+2)=='d') && ( *(p0+3)=='=') ) { if (*(p0+4)=='1') { Mode_Cde=1 ; //mode de commande moteur CPrint("\r\n Mode commande moteur: Mod=0 -> Keyboard , Mod=1 -> Potar sur RA1\r\n"); CPrint(" Potar au milieu = Arret moteur\r\n"); CPrint(" Potar à doite (vers le maxi) Sens Horaire et Freq proportionelle\r\n"); CPrint(" Potar à gauche(vers le mini) Sens Trigo et Freq proportionelle\r\n"); p0=0; } else { Mode_Cde=0 ; // via Keyboard CPrint("\r\n Mode commande = Keyboard terminal\r\n"); CPrint("Valeur de Frequence au clavier F=xxxx avec xxxx de 0006 \0xE0 9999 Hz\r\n"); p0=0; } } if(Mode_Cde==0) {// cde Frequences Clck F=1234 en HZ pour sortie NCO1 de 200 à 1999 if ( (*(p0)=='F') && (*(p0+1)=='=')&& (strlen(p0)==6 ) ) { if ( isdigit(*(p0+2)) && isdigit(*(p0+3)) && isdigit(*(p0+4)) && isdigit(*(p0+5)) ) { cx=*(p0+2)-48; k=(uint16_t)cx*1000; cx=*(p0+3)-48; k= k+ (uint16_t)cx*100; cx=*(p0+4)-48; k= k+ (uint16_t)cx*10; cx=*(p0+5)-48; k= k+ (uint16_t)cx; if((k>199) && (k<6001)) { // rappel // F0= (NCO1_Clock[NCO1_Clock_Choix] * (float)Increment ) / 2097152.0 ; F0=(float)k ; Increment= F0 * 2097152.0 / NCO1_Clock[NCO1_Clock_Choix]; sprintf(CRam1,"\r\n New Freq =%5d New Increment=%ul\r\n",k,Increment); Print(CRam1); if(NEMA_Enable==1) { NCO1CONbits.NCO1EN=0; NCO1INCU= *(pI+2); NCO1INCH= *(pI+1); NCO1INCL= *(pI+0); NCO1CONbits.NCO1EN=1; // enable } } } else CPrint(" Error saisie F=0100 \0xE0 6000\r\n"); p0=0; } } // if Mode_Cde==0 // cde BAVard xx=00 à 19 if ((*(p0)=='B') && (*(p0+1)=='A') && ( *(p0+2)=='V') && ( *(p0+3)=='=')&& (*(p0+6)==0) ) { if( isdigit(*(p0+4)) && isdigit(*(p0+5)) ) // 00 à 99 { // 31-08-2024 cx=*(p0+4); Bavard=(cx-48)*10; cx=*(p0+5); Bavard=Bavard + cx-48; } else { Bavard=0; CPrint("\r\n Erreur saisie valeur de Bavard \r\n"); } p0=0; } if ( (*(p0)=='R') && (*(p0+1)=='E') && ( *(p0+2)=='S') && ( *(p0+3)=='E') && ( *(p0+4)=='T') ) { if(strlen(p0)==5) { CPrint("\r\n Reset volontaire \r\n"); p0=0; NCO1CONbits.NCO1EN=0; // disable __delay_xSec(4); NEMA_Enable=0; NEMA_Rotation=0; // horaire Reset(); } p0=0; } if (*(p0)=='M') { NEMA_Enable=1; NCO1CONbits.NCO1EN=1; // enabled T4CONbits.T4ON=1; Duree_Tour=0 ; Old_Cpt2=0; T2CONbits.T2ON=1; p0=0; } if (*(p0)=='A') { NEMA_Enable=0; NCO1CONbits.NCO1EN=0; // disable T4CONbits.T4ON=0; T2CONbits.T2ON=0; p0=0; } if ((*(p0)=='R') && (*(p0+1)=='A') && ( *(p0+2)=='Z') ) { Old_Count_RB0=0; Count_RB0=0; Distance=0; p0=0; } } //if flag }