A method and system for controlling a turn signal based on program loop count

By using a program-based loop counting method for turn signal control, which simulates time delay using a software counter, the high failure rate and high cost of traditional turn signal control schemes are solved, achieving high reliability and low cost turn signal control.

CN122481602APending Publication Date: 2026-07-31徐协臣
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
徐协臣
Filing Date
2026-05-08
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Traditional turn signal control schemes rely on circuits composed of electronic components, which suffer from high failure rates, high costs, and susceptibility to temperature effects.

Method used

A turn signal control method based on program loop counting is adopted. The turn signal is controlled by simulating time delay through a software-level program loop counting mechanism and counter, thereby reducing the dependence on microcontroller hardware timer resources.

Benefits of technology

It improves system resource utilization and flexibility, reduces hardware costs, enhances system reliability and independence, and avoids control anomalies caused by hardware conflicts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122481602A_ABST
    Figure CN122481602A_ABST
Patent Text Reader

Abstract

The invention discloses a turn signal control method and system based on program loop counting. The turn signal flashing is controlled by program loop counting at the software level. The no-operation instruction in the main program loop is used in conjunction with the program loop count value to simulate time delay, thereby controlling the switching frequency of the turn signal on and off states. At the same time, the turn signal is automatically turned off by counting the number of flashes. The invention significantly reduces product costs and improves the system's resource utilization and overall flexibility.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of turn signal control technology, specifically to a turn signal control method and system based on program loop counting. Background Technology

[0002] Turn signals are important signaling devices used by vehicles to indicate their turning intentions to other road users. Traditional turn signal control schemes typically rely on circuits composed of electronic components. Specifically, a square wave signal is generated by the electronic components, and then a high-power drive component converts the square wave signal into a turn signal flashing signal.

[0003] However, the aforementioned circuits based on electronic components have two significant technical problems: First, the failure rate is high. In a circuit system using electronic components, if even one component fails, the entire turn signal control will malfunction. Furthermore, electronic components are susceptible to temperature fluctuations, and their turning frequency may change with temperature variations. Second, the cost is high. A circuit system using electronic components includes at least electronic components and a circuit board, requiring suitable space, resulting in high costs. Therefore, a highly reliable and low-cost turn signal control method is urgently needed. Summary of the Invention

[0004] The present invention aims to provide a turn signal control method and system based on program loop counting, which significantly reduces the dependence on microcontroller hardware timer resources, frees up valuable hardware resources for other critical tasks, and improves the system's resource utilization and overall flexibility.

[0005] To achieve the above objectives, the technical solution adopted by this invention is: a turn signal control method based on program loop counting, comprising the following steps:

[0006] S1: Initialize parameters, clear the flashing light count and program loop count to zero, configure the turn signal button interface as input, and configure the turn signal interface as output.

[0007] S2: Detect the status of the turn signal button. If no turn signal button is detected, proceed to S3; if a turn signal button is detected, proceed to S4.

[0008] S3: Clear the flashing light count and program loop count to zero, turn off the turn signals, and jump to S7;

[0009] S4: Determine whether the current flashing count has reached the preset flashing count threshold; if yes, turn off the turn signals and proceed to S7; if no, execute S5.

[0010] S5: Increment the program loop count value by 1, and determine whether the updated program loop count value reaches the preset program loop count threshold; if it does not reach the threshold, proceed directly to S7; if it does reach the threshold, execute S6.

[0011] S6: Change the on / off state of the turn signal, clear the count value of the program loop count to zero, and increment the count value of the flashing lights count by 1;

[0012] S7: Execute a no-operation instruction to consume time, then jump to S2 to continue the loop detection.

[0013] Preferably, a preset flashing number threshold is used to determine how many times the turn signal status changes before it automatically turns off, and a preset program loop number threshold is used to determine how many program loops before the turn signal status changes.

[0014] Preferably, in S7, the duration of the no-operation instruction is set according to the required delay time and the speed at which the processor executes the instruction, and is used in conjunction with the program loop count value in S5 to determine the interval time for the change of the turn signal status.

[0015] On the other hand, the present invention proposes a turn signal control system based on program cycle counting, comprising:

[0016] Memory is used to store computer programs and variable information such as program loop counts and the number of times the light state changes during operation;

[0017] A processor, connected to the memory, is used to execute the computer program to implement the turn signal control method based on program loop counting as described above;

[0018] The input module, connected to the processor, is used to receive the status signals of the turn buttons;

[0019] An output module, connected to the processor, is used to drive the turn signals to turn on and off according to the processor's control signals.

