I had another think about K Whittingham’s way of differentiating between long and short pushes, and if it could be used to solve the problem I was going to tackle with a PIC.
The task was to switch on one of three loads.
A sort push selects load 1, and a long push selects load 2 or load 3.
A long push also toggles between 2 and 3.
And if there was a deluxe option, a long push from 1 would return to 2 or 3 depending on from whence state 1 was entered.
I think this state machine would do the job. The numbers indicate which load is ‘on’, and I apologise to those who feel that a state diagram should not be polluted with output conditions.
When I though about it, two of K Whittingham’s circuits, with a tiny bit of diode logic to stop two loads being on at once, would allow the three loads to be selected independently.
Please correct me here if I have made a mistake.
I think this would implement this state machine – ignoring temporary states entered while the button is actually being pushed.
I can see two possible problems:
Switch bounce will almost inevitably clock a ‘1’ through both D-types when it is first pressed, although the correct state will be entered after it is released.
Recovery will be longer than the operating periods because the capacitor charges through more resistors.
Maybe this circuit would help to ameliorate these two? At the expense of a normally-closed push button. Tricky to think of a neat way to get rid of switch bounce problems without an NC switch or an additional RC.
If you respond below, our spam-blocking system may throw away your comment.
Better email email@example.com with ‘LongShort’ in the title.
No email addresses are collected for marketing (or any other) purposes from responses to this blog. I will keep it that way for as long as possible.