The principle of controlling a multi-purpose electronic clock based on PIC16C55 single-chip microcomputer

Publisher:CrystalClearLatest update time:2014-03-03 Source: elecfansKeywords:PIC16C55 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  This electronic clock is controlled by PIC16C55 single-chip microcomputer, which is suitable for timing constant temperature of greenhouse or timing constant pressure control of tap water. The operating voltage of PIC16C55 single-chip microcomputer is 2.5~6.25V, with low power consumption and strong driving ability. This electronic clock can control the on/off of one load three times within 24 hours; a double-limit trigger timing output port can be connected to both traditional power retention relays and pulse relays. This machine uses a four-digit LED digital tube scanning display and a blanking (power saving) working mode, which is very flexible and convenient to use.

  1. Working principle of electronic clock

  The electronic clock circuit is shown in Figure 1. RB7 port is the timing indication port. During the timing on period, it outputs a high level to drive V1 to emit light. This port can also be used as a timing output port through buffering. RB6 is a timing output port controlled by dual-limit triggering. Its working mode is: during the high level period of RB7, if RB1 is high level, RB6 outputs a high level; if RB0 is high level, RB6 outputs a low level; if RB1 and RB0 are both low level, RB6 remains in its original state; when both are high level, RB6 outputs a low level. RB5 and RB4 are used to drive pulse relays. The rising edge of RB6 triggers RB5 to output a high level on pulse; when the falling edge of RB6 triggers RB4, RB4 outputs a high level off pulse. The duration of the on/off pulse is 125ms.

  

 

  Figure 1

  RB3 is a blanking controller. When connected to a high level (i.e. SK1 is closed), the display screen and the flash are normal; otherwise, the display is blanked. When the display is blanked, the clock and various control logics are operating normally. If the driving current of each port from RB4 to RB7 is ignored, the current of the whole machine is less than 20μA when powered by 3V, that is, two No. 5 batteries can be used for several months! RB2 selects the polarity of the digital tube. When RB2 is low level, a common cathode LED is used; when RB2 is high level, a common anode LED is used. The polarity of the digital tube is determined according to the state of the RB2 port during power-on initialization. Changing the level of RB2 during operation will have no effect.

  This machine has four buttons S1~S4. S1 is the function selection button, S2 is for hour increment adjustment, S3 is for minute increment, and S4 is for minute decrement adjustment. The usage is as follows:

  When powered on, RB5 to RB7 are all low level, RB4 sends out a close pulse to close SK1, the whole machine displays and works normally, RC7 sends out a second flash pulse, RC6~RC0 sends field codes. RA3~RA0 are the bit code outputs of 10 hours, hours, 10 minutes, and minutes respectively. At this time, press S2 or S3 (hour increment/minute increment key) to set or reset RB7.

  During normal operation, the seconds flash normally; when checking or setting the timer, the seconds stop flashing. For example: during normal operation, press the S1 key, the seconds stop flashing, and the screen displays J-, indicating that the time can be checked. At this time, press any key from S2 to S4, the screen displays the current time, but the seconds do not flash. At this time, you can press S2 to S4 to check the clock. Press S1 again, the screen displays 1∪, indicating that the first opening time can be set. At this time, press S2 to S4 to view and set the time. Continue to press S1, the system displays 1∩, indicating that the first closing time can be set... Proceed in sequence. After setting the system and the 3 opening and closing times, the whole machine returns to the normal display state and the seconds flash is restored.

  If you want to cancel a certain on/off timing, just set the on and off time to the same value.

  The author has used this clock in a timed and constant pressure water supply control system. The RB6 terminal is used to drive the relay (RB5 and RB4 terminals can also be used to drive the pulse relay), the RB1 terminal is connected to the low limit input of the water pressure (water level), and the RB0 terminal is connected to the high limit input. After setting the timer, a simple timed and constant pressure automatic water supply system is completed. [page]

    2. Programming skills

  The PIC16C55 microcontroller has only 512 bytes of program memory and uses an external 32768Hz crystal oscillator, so the clock speed is low. Therefore, the key to the success of software design is to coordinate the relationship between the system's working sequence and the human-computer interface. This machine programming adopts the following scheme: See Figure 2 for the software workflow.

  

 

  Figure 2

  One machine cycle of the PIC16C55 microcontroller is 4 clock cycles. It is not difficult to calculate that there are 8192 machine cycles per second in this system. When compiling the software, first set the counting method of the internal timing counter F1 of the microcontroller to 64 divisions of the machine cycle. In this way, every time F1 overflows, the system increments by 2 seconds. Normally, the system uses the RC port and RA port to drive and scan the display screen once every 128 machine cycles, which can ensure that the display screen is scanned 64 times per second, and there is basically no flicker. And 128 machine cycles are exactly the interval time of each falling edge of the 0th bit of F1 (abbreviated as F1?0 for ease of description). We can write a program to scan the display screen once when the falling edge of F1?0 arrives. Every time the lower 4 bits of F1 are all 0 (once every 125ms), the system detects the RB port and the button status once and performs related processing. Some related programs are as follows:

  WAIT BTFSC 1, 0; Wait for the falling edge of F1?0, when programming

  GOTO WAIT; Make sure to reach this point before each falling edge

  MOVFW 1

  SKPNZ

  GOTO CLOCK; F1 = 0, full 2 ​​seconds, turn to clock processing

  ANDLW 0FH ; shield F1 high 4 bits

  SKPZ

  GOTO DISPLAY; if the lower 4 bits of F1 are not 0, switch to display

  MOVLW 0C0H ; Full 125mS, reset the RB port pulse

  ANDWF 6,1

  MOVLW 0FH ; Detect key

  TRIS 7

  MOVFW 7

  ANDLW 0FH ;Retain key data

  SKPZ

  GOTO AN; has key value, transfer key processing

  DISPLAY ...; Display scan, timing management RB port

  CLOCK...; Clock, timing processing program

  AN...;Key management program

Keywords:PIC16C55 Reference address:The principle of controlling a multi-purpose electronic clock based on PIC16C55 single-chip microcomputer

Previous article:Simple utility electronic meter solution
Next article:PVS control system circuit board circuit diagram

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号