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


Groups > comp.arch.embedded > #28129

Re: How do you read digital inputs from microswitch, jumpers, dip-switches...?

From Chris <xxx.syseng.yyy@gfsys.co.uk>
Newsgroups comp.arch.embedded
Subject Re: How do you read digital inputs from microswitch, jumpers, dip-switches...?
Date 2018-09-25 15:12 +0100
Organization Aioe.org NNTP Server
Message-ID <podfo6$dgo$1@gioia.aioe.org> (permalink)
References <pnvqld$pfh$1@dont-email.me> <po2si4$1j8v$1@gioia.aioe.org> <poau6h$6h5$3@reader1.panix.com> <wwoqD.112194$MK2.86374@fx35.iad>

Show all headers | View raw


On 09/25/18 11:57, Richard Damon wrote:
> On 9/24/18 11:00 AM, Grant Edwards wrote:
>> On 2018-09-21, Chris<xxx.syseng.yyy@gfsys.co.uk>  wrote:
>>> On 09/20/18 10:52, pozz wrote:
>>>> Often I have digital inputs connected to switches managed by the user.
>>>> For example: microswitches, tactile switches, push-buttons,
>>>> dip-switches, simple jumpers and so on.
>>>>
>>>> What is your preferred method to read the status of this inputs?
>>>>
>>>
>>>
>>> Assuming not in an rtos environment, where you have timers,
>>> a system clock tick and background timer capability, perhaps
>>> with callback, can make debounce easy.  A simple state
>>> machine using a switch statement, allows testing the input,
>>> delaying for a specified time, then reading again before
>>> acceptance of the change.
>>
>> Why delay before accepting the change?
>>
>> That sounds like you're trying to ignore noise pulses that appear
>> spontaneously.  That's a completely different problem from debouncing.
>>
>> In my experience, the usual method of debouncing, is to accept the
>> change immediately then ignore the switch for a period of time (a few
>> tens of milliseconds is usually sufficient).
>>
>
> For a human, 10s of milliseconds is normally 'instantaneous', so good
> enough. (In some gaming environment response gets more critical when the
> user has developed good twitch reflexes). While buttons rarely make a
> spontaneous make, in some environments they may open momentarily without
> intentional operation, so ignoring very short signals may be useful.

Ok, rushed and incomplete description. What I mean is that
state starts off = idle. On clock tick, input is read and
compared against the most recent value. If there is no
change, do nothing. If there is a change, state = pending.
On next tick, read again and if the same, return new value,
otherwise state = idle.

Very simplistic, yes, but using a clock tick to drive such
code means a keyscanner or hardware input module can run
in the background at interrupt level. Data from that can
either use a common variable, or queue...

Chris

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


Thread

How do you read digital inputs from microswitch, jumpers, dip-switches...? pozz <pozzugno@gmail.com> - 2018-09-20 11:52 +0200
  Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? John Speth <johnspeth@yahoo.com> - 2018-09-20 05:35 -0700
    Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? pozz <pozzugno@gmail.com> - 2018-09-21 09:42 +0200
      Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? David Brown <david.brown@hesbynett.no> - 2018-09-21 11:09 +0200
        Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Grant Edwards <invalid@invalid.invalid> - 2018-09-24 14:53 +0000
          Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? gnuarm.deletethisbit@gmail.com - 2018-09-29 12:34 -0700
      Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Andrew Smallshaw <andrews@sdf.org> - 2018-09-21 09:16 +0000
      Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? gnuarm.deletethisbit@gmail.com - 2018-09-21 06:22 -0700
        Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Robert Wessel <robertwessel2@yahoo.com> - 2018-09-21 10:04 -0500
          Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? lasselangwadtchristensen@gmail.com - 2018-09-21 14:47 -0700
            Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Robert Wessel <robertwessel2@yahoo.com> - 2018-09-22 21:57 -0500
              Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Andrew Smallshaw <andrews@sdf.org> - 2018-09-23 04:55 +0000
              Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? gnuarm.deletethisbit@gmail.com - 2018-09-22 22:55 -0700
          Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? gnuarm.deletethisbit@gmail.com - 2018-09-22 09:27 -0700
          Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Grant Edwards <invalid@invalid.invalid> - 2018-09-24 14:57 +0000
            Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Ed Prochak <edprochak@gmail.com> - 2018-10-05 09:52 -0700
              Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Richard Damon <Richard@Damon-Family.org> - 2018-10-05 14:40 -0400
              Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? gnuarm.deletethisbit@gmail.com - 2018-10-05 12:48 -0700
  Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Robert Wessel <robertwessel2@yahoo.com> - 2018-09-20 23:38 -0500
  Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Chris <xxx.syseng.yyy@gfsys.co.uk> - 2018-09-21 14:43 +0100
    Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Grant Edwards <invalid@invalid.invalid> - 2018-09-24 15:00 +0000
      Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Richard Damon <Richard@Damon-Family.org> - 2018-09-25 06:57 -0400
        Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Chris <xxx.syseng.yyy@gfsys.co.uk> - 2018-09-25 15:12 +0100
          Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Richard Damon <Richard@Damon-Family.org> - 2018-09-28 08:10 -0400
            Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Chris <xxx.syseng.yyy@gfsys.co.uk> - 2018-09-28 15:43 +0100
              Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Richard Damon <Richard@Damon-Family.org> - 2018-09-28 21:23 -0400
              Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Richard Damon <Richard@Damon-Family.org> - 2018-09-28 21:42 -0400
              Re: How do you read digital inputs from microswitch, jumpers, dip-switches...? Ed Prochak <edprochak@gmail.com> - 2018-10-05 10:04 -0700

csiph-web