[0020] Preferably, the input module includes an input port connected to a self-locking turn signal button, and the output module includes an output port connected to a turn signal.

[0021] Preferably, the processor controls the flashing frequency of the turn signal and automatically turns it off by executing a program loop count without occupying timer interrupt resources.

[0022] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0023] This invention replaces the traditional square wave oscillator circuit with a software-level program loop counting mechanism to control the flashing of turn signals. It utilizes no-operation instructions in the main program loop, combined with a software counter (program loop count value), to simulate time delays, thereby controlling the switching frequency of the turn signal on / off states. Simultaneously, another software counter (flash count value) counts the number of flashes to automatically turn off the turn signals. It does not rely on microcontroller hardware timer resources, freeing up valuable hardware resources for other critical tasks, improving system resource utilization and overall flexibility. Implemented in the main loop through software logic, it eliminates the need for complex timer interrupt configurations, avoiding the risks of resource conflicts and making the turn signal control logic more independent and robust. Even on low-cost microcontrollers with extremely limited hardware timer resources, it can stably achieve precise flashing frequency control and automatic shutdown of turn signals, effectively reducing hardware costs and improving system reliability. Attached Figure Description

[0024] Figure 1 This is a flowchart of the turn signal control method based on program loop counting according to the present invention. Detailed Implementation

[0025] The following description is intended to disclose the invention and enable those skilled in the art to implement it. The preferred embodiments described below are merely examples, and other obvious variations will occur to those skilled in the art.

[0026] like Figure 1 As shown, this invention proposes a turn signal control method based on program loop counting, comprising the following steps:

[0027] S1: Initialize parameters, clear the flashing light count and program loop count to zero, configure the turn signal button interface as input, and configure the turn signal interface as output. In this example, the flashing light count is a variable. For example, assuming the flashing light count is represented by A, A is set to 0 during initialization. Afterward, A is incremented by 1 every time the light state changes. In step S4, A is compared with a value to determine whether the light should be turned off. The same applies to the program loop count.

[0028] By using software parameterization, the system precisely defines how many times the turn signal should flash before turning off and the duration of a single on / off cycle by using preset flashing frequency thresholds and program loop count thresholds. This fully releases hardware timer resources, reduces chip costs, and enables flexible adjustment of flashing frequency and working cycle. It effectively avoids control anomalies caused by hardware interrupt conflicts and significantly improves the system's independence and reliability.

[0029] S2: Detect the status of the turn signal button. If no turn signal button is detected, proceed to S3; if a turn signal button is detected, proceed to S4.

[0030] By polling the button status in real time, the system can quickly respond to the user's turning intentions and control the logic branches. This ensures that the system can immediately execute the reset and shutdown process to eliminate the risk of malfunction when there is no operation, and seamlessly switch to the flashing counting logic when an operation is detected, thereby ensuring the real-time performance of the control.

[0031] S3: Reset the flashing light count and program loop count to zero, turn off the turn signal, and jump to S7; This step immediately resets the dual counters and turns off the lights when no turn button is detected, forcing the system to reset to the initial safe state. This not only ensures that the turn signal can be turned off immediately to comply with driving regulations, but also completely eliminates the risk of false flashing or logical errors on the next start due to residual count values.

[0032] S4: Determine whether the current flash count has reached the preset flash count threshold; if yes, control the turn signal to turn off and jump to S7; if no, execute S5; by comparing the cumulative flash count with the preset threshold in real time, the total working time of the turn signal is precisely limited by software, ensuring that it will be automatically and forcibly turned off after the predetermined flashing cycle is completed.

[0033] S5: Increment the program loop count value by 1, and determine whether the updated program loop count value reaches the preset program loop count threshold; if not, jump directly to S7; if it has reached the threshold, execute S6; by using the program loop count to build a software delay mechanism, the duration of a single on / off cycle is precisely controlled without occupying hardware timer resources, thereby achieving flexible adjustment of the flashing frequency; at the same time, by determining whether the threshold is reached to trigger the state flip, the stability of the light on / off cycle is ensured.

[0034] S6: Change the on / off state of the turn signal, reset the program loop count to zero, and increment the flashing count by 1; change the on / off state of the turn signal so that if it is on, it becomes off, and if it is off, it becomes on. After the on / off state of the light changes, reset the program loop count to zero, and restart the next program loop count; because the state of the light has changed, the flashing count is also incremented by 1.

[0035] S7: Execute a no-operation instruction to consume time, then jump to S2 to continue the loop detection.

