QCX assembly Rev 1.08
118
All mechanical switches exhibit switch bounce, where the switch contacts generate multiple
transitions for a short time when the switch is activated. It is common to see in many projects,
resistor-capacitor networks to debounce switches (including the rotary switch). Simple debounce
circuits involving a resistor and a capacitor inevitably involve a compromise when choosing the R-
C time constant. It is easy to miscalculate and make the time constant too short (bounce noise still
gets through) or too long (rapid switch closures are missed). In some cases it is impossible to find
the sweet spot in between these two extremes.
In my opinion, resistor/capacitor debouncing is a poor solution to the problem, when the circuit
contains a microcontroller. It is easy to debounce the switch edges in software! This allows you to
control time-constants or other debounce logic much more precisely. Of course, it saves those
additional resistors and capacitors too, which all helps reduce the cost and complexity of the kit!
This is the reason why in this kit, you will not see any resistor or capacitor debouncing of any of
the controls. Everything is done in the software.
The rotary encoder is debounced using a state
machine, rather than any timing loops. The rotary
encoder produces two switch-closure outputs which
have a 90-degree (quadrature, again) phase shift.
The microcontroller can monitor these transitions
and determine the number of “clicks” of the rotary encoder, and the direction the knob was turned
in, and at the same time debounce the switch transitions.
Another unnecessary component often seen is a pullup-resistor on a switch signal to a
microcontroller, so that when the switch is open (not pressed) the microcontroller sees a “high”
voltage. This is unnecessary because modern microcontrollers such as the ATmega328P all
contain configurable internal pull-ups!
I had a little more trouble when it came to the Left, Centre (shaft of the rotary encoder) and Right
push-buttons. Despite thinking that the microcontroller had plenty of I/O signals available, when I
came to implement all the features I had in mind, I realised there weren’t enough I/O signals to
read the buttons!
The solution was to analogue-multiplex all three buttons onto a single input signal to the
microcontroller, which is one of the Analogue to Digital Converter (ADC) channels. No
microcontroller internal pull-up is used because I need to have precise control over the voltage
levels. The input signal is pulled low by a 10K resistor R46. One side of all three buttons is
connected to the I/O pin. The other sides of the buttons are connected to 5V via different resistors:
3.3K (R44) for the left button, 1K (R45) for the right button, and direct connection for the centre
button. When one of the buttons is pressed, the resistors form a potential divider that sets the
voltage to the microcontroller depending on which button is pressed. Some calculation results in
the following table of voltages depending on which button is pressed:
Button pressed Voltage
None
0.00V
Left
3.76V
Centre
5.00V
Right
4.55V
Содержание QCX 5W CW
Страница 9: ...QCX assembly Rev 1 08 9...
Страница 10: ...QCX assembly Rev 1 08 10...
Страница 12: ...QCX assembly Rev 1 08 12...
Страница 26: ...QCX assembly Rev 1 08 26 3 19 Install 20MHz crystal XTAL1 The engraving on this crystal is 20 000...
Страница 50: ...QCX assembly Rev 1 08 50...
Страница 105: ...QCX assembly Rev 1 08 105...