Work Project - Counter operated by multiple micro-switches

Thread Starter

ASanchez04

Joined Feb 18, 2019
6
Hello,

I'm just wondering if anybody can help me, I am currently doing a project for work and I'd like to know if it is possible to work a singular counter with multiple microswitches. The project is an interactive kit and we have designed a game which is similar to ski ball. I am wanting to know on how I'd go about on wiring up a digital counter which is able to take an input from different microswitches to display an increase of value as a score for the player. The idea for the scoring will be that as a microswitch is switched on it will +1 the counter, and some switches will increase it by +5 (Working off of multiple switches at once). If possible, is anyone able to help us with the type of components that can be used for this idea.

Thank you!
 

danadak

Joined Mar 10, 2018
4,057
Questions -

1) How many microswitches ?

2) Microswitches hard wired to counter module ?

3) What actuates the microswitches ? Any idea of how fast / how many
microswitches can be active at any one time ?

4) You looking for a turn key solution or will this be a hack, a ground up design ?

5) What is done with the ocunter tally, is it displayed ? If displayed on whjat ?


Regards, Dana.
 

Thread Starter

ASanchez04

Joined Feb 18, 2019
6
Questions -

1) How many microswitches ?

2) Microswitches hard wired to counter module ?

3) What actuates the microswitches ? Any idea of how fast / how many
microswitches can be active at any one time ?

4) You looking for a turn key solution or will this be a hack, a ground up design ?

5) What is done with the ocunter tally, is it displayed ? If displayed on whjat ?


Regards, Dana.
1) Looking at the attachment uploaded, the end holes will have one microswitch each to count +1 as the ball his the switch, the holes on either side of the centre holes will have three microswitches each to count +3 and the centre hole will have 5 microswitch to count +5.

2) Yes, we are planning on hard wiring the microswitches onto the module as we have no to little background on electronics.

3) A metal ball will be used to actuate the switches. We are thinking of making the ball roll/bound down a step/spiral steps in order to actuate the switches one at a time so that it counts up the counter one at a time. For example if the ball rolled into the +3 hole, each step will do +1 each time.

4) This is a ground up design as it is for a challenge.

5) The counter module we have been suggested is a 'Trumeter 7000' but as we have no background in electronics, it's difficult for us to understand if this is viable for what we are trying to achieve.

Thank you.
 

Attachments

LesJones

Joined Jan 8, 2017
4,174
Am I right in thinking that each micro switch only increments the count by 1 and that when you want the count to increment by 3 you use 3 micro switches ? So when you say "the holes on either side of the centre holes will have three microswitches each to count +3" doe you mean that if the ball hits the three micro switches that the count is incremented by 9 ? (I am not clear if the word "each" referres to the holes or the micro switches.)

Les.
 

pmd34

Joined Feb 22, 2014
527
Hi ASanchez04, for the most part it sounds like you can simply wire the switching in parallel if only one switch will be activated at once. Scoring 5 maybe a little more challenging.
If several switches will be activated at once, you could look at using something like a parallel-in/serial-out shift register:
https://www.nexperia.com/products/logic/i-o-expansion-logic/shift-registers/74HC165DB.html

You could connect your counter to the serial output, and your switches to the parallel inputs, you would then need to supply a clock which pulses quick enough that you you can guarantee there will be at least one pulse from it while the ball is activating one or more of the micro-switches (using a 555 timer or a mic1557.)

You could also score 5 in this way, just connecting 5 of the parallel inputs though you may need to cascade a couple of chips, and leave one input blank between each switch so you get separate on / off pulses, and not just one long on pulse.

Really however its a nice project for using an Arduino type microcontroller as it gives you much more flexibility with how you score, displaying, timing, and upgrading!
 

Thread Starter

ASanchez04

Joined Feb 18, 2019
6
Am I right in thinking that each micro switch only increments the count by 1 and that when you want the count to increment by 3 you use 3 micro switches ? So when you say "the holes on either side of the centre holes will have three microswitches each to count +3" doe you mean that if the ball hits the three micro switches that the count is incremented by 9 ? (I am not clear if the word "each" referres to the holes or the micro switches.)

Les.
A singular microswitch will count up to +1 so in order for us to achieve a +3, we will have three microswitches in which a ball will actuate the switch one by one. So the score will not go up instantaneously, it will count to 1, then to 2, then to 3 until there are no longer any microswitches to be actuated, if that's making any sense.
 

Thread Starter

ASanchez04

