So here is the deal
i am making an aplication to measure cycle time of the machine states in a manufacturing process..
my arduino will do a bunch of stuff and will have portC as input always reading between 0,1,2,3,4,5.. machine states...
....
to simulate my code i have another arduino just jumping from state 0,1,2,3,4 randomly....
Void loop{
machine_state=PINA;
if(last_state==machine_state)//Scan
{
// do nothing just wait until a machine change in state
}
else{
// Serial.println("");
// Serial.println(machine_state);
// difaverage();
//***just enter once
if (machine_state==0)
{
Serial.println("");
Serial.println("state 1");
last_state=machine_state;
}
if (machine_state==2)//Frame clamped
{
Serial.println("");
Serial.println("state 2");
last_state=machine_state;
}
if (machine_state==4)//Frame released
{
Serial.println("");
Serial.println("state 3");
last_state=machine_state;
}
if (machine_state==6)//Call button
{
Serial.println("");
Serial.println("state 4");
last_state=machine_state;
}
if (machine_state==8)//Call button
{
Serial.println("");
Serial.println("state 5");
last_state=machine_state;
}
last_state=machine_state;
}
}//end of loop
i have problems when i go from state 2(010) to state 3(100)... it goes to state 4(110)(skipping state 3).. the controller is read the bit transition... i have added some delays but i could not get it to work...
any tips?