its a ballbearing 'switch'..
I want to try and use it to detect a 'SWING' type event..
(I'll also be tackling this using an accelerometer as well)
I have seen other products use these sensors for the same thing I am trying to use it for.. (toys..etc)
I 'do not' want to register a 'tilt' only a SWING...
anyone propose any suggestions on how to go about this using this type of sensor/switch?
Being new to the Arduino itself..
Im not sure the best approach to tackel using this sensor and to use it the way Id like to..
would I use an external Interrupt? (seems to be the only ting I 'can' get working lately..lol)
and if so.. what do I check for even? change? high/low? rising/falling?
I dont want a simple 'tilt' to trigger it though? must be a 'swing' type of force/event.. to be clear. ;)
time the 'time' it takes for a 2 'change' interrupts to fire?
Thanks for the discussion..
I 'do not' want to register a 'tilt' only a SWING...
Not sure how the switch is supposed to work, but I can't see how you can differentiate - I would have thought you'd need more than a single axis of sensing.
well ther are 2 of these ball bearing sensors..
1 for X axis and 1 for Y axis..
however... Id liek to start working with just one sensor at a time..
since Im not sure how to go about this.
I guess Im nto sure how to tell the difference either.. (which is why Im posting for help/suggestions).. I mean I 'know" (100%) that its possible..
using these EXACT same sensors.. (I purchased the SAME exact part#)...
on 'toys' that have been sold for MANY years (decade?)
and when tilted (which I suppose I can test for sure again as I have several of these toys laying around).. they do NOT register the effect..
but when 'swung' it does..
timing check perhaps? when balls break contact on one side?..before they reach other side perhaps?
heck I havent even been able to get a simple 'timer/debounce' going to check the OTHER type of sensor(s) Im using as well..
(nail & spring type)..
I can get that to work fairly good using an external interrupt only..using a timer/polling approach I couldnt get anything to work right.. =(
but these Im not sure HOW to go about check/using it..
Do you have an electrical schematic for this thing also? From the mech drawing it's not possible to tell where the conductors are.
I guess Im not clear on what an electrical schematic is? lol
If I remember correctly..
after tracking down the part numbers..and a vendor.. i got them from here:
(Chinese site translated)
I didnt see any spec sheet/.pdf...etc. some abrupt 'English' comments
but maybe these will help you, help me? LOL
it seems like one side might be ON and the other OFF... but Im still curious as to how other 'toys' utilize it (especially NOT to trigger on a simple 'tilt')...
I made a crude/simple 'demo' board with my 3 sensors on it
2 x ballbearing (swing) sensors
1 x nail & spring (clash) sensor
I have what I 'hope' is a correct and acceptable approach to using an external interrupt w/ a bit of a debounce routine in it to stop extra/false 'positives'...for the CLASH (nail & spring) sensor..
but need advice/help on working with these ball bearing types.
for testing.. I have just been taking each lead
an putting one in pin2 and the other to GND..
Thanks for any help/ideas.
I mean I 'know" (100%) that its possible.
Well it is not.
There is no way to detect if that switch is conducting from a tilt or a swing.
If the switch got old and was tarnished inside then you might have a situation where it needed extra force to push the ball into the contact. This would be provided by the extra force the swing gives it. But there is nothing in the signal output that could determine if the contact was closed quickly or slowly.
I have just been taking each lead and putting one in pin2 and the other to GND.
I hope you have a pull up resistor or have enabled the internal pull up resistor.
I use these sorts of switches in an alarm pager product where it registered an alarm if tilted. That is if the wearer fell to the ground. Problem it proved to be very unreliable sometimes needing more of a jolt than it got. We had to use these sorts of switches because the reliable mercury switch has been banned in Europe.
It might be possible by looking at the state of all three switches mounted like this to detect a swing. Is that what you mean?
well Im not sure how HASBRO uses them in this fashion then..
and has for over 10+ years.
every single one of their 'sound boards' uses TWO of these switches/sensors.. to detect a SWING on either the X or Y axis.. and have them mounted on their boards/pcb's in the exact same fashion..
'the 3rd switch'..is for CLASH/HIT tracking events.. nothing to do with SWING events..
I turn on this HASBRO 'toy' and if I swing it.. it makes a sound.. if I 'tilt it'.. it does NOT..
Im not..nor have I implied it was some 'signal' given off by the sensor that told the difference between a SWING and a TILT..
however somehow, somewhere.. in the code Im assuming there has to be some 'control/check' to eliminate a tilt vs a swing..
so again I 'am' saying it is 100% possible..
several other people/comanies do it.. same EXACT hardware.. (I sourced it myself, with same part#'s..etc)
if its a 'timed' thing.. or some other involvement.. who knows (which is why Im asking).. but I can show you a few other 'products' that use this same 2-3 sensor set-up..and do NOT trigger any sound/event when a 'tilt' happens.
I doubt 100's of thousands of these toys all purposely had tarnished/old sensors..
So your saying.. no it is NOT possible.. but yet I have several products that say/prove otherwise?
I dont want to argue about IF its possible.. I see it is..
Im curious as to seek out HOW they are doing it..
I have tried with the internal pullup resistor enabled.
(side note: this does NOT work for internal pull DOWN...right?)
anyways.. back on track.. since the sensor only basically gives of a YES or NO (1 or 0) read..
my original suggestion (unless someone knows how other companies are doing it).. maybe trying to time (micros() not millis()) the 'period' between the 1 & 0?
Thanks to anyone with suggestions.
appreciate it. :D
I'm curious as to why there are two balls in there.
I wondered the same thing..
but it seems the originals were like that as well..
SW200D is the part# (ball bearing type)
the other is a SW-18020P (nail & spring type)
Im still curious as to how Hasbro, Master Replica, and other regular EE's work with these sensors to only trigger on a SWING event..and NOT a simple 'tilt'??
timing is the only thing "I" can think of.. but who knows! lol
Does the nail/spring sensor work somewhat like this:
Then if the flexibility of the spring isn't too soft, it might be possible to detect the swing with this sensors, and only use the ball bearings to determine the direction.
You would still not be able to determine the direction, if you swing and tilt the board at the same time, though.
I suppose your suggestion is an approach I could pursue..
however Id like to try and mimic how the other 'people' are doing theirs..
I know the Hasbro and other toy boards do NOT use the 'clash' sensor in the swing detection.. (because if I remove it completely..it works as normal...except no clash events when I bang it against something of course)
I am also trying to do this with an accelerometer.. and I have it partially working....
but going the accelerometer route.. I have NOT been able to figured out to pick up a 'JERK' (as they refer to it) action in the accelerometer..
I guess I could/should try reverse logic for what Im using to pick up acceleration?
(worth a shot).. however I wanted to tackle this approach first.
(which is leading to a dead end for me) LOL
Is there any kind of damping in this ball switch, like an insulating oil?
When you shake one, does it rattle, or does it feel damped?
I'm struggling to visualise this device.
from what I can tell..
(and I have 100's of them so I could cut one open if need be)
but it DOES sound normal.. (ie: no oil or anything)..
as it shakes and does make noise.. does NOT feel there any oil or 'slowing' of ball rolling..
and over the last few years where people have used these..I have never seen/heard mention of it.
That last gif showing the switch tilting on and off reminds me very much like the old mercury tilt switches which were very popular at one time. I assume with all the effort to eliminate mercury from the environment has made this kind of switch more popular.
Im sure you are correct...
probably a replacement for the mercury type.. (which is mentioned in the Beginners Arduino book)
however.. Im still wondering how Hasbro, other toy companies and other EE's work with this specific sensor to 'avoid' a regular 'tilt' event from triggering a routine... and only a 'swing' event to do so.
Only thing I have/can come up with is trying to use micros() I dont even think millis() will do it?
basically from 'state to state' check the 'length/period' of time it took?
if under xx then do something..if > xx then its a tilt..and do nothing?
I just dont wanna waste my time more experienced members have a better solution/approach. (suggestion)