Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Stop counting consecutive interrupts that are generated without intention

Status
Not open for further replies.

Snitch

Junior Member level 3
Junior Member level 3
Joined
Jun 5, 2012
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Sri Lanka
Activity points
1,469
When it's needed to generate only one interrupt using B0 of 16F877A, due to human errors, more than one interrupts are generated. To stop counting these unwanted interrupts I thought of restricting it by putting a time barrier in my code. To check whether it works I put two seconds as the minimum time between two consecutive interrupts. It works. But 2 seconds is too long.

Does anyone have experience in doing this? Can you please tell me what would be the suitable delay for this.

Thanks in advance.
 

What is the purpose? Do you want to know how many time a switch has been pressed? If so a delay of around 100 to maybe 250ms may be enough.
 
  • Like
Reactions: Snitch

    Snitch

    Points: 2
    Helpful Answer Positive Rating
What you require is switch debouncing. I assume you're using a switch and that's where human error comes in.

In most cases 100ms should be enough. You may also want to employ a hardware solution and maybe then, you can reduce the delay. Sometimes 30 to 50ms may also be enough.

An RC filter may be enough. But, if you use a circuit such as that presented in the links below, you may even avoid the software delay.
http://www.all-electric.com/schematic/debounce.htm


You may find these good reads:
**broken link removed**
https://www.edaboard.com/threads/36051/

Hope this helps.
Tahmid.
 
  • Like
Reactions: Snitch

    Snitch

    Points: 2
    Helpful Answer Positive Rating
Thank you Preset and Tahmid.

My purpose is to detect when an IR beam is being crossed. There are two beams. By considering which beam is crossed first I'm going to detect which way a man went.(went into the room or went out of room). I can only use B0 pin. When testing whether my code works, counting goes wrong because I accidentally give 2,3 interrupts.. That is my problem. And I've got to solve this through my code. But if it is better to have a hardware solution I'll try to do it.
 

Snitch;1095856When testing whether my code works said:
I accidentally give 2,3 interrupts[/B].. That is my problem. And I've got to solve this through my code. But if it is better to have a hardware solution I'll try to do it.

Do you mean that 2, 3 interrupts are accidentally generated, when, in fact, only one should be?

You can try with a 50ms to a 100ms delay. See if that improves the situation. If not, try with a larger delay and see if it is within acceptable bounds. If not, you may need to use the hardware solution.

Are you receiving the input from an IR sensor? What is the output from the sensor?
 
  • Like
Reactions: Snitch

    Snitch

    Points: 2
    Helpful Answer Positive Rating
Yes. Even when I'm giving inputs manually, that happens. The output is about 4.2 V.
 

Is this in simulation or in practice?

Output is 4.2V, when? When the beam is broken? Or when it isn't broken?
 

In practise. 4.2 V when the beam is broken.
(Manually means when I directly give input to the pic without using that IR sensing circuit)
 

I think you should try with 100ms delay and adjust delay time as I have previously mentioned.

You can also try the hardware solution and compare the results and see which works better for you, or is more suitable for you.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top