Can SOIC handle switch bounce?
I have a micro switch working with a 10" long lever for my canopy switch. In trying to get it to open properly with SOIC I kept running into problems with the opening and closing of the canopy getting out of sequence.
Using the logging function of SOIC (SOIC Config?) I noticed switch bouncing and multiple contacts at times. The code is set to set and clear the 0 bit of the offset. I think this is screwing up the sequence.
Is there a way to delay the switch reading for a few milliseconds?
Re: Can SOIC handle switch bounce?
John
It could be that the SIOC code is too fast for the hardware. Try inserting a software delay between reading and resetting the offset. There is an example of the SIOC DELAY function on Nicos` site here
http://www.lekseecon.nl/howto.html
Regards
David
Re: Can SOIC handle switch bounce?
The DELAY function won't help here. I am getting a manual switch bounce. the long lever and torque created is causing the little micoswitch to open and close two or three times when the handle is moved to close the switch.
DELAY will only delay the sim action. I need to have a delay between the time the switch closes and SOIC reads it closed. Otherwise, it is redesign the entire mechanism which, of course, is not easy to get to without removing the ejection seat, side panel, etc.
Ahhhh, such is a sim builder's life. :rolleyes:
Re: Can SOIC handle switch bounce?
Hi John,
The Master Card of OC takes care of de-bouncing, but I assume your switch bouncing is too long stretched in time.
You can either solve that with extra hardware: http://www.electronixexpress.com/t_bounc.htm
or you can solve this in SIOC, with the DELAY function and a sempahore, it goes like this:
Code:
Var 1 Value 0 // semaphore
Var 2 Link IOCARD_SW Input xy // connected to your switch
{
IF v1 = 0
{
v1 = 1 // set semaphore
v3 = DELAY v2 50 // assign v2 to v3 after .5 second
}
}
Var 3
{
v1 = 0 // reset semaphore
L0 = v3 // L0 contains the de-bounced input
// ...
}
Regards,
Nico Kaan
Re: Can SOIC handle switch bounce?
Thanks Nico! I will try this tonight.
Re: Can SOIC handle switch bounce?
Okay, let me know the result.
I was wondering, maybe it is even more reliable to take v2 as end result so in Var 3 write:
Quote:
L0 = v2 // L0 contains the de-bounced input
Nico
Re: Can SOIC handle switch bounce?
Obviously if you can do it in software that would be the easiest route, but if not you could do it in hardware. A simple RC circuit would do it, but you'd need power:
http://www.electronixexpress.com/t_bounc.htm
Depends how handy you are with a soldering iron.
Re: Can SOIC handle switch bounce?
Nico
Thanks, I knew there would be a way of solving this in SIOC.
Regards
David
Re: Can SOIC handle switch bounce?
Quote:
Originally Posted by
kiek
Okay, let me know the result.
I was wondering, maybe it is even more reliable to take v2 as end result so in Var 3 write:
Nico
OK Nico, I have it working and it seems to help some? i am still getting out of sync but it could be something else. Here is my code snippet. See if i manged to code it the way you were thinking.
I still think I will redesign the switch sometime. It is just too loose with no feel.
// ************************** Canopy ********************************
Var 8000, Value 0 // Initialization
Var 8001, name canopysw, Link IOCARD_SW, Input 7, TYPE I
{
IF V8000 = 0
{
&canopysw = 1
&canopy = DELAY &canopysw 50 // assign .5 delay to canopysw
}
}
Var 8002, name canopy, Link FSUIPC_INOUT, Offset $3367, Length 1
{
V8000 = 0
L0 = &canopy
}
Re: Can SOIC handle switch bounce?
Hi,
Isnt there a mistake in the script, I think it should be like the following :
Var 8000, Value 0 // Initialization
Var 8001, name canopysw, Link IOCARD_SW, Input 7, TYPE I
{
IF V8000 = 0
{
V8000 = 1
&canopy = DELAY &canopysw 50 // assign .5 delay to canopysw
}
}
Var 8002, name canopy, Link FSUIPC_INOUT, Offset $3367, Length 1
{
V8000 = 0
L0 = &canopy
}
another solution is to do the following :
when the canopy switch changes, the V8000 is set to 1 and the fsuipc offset
is written immediately but the following updates of the canopysw are not possible
since V8000 is 1. Only after the delay time the V8000 is reset to 0 allowing further
updates of the canopysw
(Niko, correct me if Im wrong here!)
Var 8000, name canopyUpdate, Value 0 // Initialization
Var 8001, name canopysw, Link IOCARD_SW, Input 7, TYPE I
{
IF &canopyUpdate = 0
{
&canopyUpdate = 1
&canopy = &canopysw
&canopyUpdate = DELAY 0 50
}
}
Var 8002, name canopy, Link FSUIPC_INOUT, Offset $3367, Length 1