CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

I wanna use While...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
NewSpace



Joined: 23 Sep 2003
Posts: 12
Location: South KOREA

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

I wanna use While...
PostPosted: Sat Nov 27, 2004 5:34 am     Reply with quote

Dear Engeneer...

Hello?
This is Shouth Korea... Sorry I'm poor English...

anyway... I wanna use while...

B2 is Input...
and D3 is Out put

First.

D3 = 1;

while(1)
{
if(B2 == 1) break; //sensor in?
}

D3 = 0;


2nd...

D3 = 1;
while (B2 != 1)
{
}


What is better?

Please teach me...


Cyliner On... and... Sensor In then... Cylinder Off...
_________________
Hello~?

This is South KOREA
My name is Sanghyouk Kim But Call me Nick
Sorry I'm poor English
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sat Nov 27, 2004 8:49 am     Reply with quote

You can use macros to get your code more readable.
Is this what you want to do?

Code:


#define activate      output_high
#define deactivate    output_low
#define cylinder_D    PIN_D3

#define sensor_1      PIN_B1 // Home position
#define sensor_2      PIN_B2 // End of the stroke

void main()
{

 while(1)
   {
    do
      {
       activate(cylinder_D);
      }while(input(!sensor_2)); // until the cylinder is completelly OUT
     
    delay_ms(1000);

    do
      {
       deactivate(cylinder_D);
      }while(input(!sensor_1)); // until the cylinder is completelly IN
 
    delay_ms(1000);
  }
}



best wishes,

Humberto
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Nov 28, 2004 9:37 am     Reply with quote

Code:
      }while(input(!sensor_2)); // until the cylinder is completelly OUT
I think this contains an error and must be changed to:
Code:
      }while(! input(sensor_2)); // until the cylinder is completelly OUT
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group