Jump to content
Sign in to follow this  
onn

Why I Click My Stop Button And No Output Come Out During I Delaying 10S On My Program.

Recommended Posts

Hope got ppl can help me..i stuck on this step so long ready still dun know fix it..

 

Question

1. Stop input

At any time of the wash cycle, means at any state.

When you press the stop button, the wash motor and spin are ‘off’ but pump is in ‘on’ state. At this state you must sense the water level. When the water level reach the lower level sensor, pump off. This state is the original state (idle state).

 

my problem is on state 4 when the wash cycle is turn on then will automatic delay 10s for wash cycle process.after that it will go to state 5..but now i want change it to during delay 10s.. if i click stop button then it will go to state 9... unfortunately now my program is during delay 10s if i click stop button it wont go to state 9 its keep continue to state 5...

 

 

 

7 6 5 4 3 2 1 0

 

STOP temperature(0) SENSOR(low) SENSOR(low) temperature(1) START port A

LED WATER CYCLE WATER HEATER SPIN PUMP port B

 

 

Below there is my code for state 4,5 and 9

void state0(void){

inbyte=porta;

portb=0x00; //no output

inbyte &=0x01;

if (inbyte==0x01) nxtstate=1; //if click start then go to state 1

}//end of state0.

 

void state4(void){

inbyte=porta;

portb=0x10; //turned on wash cycle

inbyte &=0x80;

if (portb==0x10){ //if turned on wash cycle

delay(1,1000); //DELAY 10s

nxtstate=5; //after finish delay go state 5

if(inbyte==0x80) nxtstate=9; //if press sp(stop) and go to state 9

}

}//end of state4

 

void state5(void){

inbyte=porta;

portb = 0x01; //turn on PUMP

inbyte &=0x88 ;

if (inbyte==0x08)nxtstate=6; //if click SENSOR (low) then go state 6

if (inbyte==0x80) nxtstate=9; //if press sp(stop) and go to state 9

}//end of state5

 

void state9(void){

portb = 0x01; //turn on PUMP

inbyte=porta;

inbyte &=0x08;

if (inbyte==0x08)nxtstate=0 ; //if SENSOR (low) then go to state 0

}//end of state9

Share this post


Link to post
Share on other sites

In state 5 the code blocks, ie execution of the state machine is suspended as you have sent the processor off just to do nothing for 10s.

The thing to do is make the delay timing code non-blocking.

 

To give you the idea imagine that you use a variable to count the time in seconds, this is updated every time a second passes (either in the main loop or by an interrupt service routine). Now you state 5 code just checks for when the time reaches 10s or the stop button is pressed.

 

I hope you get the general idea,

 

Regards

Dave

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...