Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.arch.embedded > #13852

Re: Counting 2ms long pulses on several input pins

From Paul <paul@pcserviceselectronics.co.uk>
Newsgroups comp.arch.embedded
Subject Re: Counting 2ms long pulses on several input pins
Date 2013-09-24 15:51 +0100
Organization PC Services
Message-ID <MPG.2cabb76d73bcf0cd989786@172.16.0.1> (permalink)
References <l1qck1$9dd$4@dont-email.me> <bad71fF7fdaU1@mid.individual.net>

Show all headers | View raw


In article <bad71fF7fdaU1@mid.individual.net>, 
Paul_E.Bennett@topmail.co.uk says...
> 
> pozz wrote:
> 
> > I have a 5 microswitches
> > (www.tamiyausa.com/images/product/470/75016/header_75016.jpg) connected
> > to some inputs of a microcontroller.  The switches are normally closed
> > and put the level to low.  When they are open, the level is high thanks
> > to pull-up resistors.
> > 
> > I have to count the pulses generated from the microswitches.  They are
> > managed by a rotating cam (en.wikipedia.org/wiki/Cam) that push/release
> > continuously the switches.
> > 
> > The rotation speed could change. When it is slow, the complete pulse
> > width could be up to 15-20ms, where the last part (about 3-5ms) is
> > composed by many bouncing oscillations.
> > When the rotation is fast, the complete pulse width is about 1-2ms and
> > the boucing oscillations takes about 2-3ms.
> > 
> > What is the best approach/algorithm to debounce and detect/count pulses
> > on all the lines, without stressing the microcontroller too much?
> > 
> > My approach is to sample each input lines every 1ms in the ISR of a
> > timr.  Usually it is at low level.  When I see the first 1, I increase
> > the counter and change to HIGH status.  Now I have to see two
> > consecutives 0 to go back to LOW status.
> > 
> > Do you have better ideas?
> 
> There is insufficient information here to determine:-
> 
>   1.  Is the use of mechanical switches adequate to the task being
>       undertaken.

Not enough info on reprtion frequency and max latency for each input
amongst many other factors.
 
>   2.  The best de-bounce method (in either hardare or software) that should
>       be employed.

Whether even an simple MAX6817 would do all the work and one interupt 
pin to micro..... up to complex hardware filtering, or simple filtering
and software.

Whether counters for each are needed etc. etc...

<pedant>
Most likely all solutions will be h/w and s/w even. minimal h/w pull up 
resitor and software.
</pedant>
 
>   3.  Whether polling or edge triggered inturrupts are the best strategy.
> 
> So Pozz, a simple test on which you should then report the results here. 
> Mount one of the switches as intended and strap it into a circuit 
> configuration that will resemble the input circuit you are using. Attach a 
> scope across the points where the input would be taken and set the trigger 
> to capture the resultant input. Rotate the cam-shaft over the full range of 
> rates you expect it to operate at and report the results in the form of 
> shoing us the scope traces (on a link) or tabulated as figures relating how 
> long the contacts bounce for at what speed.
> 
> Of course, once you have done this you may discover your own answer to your 
> problem. Either ay I think the other responders and myself will be 
> interested in your findings.

Also any relationship between the switches/cams, as to are we measuring 
the pulse characteristics for each cam in isolation, or related to other
cams.

The cams could for example be paper feed related in a printer and time 
differences could detect paper jam/empty/page ejected.

