Dear All,
I am a new user on this forum, so first of all a big Hi to everyone that decides to take a look at this thread.
To give you some context to the problem, my project involves using an Arduino Leonardo to make a HID device that will be used as a game controller. It pretty much works and takes in both digital and analogue inputs that can then be mapped to different controls in games.
The digital inputs part is a key matrix with switches that are assigned to the logical buttons on the HID device. For this purpose I use mostly DPDT toggle switches, and wire them in a way that the two positions of the switch use two opposite throws and separate poles, like shown below.
This works well but uses two keys on the key matrix, which in turn means it uses two logical buttons on the HID device. Some games allow you to map the same control to two buttons (e.g. to flip a light ON and OFF), but some don't which makes this not ideal.
So the next thing I tried was to use one pole and connect the two corresponding throws together. This is also shown below.
In this configuration the sense line is always HIGH because the drive line is set high when cycling through the key matrix, and because the switch is always closed due to the shorted throws. While the switch is closed, the logical button on the HID device remains pressed.
There is a short period of time where the state of the sense line is LOW, and this is when the switch is being flicked and the lever is in the middle position right between the two throws, causing the pole not to make contact with neither of the throws. When the flick of the lever is complete the switch is closed again.
This is the equivalent of pressing a button on the HID device, releasing it for a very short period of time and then pressing it again.
The Problem:
The Arduino platform doesn't poll the key matrix fast enough and the LOW state of the sense line is not detected during the fast flick of the switch. This results in the logical button being constantly pressed, even during the flick. While in game, this means that flicking the switch has no effect. On the odd occasion the LOW period is detected and the switch works, but it happens very rarely and is unusable.
How can I highlight that LOW period and make it more detectable to the Arduino MCU?
Is there something I can do to make the LOW state longer, with some kind of a delay circuit?
Maybe using some Falling Edge detector could work. Maybe there is and IC just for what I need but I just don't know about it.
Or maybe there is some completely other way to do it.
I look forward to your ideas.
Thanks in advance and kind regards
Lukasz
I am a new user on this forum, so first of all a big Hi to everyone that decides to take a look at this thread.
To give you some context to the problem, my project involves using an Arduino Leonardo to make a HID device that will be used as a game controller. It pretty much works and takes in both digital and analogue inputs that can then be mapped to different controls in games.
The digital inputs part is a key matrix with switches that are assigned to the logical buttons on the HID device. For this purpose I use mostly DPDT toggle switches, and wire them in a way that the two positions of the switch use two opposite throws and separate poles, like shown below.
This works well but uses two keys on the key matrix, which in turn means it uses two logical buttons on the HID device. Some games allow you to map the same control to two buttons (e.g. to flip a light ON and OFF), but some don't which makes this not ideal.
So the next thing I tried was to use one pole and connect the two corresponding throws together. This is also shown below.
In this configuration the sense line is always HIGH because the drive line is set high when cycling through the key matrix, and because the switch is always closed due to the shorted throws. While the switch is closed, the logical button on the HID device remains pressed.
There is a short period of time where the state of the sense line is LOW, and this is when the switch is being flicked and the lever is in the middle position right between the two throws, causing the pole not to make contact with neither of the throws. When the flick of the lever is complete the switch is closed again.
This is the equivalent of pressing a button on the HID device, releasing it for a very short period of time and then pressing it again.
The Problem:
The Arduino platform doesn't poll the key matrix fast enough and the LOW state of the sense line is not detected during the fast flick of the switch. This results in the logical button being constantly pressed, even during the flick. While in game, this means that flicking the switch has no effect. On the odd occasion the LOW period is detected and the switch works, but it happens very rarely and is unusable.
How can I highlight that LOW period and make it more detectable to the Arduino MCU?
Is there something I can do to make the LOW state longer, with some kind of a delay circuit?
Maybe using some Falling Edge detector could work. Maybe there is and IC just for what I need but I just don't know about it.
Or maybe there is some completely other way to do it.
I look forward to your ideas.
Thanks in advance and kind regards
Lukasz