Joined Feb 18, 2019
6
Hi ASanchez04, for the most part it sounds like you can simply wire the switching in parallel if only one switch will be activated at once. Scoring 5 maybe a little more challenging.
If several switches will be activated at once, you could look at using something like a parallel-in/serial-out shift register:
https://www.nexperia.com/products/logic/i-o-expansion-logic/shift-registers/74HC165DB.html

You could connect your counter to the serial output, and your switches to the parallel inputs, you would then need to supply a clock which pulses quick enough that you you can guarantee there will be at least one pulse from it while the ball is activating one or more of the micro-switches (using a 555 timer or a mic1557.)

You could also score 5 in this way, just connecting 5 of the parallel inputs though you may need to cascade a couple of chips, and leave one input blank between each switch so you get separate on / off pulses, and not just one long on pulse.

Really however its a nice project for using an Arduino type microcontroller as it gives you much more flexibility with how you score, displaying, timing, and upgrading!
Thank you for the feedback, as it is an apprentice challenge we are only receiving a budget of £100 which will be used for components, materials, etc... and as the groups consists of electrical & mechanical apprentices, we don't have a great amount of knowledge with electronics in an advanced sense. Will this method be achieved without the use of multiple chips?

We have thought about using arduino but we just don't understand it at all for the time-scale of 2 weeks to complete the challenge.

Thank you.
 
One easy controller is the www.picaxe.com. It's programmable in BASIC.

Switches need de-bouncing for electronics, They don;t have clean edges, the counter will pick up multiple counts.

A possibility, still might not work, depends on timing.

Each switch would "gate" an oscillator for the required # of counts. Say the oscillator was 1 pps (too slow)
The debounced switch #1 would edge trigger and let in 1 count, it would gate for 1s
The ndebounced switch #5, would edge trigger and let in 5 pulses, it would gate for 5s

Timerblox from Analog Devices might be a start for the timing logic.

Not great but still. Two switches at the same time, that may be an issue or two co-incident might be another problem.
There are priority encoders for digital logic.

Calibration, if there was such a thing might be a pulse every 10s to the switch where you could try to set the increment to the proper value. If you could reset the count even better.

60 of 50 Hz is an easy time base from the AC line. That's like a change every 8.33 mS. De-bounce time might be along that order..

==

The processor can either generate interrupts on a switch change, De-bouncing can be done in software or hardware. and determine how much to increment.

External hardware could generate one interrupt and also latch who generated it with priority encoder.

You might be stuck with a serial LCD display for starters. You just don't have the time.

I'm thinking out loud here, no circuits in mind just some ideas and caveots,

You may not understand a word of this.
 

djsfantasi

Joined Apr 11, 2010
9,156
If all of the micro switches increment to count by 1, then simply wiring all of them in parallel will work.

Your counter is an all-in-one device, which counts mechanical closures and displays the current count. It also included circuitry for an external reset.

The major issue you will face is mentioned in the product description. It is that in actuality, when each microswitch is activated, it sends multiple pulses as seen by the electronics. This is a common counting problem and has a common solution. The solution is “switch debouncing”. You can read about that here

The product description mentions switch debouncing. They suggest using a capacitor and resistor. That technique is described in the article to which I linked.

The only remaining issue I see is if two separate balls activate two switches near the same time. I’d start with this solution and see if this is a problem.
 

Bernard

Joined Aug 7, 2008
5,784
With all SWs wired in parallel then, one de-bounce circuit should be enough. There should be about
50 ms between one SW opening & next SW closing for bounce time
 

danadak

Joined Mar 10, 2018
4,057
This can be done in one chip. The debounce, counting, display. But
it requires some basic knowledge about micros.

One possible approach is using Ardublock and Arduino. Programming is
done graphically, This is in significant use by 8 year olds and up in school
to learn programming. Scratch is another Ardublock like language, tons
of examples and support out on web.

Here is an example Ardublock design (a different application) -

upload_2019-2-18_13-3-23.png

This generates Arduino code when you instruct Ardublock to upload to Arduino.
Arduino code primarily C like code you can look at. But do not, for simple applications,
have to alter. You stay in the graphical world.

Another approach uses HW, one chip, called PSOC -

upload_2019-2-18_13-29-23.png

A small $ 15 board would suffice. But you have to code this design.

Key to design is, as previously mentioned, debouncing the switches. That
can be done in code or HW or SW. For the above languages it would be
done in SW.

Note in both cases, Arduino, PSOC, the actual solution is one chip but the boards
have programming stuff on them, that is unused when design is finished. So
could be eliminate once finished.


Regards, Dana.
 