[0036] The duration of the no-operation instruction is set according to the required delay time and the speed at which the processor executes instructions. It is used in conjunction with the program loop count value in S5 to determine the interval time for the turn signal status change.

[0037] By using no-operation instructions to build a software delay baseline, and in conjunction with loop counting, high-precision blinking timing control is achieved. It can flexibly adapt to the main frequency characteristics of different processors without relying on additional hardware timers, thus ensuring the uniformity and stability of the turn signal on / off interval.

[0038] On the other hand, the present invention proposes a turn signal control system based on program cycle counting, comprising:

[0039] Memory is used to store computer programs and variable information such as program loop counts and the number of times the light state changes during operation;

[0040] A processor, connected to the memory, is used to execute the computer program to implement the turn signal control method based on program loop counting as described above;

[0041] An input module, connected to the processor, is used to receive status signals from the turn signals; the input module includes an input port connected to the self-locking turn signals.

[0042] An output module, connected to the processor, includes an output port connected to the turn signal, used to drive the turn signal to turn on or off according to the control signal from the processor.

[0043] In addition, the processor controls the flashing frequency of the turn signals and enables automatic shut-off by executing program loop counting without occupying timer interrupt resources.

[0044] Furthermore, the components in the above system are also used to implement the following methods:

[0045] The processor receives the turn signal button signal. When the processor does not receive the information that the turn signal button has been pressed, it resets the number of flashing lights and the number of program loops to zero and turns off the turn signal so that it can be processed correctly when the turn signal button is pressed in the next loop.

[0046] When the processor receives information that the turn signal button has been pressed, it first checks whether the number of turn signal flashes has reached the set number. If it has, the turn signal should be turned off even if the button has been pressed.

[0047] If the turn signal flashing count has not reached the set number, the turn signal flashing procedure is executed. First, the program loop count is incremented by 1. Then, it checks if the loop count has reached the set value. If not, no action is taken; if it has, it indicates that the current state of the light (on or off) has been in place for a period of time and needs to be changed. The light state is then changed, the program loop count is reset to zero, and the flashing count is incremented by 1. A no-op occurs at the end of the program, which acts as a delay to reduce the number of loops. After the no-op, the program jumps to the button check and enters the loop state.

[0048] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention. The scope of protection claimed by the appended claims and their equivalents is defined.

Claims

1. A method of controlling a turn signal based on program loop count, the method comprising: Includes the following steps: S1: Initialize parameters, clear the flashing light count and program loop count to zero, configure the turn signal button interface as input, and configure the turn signal interface as output. S2: Detect the status of the turn signal button. If no turn signal button is detected, proceed to S3; if a turn signal button is detected, proceed to S4. S3: Clear the flashing light count and program loop count to zero, turn off the turn signals, and jump to S7; S4: Determine whether the current flashing count has reached the preset flashing count threshold; if yes, turn off the turn signals and proceed to S7; if no, execute S5. S5: Increment the program loop count value by 1, and determine whether the updated program loop count value reaches the preset program loop count threshold; if it does not reach the threshold, proceed directly to S7; if it does reach the threshold, execute S6. S6: Change the on / off state of the turn signal, clear the count value of the program loop count to zero, and increment the count value of the flashing lights count by 1; S7: Execute a no-operation instruction to consume time, then jump to S2 to continue the loop detection.

2. The program cycle count based turn signal control method of claim 1, wherein, The preset flashing number threshold is used to determine how many times the turn signal status changes before it automatically turns off, and the preset program loop number threshold is used to determine how many program loops before the turn signal status changes.

3. The program cycle count based turn signal control method of claim 1, wherein, In S7, the duration of the no-operation instruction is set according to the required delay time and the speed at which the processor executes instructions. This is used in conjunction with the program loop count value in S5 to determine the interval time for the turn signal status change.

4. A program cycle count based turn signal control system characterized by, include: The memory is used to store the computer program and preset thresholds for the number of flashing lights and the number of program loops. A processor, connected to the memory, is configured to execute the computer program to implement the turn signal control method based on program loop counting as described in any one of claims 1 to 3; The input module, connected to the processor, is used to receive the status signals of the turn buttons; An output module, connected to the processor, is used to drive the turn signals to turn on and off according to the processor's control signals.

5. The program cycle count based turn signal control system of claim 4, wherein, The input module includes an input port connected to a self-locking steering button, and the output module includes an output port connected to a turn signal.

6. The program cycle count based turn signal control system of claim 4, wherein, The processor controls the flashing frequency of the turn signals and enables them to automatically turn off by executing a program loop count without occupying timer interrupt resources.