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 support@ccsinfo.com

led blink count

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



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

led blink count
PostPosted: Sat Oct 22, 2011 12:03 pm     Reply with quote

How can I count led flash during Blink LED ?
Code:

/***************************************************************************
  Function BlinkLED5
  LED Blink @ 500 ms interval one by one.  BlinkLED5_flag set in interrupt.
****************************************************************************/
void BlinkLED5(void)
{
   if(BlinkLED5_flag==0)
   {
    output_high(RL2);
   }
   else
   {
   output_low(RL2);
   }
}

1 _on time = 500 ms
1 _off time = 500 ms
Total time 1 _ led flash time =1000 ms =1 sec
I want counting led flash time during any testament.
like

if (BlinkLED5>10times)
return(HIGH_VOLTAGE);

My question: how can find (10times) ?
_________________
sahu
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 22, 2011 2:49 pm     Reply with quote

The most simple way would be:

1. Declare a 'count' variable above the function. Declare it as int8
if you want a range of 0 to 255.

2. Set 'count' = to 0 at the start of main(). Also, you can reset it to 0
at any other place in main() when you want to do it.

3. Inside your BlinkLED5 function, put in a line of code to increment
the 'count' variable.

4. Then read 'count' in main() to see what its value is.

I think this method would be the easiest way for you to understand it.
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Sun Oct 23, 2011 2:28 am     Reply with quote

PCM programmer wrote:
The most simple way would be:

1. Declare a 'count' variable above the function. Declare it as int8
if you want a range of 0 to 255.

int8 count // for range of 0 to 255 is ok ?

int10 count // for range of 0 to 1023 is ok ?

PCM programmer wrote:

2. Set 'count' = to 0 at the start of main(). Also, you can reset it to 0
at any other place in main() when you want to do it.

3. Inside your BlinkLED5 function, put in a line of code to increment
the 'count' variable.

4. Then read 'count' in main() to see what its value is.

I think this method would be the easiest way for you to understand it.

if possible cn u give 1 example ?
I'm right ?
Code:
if ((ch_0>800) &&  (BlinkLED5_count>= 60)) // lod 130 % Wait yet 1 min
      return(OVER_LOD_SENCE);

_________________
sahu
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Sun Oct 23, 2011 2:59 am     Reply with quote

i was try like
Code:
if ((ch_0>800) &&  (BlinkLED5_count>= 60)) // lod 130 % Wait yet 1 min
      return(OVER_LOD_SENCE);

but found error
Quote:
*** Error 12 "main.c" Line 253(25,40): Undefined identifier BlinkLED5_count

_________________
sahu
ckielstra



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

View user's profile Send private message

PostPosted: Sun Oct 23, 2011 4:35 am     Reply with quote

Sahu,
To me it seems you are spending more time here on the internet asking questions than that you are trying to learn something yourself. We all were beginners once so I do understand you make a lot of errors and that is fine. But what is annoying me is that I get the feeling that for every tiny problem you immediately jump to this forum. Please try investigating a bit more yourself, experiment, read books, etc. That is the way you will learn things, just asking for the quick answer seems easier but will give you problems later as you don't understand the basics and have never learned how to find an answer.

Code:
int8 count // for range of 0 to 255 is ok ?

int10 count // for range of 0 to 1023 is ok ?
The way of thinking is good, but have you tried the code and seen what happens?

sahu77 wrote:
i was try like
Code:
if ((ch_0>800) &&  (BlinkLED5_count>= 60)) // lod 130 % Wait yet 1 min
      return(OVER_LOD_SENCE);

but found error
Quote:
*** Error 12 "main.c" Line 253(25,40): Undefined identifier BlinkLED5_count
I think the error message is very clear, even for a beginner.
What the compiler is saying: The variable BlinkLED5_count is unknown. This could be because you made a spelling error in the name or because you forgot to declare the variable in the scope of your function.
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Sun Oct 23, 2011 10:47 am     Reply with quote

Some time ago this board started spoon feeding and devolved to doing homework assignments.The risk this brought was that many on this board were getting A grades for students that probably deserved much less. It encouraged many more to seek out A grades via this board. There is a very reasonable chance with this board that any question has already been asked and answered. Some insist that they been shown where they went wrong essentially insisting that another person debug their code. Others look at the approach of others and learn from it. Some believe that cutting and pasting without understanding is a winner. A bit like shaking the disassembled parts of a car together and expecting a full functioning automobile as the result.
This board is open to all but maybe any issue that is already answered either here or elsewhere shouldn't be answered quickly with the hope the delay might encourage some motivation of behalf of the poster to try and solve it themselves.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sun Oct 23, 2011 5:26 pm     Reply with quote

can i also declare??
Code:

int13 mycount;
int21 thatcount;
int 5 shortcount;
 


you are in to deep weeds here sahu

have you READ the CCS manual -
especially the topic 'DATA DEFINITIONS" ?????
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