djsfantasi

Joined Apr 11, 2010
9,156
@danadak, he has it all in one device already, except for the denounce. The counter he posted included everything he needed (except for the denounce) and is an industrial solution, appropriate for the intended environment.

While in general, I agree with your approach, in this case it might confuse the TS.
 

danadak

Joined Mar 10, 2018
4,057
Except for debounce, muxing, and pullups.

Note his display choice, no back light, not the best of choices.

Wring all switches in parallel will take design down if one switch gets stuck closed.
In a pin ball environment, thats a real possibility due to machine violence. Note
microswitches could easily be done with reflective opto couplers, no mechanical
issues to deal with. And if display remote a low speed I2C interface probably
work quite nicely.



Regards, Dana.
 

sghioto

Joined Dec 31, 2017
5,379
As long as only one ball can activate switches at a time the TS's mechanical design with appropriate debouncing should be fine as djsfantasi noted in post #10. Most of the work is in the mechanical construction, the electrical is the easy part.
SG
 

djsfantasi

Joined Apr 11, 2010
9,156
Except for debounce, muxing, and pullups.

Note his display choice, no back light, not the best of choices.

Wring all switches in parallel will take design down if one switch gets stuck closed.
In a pin ball environment, thats a real possibility due to machine violence. Note
microswitches could easily be done with reflective opto couplers, no mechanical
issues to deal with. And if display remote a low speed I2C interface probably
work quite nicely.



Regards, Dana.
What muxing? What pull-ups? I didn’t see any requirement for either!

You and I have often both proposed micro solutions in other threads. So you know I understand where you’re coming from.

But, they are not the be all and end all solution. Sometimes, you just need a hammer and not a sledge. Your posts actually raise valid points... in another environment. Particularly when the TS has additional unsolved issues.

This is not the case here. Personally, I make my recommendations based on the TS requirements, not my preconceived ideas.

@ASanchez04, your solution is very simple. Don’t be confused by more complex answers.
 

eetech00

Joined Jun 8, 2013
3,859
If all of the micro switches increment to count by 1, then simply wiring all of them in parallel will work.

Your counter is an all-in-one device, which counts mechanical closures and displays the current count. It also included circuitry for an external reset.

The major issue you will face is mentioned in the product description. It is that in actuality, when each microswitch is activated, it sends multiple pulses as seen by the electronics. This is a common counting problem and has a common solution. The solution is “switch debouncing”. You can read about that here

The product description mentions switch debouncing. They suggest using a capacitor and resistor. That technique is described in the article to which I linked.

The only remaining issue I see is if two separate balls activate two switches near the same time. I’d start with this solution and see if this is a problem.
Hi

Good suggestions...but I doubt the TS understands the electronics jargon. You should probably provide a schematic that shows how to wire it up.

Just sayin...

eT
 

danadak

Joined Mar 10, 2018
4,057
djsfantasi -

What muxing? What pull-ups? I didn’t see any requirement for either!
Pullups so switches can generate logic levels.

Muxing, as stated earlier paralleling all switches not a good idea.. Mux needed so each
switch can be screened/sampled individually, and debounced. Or eliminate mux and do
design fully parallel, ugh......

But, they are not the be all and end all solution. Sometimes, you just need a hammer and not a sledge.
Your posts actually raise valid points... in another environment. Particularly when the TS has additional unsolved
issues.
For sure I am an advocate of Micros for a litany of reasons. I also understand some folks this will
be a new experience. Shipping billions of micros annually these days, kids age 8 and above being
taught basic programming, its all good. Do they fit everything, so far not able to generate RF power,
but thats just a matter of time, not able to manage KW of power onchip, that too a matter of time. But
I diverge.

This is not the case here. Personally, I make my recommendations based on the TS require-
ments, not my preconceived ideas.
Wonderful.

I like to examine a TS's posting, try to address that, and leave behind some thoughts on how and what
can be done to enhance as well. Depends on full moon or.....Egotistical, yep, preconceived, yep. But I
think a forum has all these components in it. Spreading not just solutions but ideas and knowledge, its
all good.

sghioto -

Also earlier the idea that only one switch closed at a time. My focus was on issue
if a switch gets stuck closed, and they are wired in parallel, it takes the whole game
down. Why not leave game running, slightly crippled, when that happens. And of
course report it as a malfunction because you have intelligence in the system. Recently
just replaced two micro switches in an oven, one shorted the other unable to make
meaningful ohmic closure. Oven was < 5 years old.


Regards, Dana.
 
Last edited:
Top