View previous topic :: View next topic |
Author |
Message |
sahu77
Joined: 08 Sep 2011 Posts: 202
|
led blink count |
Posted: Sat Oct 22, 2011 12:03 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Oct 22, 2011 2:49 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
sahu77
Joined: 08 Sep 2011 Posts: 202
|
|
Posted: Sun Oct 23, 2011 2:28 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
sahu77
Joined: 08 Sep 2011 Posts: 202
|
|
Posted: Sun Oct 23, 2011 2:59 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Oct 23, 2011 4:35 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Sun Oct 23, 2011 10:47 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Sun Oct 23, 2011 5:26 pm |
|
|
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" ????? |
|
![](templates/subSilver/images/spacer.gif) |
|