Paper, Order, or Assignment Requirements
You are an engineer supposed to program a microcontroller for handling a signalling device. The device has 2 signalling and 3 control LEDs. The signalling LEDs are represented by D0 and D1 on the PIC kit, whereas the control LEDs are D5, D6 and D7.
The device can work in 3 different modes, M0, M1 and M2. In the mode M0, the signalling LEDs D0 and D1 are alternated by clicking the push button for a short time (short click – less than 1s). Every short click makes the active signalling LED to go off and it activates the other signalling LED. For instance, if D0 is active, a short click will turn D0 off and turn D1 on. The next short click will turn D1 off and turn D0 on. This mode is highlighted to a user by turning on the control LED D5 (D6 and D7 have to be off at that time).
In the mode M1, the signalling LEDs D0 and D1 are alternating automatically (no need to click the push button) so that the time interval between two changes is determined by the variable resistor. When the variable resistor is in the minimal position, the time between two alternations is 0.5s and when it is in the maximal position, this time is 1s. This mode is highlighted to a user by turning on D6 (thus, D5 and D7 have to be off).
In the mode M2, the signalling LEDs D0 and D1 are alternating automatically (no push button required), similarly to the mode M1, but in a fast regime each 0.1s. This time remains fixed and cannot be changed by the variable resistor. This mode is highlighted by turning on D7 (while D5 and D6 are off).
The three modes and the associated functions and control LEDs are summarised below in Table 1.
To change between different modes, the push button is used. Whenever a user clicks the push button twice in a short interval (double click – less than 0.25s between two short clicks), the device recognises it as a request to change to the mode M1. If such a double click comes while in the mode M1, it is recognised as a request to change back to the default mode M0. Whenever a user clicks the push button once and long (long click – longer than 1s), it is recognised as a request to change to the mode M2. Similarly, if such a long click comes during the mode M2, the device is changing back to the default mode M0. The double and long clicks are also accepted during the modes M1 and M2, that is, if a double click comes during the mode M2, the device is changing to the mode M1 and vice versa, if a long click comes during M1, the device is changing to M2. These transition rules are summarised below in Table 2.
The meaning of different click types is summarised in Table 3.
D5 on (D6, D7 off)
Alternating manually between D0 and D1 on short click on the push button
D6 on (D5, D7 off)
Alternating automatically between D0 and D1 with the time between alternations determined by the variable resistor. The value obtained from the resistor should be converted linearly into the time interval from 0.5s to 2s, that is, when the resistor is at the minimal position, the corresponding time should be 0.5s, whereas when at the maximal position, the time should be 2s.
D7 on (D5, D6 off)
Alternating automatically between D0 and D1 with the time between alternations fixed at 0.1s.
Table 1: Functions required in all modes
Table 2: Transition between modes
Push button click type
A single push button click which lasts for less than 1s
Two consecutive short clicks with less than 0.25s between them
A single push button click which lasts for more than 1s
Table 3: Definitions of the push button click types
Your task comprises the following:
A. Design an algorithm that will implement the described signalling device.
B. Program the PIC12F675 microcontroller to execute the designed algorithm using the hardware built in the PIC kit.
C. Demonstrate the functional microcontroller to the lecturer and explain the chosen solutions.
D. Make a written individual report with detailed explanations on the selected system specifications and how the programming was implemented. Creative solutions will be especially appreciated. Give also clarifications how the system should behave in case of unplanned use (for instance, changing the potentiometer position during the modes M0 or M2).
You can be quite flexible in designing the system, but the core requirements described above must be met. When completing the task, take the following suggestions into account: