Hallo ,
Ich versuche aus dem Signal der 2 Gabellichtschranken mein Motor die
Richtung zu definieren es klappt nicht, würde hier jemanden mir helfen ,
Bitte. hier si mein code mit Signal dbei L1 und L2
while ( 1 )
{
// Taste wird gedückt
if((state==1)&&((!(FIO2PIN &(1<<10)))||(running == 1)))
{
running = 1;
Motor_Forward(4);
// Count IncommingImpuls and Stop
if((FIO2PIN & (1<<12))) //P2.12 (H)
{
if((FIO4PIN & (1<<12))&&!(FIO2PIN & (1<<12)))
{
NumImp++;
while((FIO4PIN & (1<<12))&&!(FIO2PIN & (1<<12))){}
if(NumImp == 10) // After 10 Impuls Stop
{
//Save Current Impuls
OldNumImpF = NumImp;
PWM_Stop(4) ;
state = 2;
NumImp = 0;
running = 0;
}
}
}//
}
//current state of P2.10 is Low
if((state==2)&&((!(FIO2PIN &(1<<10)))||(running == 1)) )
{
running = 1; Motor_Backward(4);
// P0.4 &&P0.2 are all high
if((FIO4PIN & (1<<12))&&(FIO2PIN & (1<<12)))
{
if(!(FIO4PIN & (1<<12))) //P4.12 ist low
{
NumImp++;
while(!(FIO4PIN & (1<<12))) {}
if(NumImp == 10) // After 10 Impuls Stop
{
//Save Current Impuls
OldNumImpB = NumImp;
PWM_Stop(4);
state = 1;
NumImp = 0;
running = 0;
}
}
}
}
} //end of statement
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.
