In addition, we suggest the following instruments:
Microprocessor-based systems that we use today, such as coffee makers and microwave ovens, require a human-machine interface (HMI). HMI inputs are implemented with some type of electromechanical device such as touch pads, push buttons, toggles, and rotary switches. Such devices rarely produce clean (noise free) logical signals to the inputs of high speed digital electronics. Special software and/or hardware is required to reduce or entirely eliminate the noise from these signals.
The design challenge titled “Push-on/Push-off Buttons” presented on the Digilent Learn website targets the chipKIT Pro circuit board. This lab modifies the requirements to include non-blocking button press and release detection using change notification interrupts. The requirements are:
Write the code that converts the three momentary contact pushbuttons to operate as push-on/push-off buttons and that satisfies the following specifications:
Digital logic can be classified as combinational or sequential. Combinational circuits are logic circuits whose outputs respond immediately to the current inputs, as was presented in Lab 1a. No memory circuits are required for combinational logic circuits. In a sequential logic circuit, the outputs depend on the current inputs plus state, requiring some form of memory. In hardware, memory is provided by flip-flops, latches, and counters. Principle of Equivalence of Hardware and Software: Anything that can be done with software can also be done with hardware, and anything that can be done with hardware can also be done with software. The exception to this principle is speed of implementation. Hardware has considerably faster time response. This is true of discrete logical electronic devices but even more so with modern FPGAs.
Momentary contact switches have one stable state, that being when the switch is in the relaxed condition. A push-on/push-off switch is a type of a mechanical toggle switch that has two stable states. The common approach to implementing a push-on/push-off operation with a momentary contact push button is to provide some type of memory which is usually electronic in nature, such as a flip-flop or latch. Section 7.6 of Unit 2 presents a state machine implementation of the push-on/push-off toggle switch. Since we want to detect the push button operations using change notification interrupts that detect both openings and closings, the state machine presented in Unit 2 has four stable states.
Electromechanical devices, such as switches and relays that are commonly used for microprocessor inputs, are mass-spring devices that will result in contact bounce when opening and closing. Combinational logic circuits will see the multiple contact closures and openings as multiple events unless signal conditioning circuits are used. Usually some type of delay after the initial contact operation is implemented so subsequent operations are ignored for a period of time. The delay can be implemented using an analog low-pass circuit with a resistor and capacitor in addition to electronic devices. Such circuits are costly in terms of circuit board real-estate. As an alternative, there are specialty electronic circuits as well as FPGA designs that can be used to remove contact bounce.
High speed modern microprocessors are also subject to contact bounce issues. Contact bounce issues can be mitigated using simple time delays, such as the polling software delay used in Lab 1b; however, this delay implementation is a blocking procedure that inhibits the processor from executing code for another task during the delay period. Delays implemented with interrupts are used to notify the processor to execute code for another application task and to notify again when the delay period has expired. This implementation of a delay is non-blocking.