-- 
Paul Carpenter          | paul@pcserviceselectronics.co.uk
<http://www.pcserviceselectronics.co.uk/>    PC Services
<http://www.pcserviceselectronics.co.uk/pi/>  Raspberry Pi Add-ons
<http://www.pcserviceselectronics.co.uk/fonts/> Timing Diagram Font
<http://www.gnuh8.org.uk/>  GNU H8 - compiler & Renesas H8/H8S/H8 Tiny
<http://www.badweb.org.uk/> For those web sites you hate

Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Counting 2ms long pulses on several input pins pozz <pozzugno@gmail.com> - 2013-09-23 23:42 +0200
  Re: Counting 2ms long pulses on several input pins mike <ham789@netzero.net> - 2013-09-23 15:00 -0700
  Re: Counting 2ms long pulses on several input pins Don Y <this@isnotme.com> - 2013-09-23 16:12 -0700
  Re: Counting 2ms long pulses on several input pins Paul Rubin <no.email@nospam.invalid> - 2013-09-23 18:45 -0700
    Re: Counting 2ms long pulses on several input pins Arlet Ottens <usenet+5@c-scape.nl> - 2013-09-24 08:06 +0200
      Re: Counting 2ms long pulses on several input pins Don Y <this@isnotme.com> - 2013-09-24 00:37 -0700
        Re: Counting 2ms long pulses on several input pins Arlet Ottens <usenet+5@c-scape.nl> - 2013-09-24 10:24 +0200
          Re: Counting 2ms long pulses on several input pins Paul Rubin <no.email@nospam.invalid> - 2013-09-24 02:05 -0700
            Re: Counting 2ms long pulses on several input pins Arlet Ottens <usenet+5@c-scape.nl> - 2013-09-24 11:01 +0200
          Re: Counting 2ms long pulses on several input pins Don Y <this@isnotme.com> - 2013-09-24 09:55 -0700
            Re: Counting 2ms long pulses on several input pins Tom Gardner <spamjunk@blueyonder.co.uk> - 2013-09-24 18:13 +0100
              Re: Counting 2ms long pulses on several input pins Don Y <this@isnotme.com> - 2013-09-24 11:03 -0700
            Re: Counting 2ms long pulses on several input pins Arlet Ottens <usenet+5@c-scape.nl> - 2013-09-24 19:38 +0200
              Re: Counting 2ms long pulses on several input pins Don Y <this@isnotme.com> - 2013-09-24 11:13 -0700
                Re: Counting 2ms long pulses on several input pins Arlet Ottens <usenet+5@c-scape.nl> - 2013-09-24 20:30 +0200
                Re: Counting 2ms long pulses on several input pins Paul E Bennett <Paul_E.Bennett@topmail.co.uk> - 2013-09-24 21:20 +0100
                Re: Counting 2ms long pulses on several input pins Don Y <this@isnotme.com> - 2013-09-24 16:08 -0700
    Re: Counting 2ms long pulses on several input pins Don Y <this@isnotme.com> - 2013-09-24 00:34 -0700
  Re: Counting 2ms long pulses on several input pins Andrew Smallshaw <andrews@sdf.lonestar.org> - 2013-09-24 04:31 +0000
  Re: Counting 2ms long pulses on several input pins Paul E Bennett <Paul_E.Bennett@topmail.co.uk> - 2013-09-24 11:15 +0100
    Re: Counting 2ms long pulses on several input pins Paul <paul@pcserviceselectronics.co.uk> - 2013-09-24 15:51 +0100
  Re: Counting 2ms long pulses on several input pins pozz <pozzugno@gmail.com> - 2013-09-25 00:33 +0200
    Re: Counting 2ms long pulses on several input pins Don Y <this@isnotme.com> - 2013-09-24 16:36 -0700
      Re: Counting 2ms long pulses on several input pins pozz <pozzugno@gmail.com> - 2013-09-25 07:39 +0200
        Re: Counting 2ms long pulses on several input pins Don Y <this@isnotme.com> - 2013-09-24 23:37 -0700
          Re: Counting 2ms long pulses on several input pins pozz <pozzugno@gmail.com> - 2013-09-27 15:54 +0200
            Re: Counting 2ms long pulses on several input pins Don Y <this@isnotme.com> - 2013-09-27 12:35 -0700
    Re: Counting 2ms long pulses on several input pins mike <ham789@netzero.net> - 2013-09-24 16:43 -0700
  Re: Counting 2ms long pulses on several input pins j.m.granville@gmail.com - 2013-09-24 17:32 -0700
    Re: Counting 2ms long pulses on several input pins Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2013-09-25 09:52 +0300
      Re: Counting 2ms long pulses on several input pins Don Y <this@isnotme.com> - 2013-09-25 00:09 -0700
        Re: Counting 2ms long pulses on several input pins j.m.granville@gmail.com - 2013-09-25 16:53 -0700

csiph-web