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
Previous article:Simple utility electronic meter solution
Next article:PVS control system circuit board circuit diagram
- Popular Resources
- Popular amplifiers
- MCU Principles and Interface Technology C51 Programming (Edited by Zhang Yigang)
- Chip Manufacturing: A Practical Tutorial on Semiconductor Process Technology (Sixth Edition)
- Example interpretation of 51 single chip microcomputer complete learning and application
- Example interpretation of 51 single chip microcomputer complete learning and application
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- [RT-Thread reading notes] Week 4: Digest the first six chapters and fill in the gaps
- Steam oven water level detection - which one is more suitable, the float type or the photoelectric type?
- POE PD+DCDC non-isolated solution
- Help: Transformer detection of low frequency or DC residual current
- How to realize network remote control of balance car? ?
- Help with max30102 heart rate and blood oxygen test module issues
- November 10th prize-winning live broadcast: Protecting clean water sources - ADI water quality monitoring program registration is open~
- FOC sensorless motor control video
- Implementation of a sensorless, low-cost, high-speed, low- and medium-power BLDC controller
- Design of embedded network interface controller based on FPGA