[Menu]>[Guide to use the PIC]>[Circuits Gallery]>[Digital Clock]

Operation confirmation of Digital Clock

I found the following improvement point after making an actual circuit and confirming in the operation. A clock was slow. When measuring count time of 1 second, it had been delayed compared with the correct clock. There was a mistake in the processing which makes time of 1 second as a result of the investigation. 1 second is made by counting 20 milliseconds 50 times. At first, if being equal to or less than 50, it was doing the processing which updates a counter. In this case, it counts in the extra of 1 count because it is increasing a count after checking. 1 correct second could be made by correcting checking data to 49. It wasn't possible to have done time setting in the rotary encoder. When a rotary encoder was turned, the whole clock display blinked once. And it wasn't possible to do time setting. Also, when a rotary encoder was turned, it had returned to the position of tens of hour after changing the time setting position. The cause was to do the influence being of the capacitor to have put between the encoder circuit and the grounding. 0.1uF was used for the capacitor. When a rotary encoder was turned and A terminal or B terminal was connected with +5V, the electric current flowed through the capacitor rapidly and +5V voltage went down. Therefore, the power of PIC became OFF and was initialized. A capacitor was put to prevent from the chattering of the rotary encoder. However, because this clock is preventing a chattering by the software, the capacitors aren't necessary. After removing capacitors, PIC became never initialized. In spite of this change, it wasn't possible to do time setting by the encoder. This cause was to be because the resistance value(10K-ohm) to put between the encoder and the grounding was big. The voltage of the terminal of PIC didn't become an L level in the condition of OFF in the encoder. It became possible to do normal time setting by changing a resistance value into 1K-ohm. The time setting of units of hour in PM1x was abnormal. First, it set units of hour to "9" in the condition of PM0x. After, it set tens of hour to PM1x. In this condition, when increasing the count of units of hour, an abnormally display was done to units of hour. It didn't become a figure. In case of PM1x, only three kinds(0,1 and 3) are made to be able to be set to units of hour. In the previous processing, it judged in the condition which is equal to 2 as the upper limit judgment. Therefore, when units of hour was 9, it was increasing a count simply because it was not 2. As a result, it referred to the data which exceeded 7 segment tables and an abnormally display was done. It changed the processing into "equal to or more than 2" judgment and it became able to be normally set. The count-down processing with PM1x was similar too. It wasn't possible to do normal time setting because the units of hour was only the judgment of "0". The normal setting became possible by putting "equal to or more than 3" judgment. This clock can set to AM1x or PM1x after setting the units of hour to 9(The figure which is not 0, 1, 2). So, the setting of AM19 or PM17 .. has become possible. It isn't checking about this. The blink interval of time setting was changed into 200 milliseconds. At first, this blink interval was 500 milliseconds. In case of 500 milliseconds, it is difficult to watch the display of the change time. It was changed into the 200-millisecond interval. When changed into the time setting mode, the setting position had become units of hour. When changed with the time setting mode, tens of hour is set as the setting position. However, it had become the position of units of hour. The cause was to be because it didn't set the last look data of RB7. By pressing RB7 continuously for 2 seconds, it becomes a time setting mode. However, when the last look of RB7 was 0, it recognized that RB7 changed and it shifted one setting position. The position gets to shift when RB7 is pressed next if setting the last look of RB7 to 1 when becoming a time setting mode. When the time setting mode ends, the error occurs to the setting in 0 seconds. Even if a setting switch in 0 seconds was pushed according to 0 seconds when the time setting ends, the error occurred to the setting in the second.(Becoming 1 second immediately so on) The cause was to be because when becoming a clock mode from the time setting mode the counter which counts 1 second wasn't cleared. It solved in clearing a counter in 1 second when becoming a time setting mode. The checking of setting in 0 seconds is done in the 20-millisecond interval. So, the a maximum of 20-millisecond error occurs. I think there is no problem in case of practical use by this error. It is delayed about 1 second in a day. The clock was delayed about 1 second in a day. First, I was confirming the operation of the PLL oscillator, thinking that the PLL oscillator didn't synchronize with the color burst signal of the TV. However, it was doing normal operation in 10000.0000KHz when measuring by the frequency counter. The cause was to do the mistake being of the logic of CPLD which makes 50Hz from 10MHz. The 1/200000 counter is composed of 1/100000 counter and 1/2 counter. I judged 1/100000 count at 100000. The right value is 99999. Therefore, it became the counter of 1/200002. In case of the wrong logic, to be delayed in 1 second is caused by 100000 seconds. Because a day is 86400 seconds, it is delayed 0.86 seconds in a day. The output of the counter of CPLD becomes 49.9995 Hz in the calculation. According to the detailed measurement, there is possibility to have found a mistake.