Bryan Mayland
TVWBB Hall of Fame
There's a new AVR firmware snapshot available in the online repository 20160910B.
Ever since the switch to the free-running ADC, the buttons have been less responsive. Sometimes they miss a press, and so you hold it down to get it to work and then it works TOO well and you get too many button presses. It was a pain with the 4-way switch, but nowhere is it more obvious than with the 4 individual buttons of the HeaterMeter v4.3, which have a great tactile SNAP when you press them... but HeaterMeter didn't recognize the press. I spent the last day analyzing the button press waveforms in the oscilloscope and concluded it was not a hardware problem, both the 4-way and individual buttons work amazingly well and always have sharp press transitions and almost always have sharp falloffs. It was clearly a software issue, which is what we knew all along right?
The ADC loop in grillpid samples 255 data points and 3 or 48 discard samples for each 6 ADC inputs. Each sample is 0.105ms so 27.09ms per ADC or 162.54ms per loop. This high latency between button means a press can be missed, especially if it was being pressed during the 27ms poll of the button input (which would be discarded as a transition) so the button would have to be held at least 320ms to be detected.
The new code polls the buttons for just 4 samples in between each of the other full-oversampling ADC readings. This creates a 27ms max latency between button polls and because the sampling period is only 0.42ms there is 50x less of a chance of catching an edge (which is on the order of 100ns). Reducing this to 1 or 2 samples may be beneficial if that is found to be a problem.
As a side effect of the high button latency, the user would hold down the button for longer to get it to respond, which also would create key repeats because they would need to hold it for 160-320ms but then release it in under 250ms. The new code enforces a 250ms lockout of all activity after any button event, although the responsiveness of the buttons now mitigate this issue.
So give it a try and let me know if it feels better. Also please pay careful attention to servo chattering. I tried to make the code as small as possible, but there is more code in the interrupt handler which might mess with our servos again.
Ever since the switch to the free-running ADC, the buttons have been less responsive. Sometimes they miss a press, and so you hold it down to get it to work and then it works TOO well and you get too many button presses. It was a pain with the 4-way switch, but nowhere is it more obvious than with the 4 individual buttons of the HeaterMeter v4.3, which have a great tactile SNAP when you press them... but HeaterMeter didn't recognize the press. I spent the last day analyzing the button press waveforms in the oscilloscope and concluded it was not a hardware problem, both the 4-way and individual buttons work amazingly well and always have sharp press transitions and almost always have sharp falloffs. It was clearly a software issue, which is what we knew all along right?
The ADC loop in grillpid samples 255 data points and 3 or 48 discard samples for each 6 ADC inputs. Each sample is 0.105ms so 27.09ms per ADC or 162.54ms per loop. This high latency between button means a press can be missed, especially if it was being pressed during the 27ms poll of the button input (which would be discarded as a transition) so the button would have to be held at least 320ms to be detected.
The new code polls the buttons for just 4 samples in between each of the other full-oversampling ADC readings. This creates a 27ms max latency between button polls and because the sampling period is only 0.42ms there is 50x less of a chance of catching an edge (which is on the order of 100ns). Reducing this to 1 or 2 samples may be beneficial if that is found to be a problem.
As a side effect of the high button latency, the user would hold down the button for longer to get it to respond, which also would create key repeats because they would need to hold it for 160-320ms but then release it in under 250ms. The new code enforces a 250ms lockout of all activity after any button event, although the responsiveness of the buttons now mitigate this issue.
So give it a try and let me know if it feels better. Also please pay careful attention to servo chattering. I tried to make the code as small as possible, but there is more code in the interrupt handler which might mess with our servos again.