A Square Wave Phase Shifter Controlled by Serial Port Instructions and a Phase Shifting Method

By designing a square wave phase shifter controlled by serial port instruction, square wave phase shift is achieved using microcontrollers and other components, the problem that the output waveform of the existing phase shifter is easily affected by the input waveform, and precise control and portability are achieved.

CN115185870BActive Publication Date: 2025-06-10NANTONG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210592573.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-27
Publication Date
2025-06-10
Estimated Expiration
2042-05-27

AI Technical Summary

Technical Problem

In the phase shifting operation, the output waveform of the existing phase shifter is easily affected by the input waveform, and is large in size and inconvenient to move. The adjustable phase angle range is less than 90°, making it difficult to meet the needs of modern digital signal processing.

Method used

A square wave phase shifter controlled by serial port instruction is designed, using components such as microcontroller, voltage comparator, signal switching device, USB to serial port chip, etc., to realize square wave phase shifting through serial port instruction control phase shifter to avoid the output waveform being affected by the input waveform.

Benefits of technology

It realizes precise control of phase shift angle, avoids the output waveform being affected by the input waveform, is small in size, is easy to move, and the adjustable phase angle range is greater than 90°, meeting the needs of modern digital signal processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115185870B_ABST
    Figure CN115185870B_ABST
Patent Text Reader

Abstract

The present invention belongs to the technical field of digital signal processing, and specifically relates to a square wave phase shifter and a phase shifting method controlled by serial port instructions, including a single-chip microcomputer, a voltage comparator, a signal switching device, a USB-to-serial port chip, a signal input interface, a signal output interface one, a signal output interface two, and a TYPE-C interface. The phase shifting method includes Mode 1: An external square wave signal is input to the voltage comparator, and after the voltage comparator stabilizes the waveform, it is input to the single-chip microcomputer and output from the signal output interface one through the signal switching device. The single-chip microcomputer delays for a certain time according to the input waveform and outputs through the signal output interface two. Mode 2: Without external signal input, a square wave with a specified frequency and duty cycle is directly generated by the single-chip microcomputer and output from the signal output interface one through the signal switching device. The single-chip microcomputer delays for a certain time based on one path of the output signal and outputs through the signal output interface two.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of digital signal processing, and specifically to a square wave phase shifter controlled by serial port instructions and a phase shifting method. Background Art

[0002] With the development of integrated circuit technology and information processing technology, phase shifting technology plays a crucial role in signal processing circuits, lock-in amplifier circuits for weak signal detection, power research of alternating current signals, and the measurement process of alternating current power. In these related circuits, we can always find the figure of a phase shifter.

[0003] To achieve the phase shift of signal B relative to signal A, one approach is to directly perform phase shift on analog signals, such as resistance-capacitance phase shift, transformer phase shift, etc. However, such phase shifters have many deficiencies: the output waveform is affected by the input waveform, and the phase shift operation is inconvenient; the volume is too large and not easy to move; the phase shift angle drifts due to factors such as the connected load and time; the adjustable range of the phase angle is less than 90°. With the development and improvement of single-chip microcomputer technology, digital phase shifting technology has become the mainstream. Summary of the Invention

[0004] The purpose of this part is to outline some aspects of the embodiments of the present invention and briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this part, as well as in the abstract and title of the present application, to avoid obscuring the purpose of this part, the abstract, and the title. However, such simplifications or omissions shall not be used to limit the scope of the present invention.

[0005] Therefore, the purpose of the present invention is to provide a square wave phase shifter controlled by serial port instructions and a phase shifting method, which can avoid the output waveform being affected by the input waveform.

[0006] To solve the above technical problems, according to one aspect of the present invention, the following technical solutions are provided:

[0007] A square wave phase shifter controlled by serial port instructions, comprising: a single-chip microcomputer, a voltage comparator, a signal switching device, a USB-to-serial port chip, a signal input interface, a first signal output interface, a second signal output interface, and a TYPE-C interface; the signal switching device is composed of pin headers and jumper caps; the signal input interface is electrically connected to the voltage comparator, and the output end of the voltage comparator is respectively electrically connected to the signal switching device and the single-chip microcomputer; the output end of the single-chip microcomputer is respectively electrically connected to the signal switching device and the two output interfaces; the output end of the signal switching device is electrically connected to one output interface; the single-chip microcomputer is electrically connected to the USB-to-serial port chip, and the USB-to-serial port chip is electrically connected to the TYPE-C interface.

[0008] As a preferred solution of a square wave phase shifter controlled by serial port instructions according to the present invention, wherein: the single-chip microcomputer is further connected with a serial port, and the single-chip microcomputer is connected to a USB-to-serial port chip through the serial port.

[0009] As a preferred solution of a square wave phase shifter controlled by serial port instructions according to the present invention, wherein: the model of the single-chip microcomputer is STM32L151C8T6.

[0010] As a preferred solution of a square wave phase shifter controlled by serial port instructions according to the present invention, wherein: the model of the voltage comparator is LM393.

[0011] As a preferred solution of a square wave phase shifter controlled by serial port instructions according to the present invention, wherein: the model of the USB-to-serial port chip is CH340N.

[0012] The phase shifting method of the square wave phase shifter controlled by serial port instructions described in one item includes the following steps:

[0013] Step 1: The external anti-wave signal is input to the voltage comparator, and after the voltage comparator stabilizes the waveform, it is input to the single-chip microcomputer and the signal switching device, and is output from the signal output interface 1 through the signal switching device;

[0014] Step 2: The single-chip microcomputer outputs through the signal output interface 2 after delaying the set time according to the input waveform;

[0015] Or Step A: The single-chip microcomputer generates a square wave with a specified frequency and duty cycle and outputs it from the signal output interface 1 through the signal switching device;

[0016] Step B: The single-chip microcomputer outputs through the signal output interface 2 after delaying the set time on the basis of Step A.

[0017] As a preferred solution of the phase shifting method of the square wave phase shifter controlled by serial port instructions according to the present invention, wherein: the delay time in Step 2 is set by serial port instructions.

[0018] As a preferred solution of the phase shifting method of the square wave phase shifter controlled by serial port instructions according to the present invention, wherein: the frequency and duty cycle of the signal output interface 1 and the delay time of the signal output interface 2 in Step B are set by serial port instructions. Description of the Drawings

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the present invention will be described in detail below in conjunction with the drawings and detailed embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained according to these drawings. Among them:

[0020] Figure 1 is the system structure diagram of the present invention;

[0021] Figure 2 is the circuit schematic diagram of the present invention;

[0022] Figure 3 is the program flow chart of Mode 1 of the present invention;

[0023] Figure 4 is the program flow chart of Mode 2 of the present invention. Detailed implementation manners

[0024] In order to make the above objects, features and advantages of the present invention more obvious and understandable, the following will describe the detailed implementation manners of the present invention in conjunction with the accompanying drawings.

[0025] In the following description, many specific details are set forth in order to fully understand the present invention. However, the present invention can also be implemented in other ways different from those described herein. Those skilled in the art can make similar extensions without departing from the connotation of the present invention. Therefore, the present invention is not limited by the specific implementation manners disclosed below.

[0026] Secondly, the present invention will be described in detail with reference to the schematic diagrams. When describing the embodiments of the present invention in detail, for the convenience of explanation, the cross-sectional views showing the device structure will be enlarged locally out of the general scale, and the schematic diagrams are only examples and should not limit the scope of protection of the present invention herein. In addition, in actual production, three-dimensional spatial dimensions including length, width and depth should be included.

[0027] In order to make the purpose, technical solution and advantages of the present invention clearer, the following will further describe the embodiments of the present invention in detail in conjunction with the accompanying drawings.

[0028] As Figure 1 shown, the present invention includes a single-chip microcomputer 1, a voltage comparator 2, a signal switching device 3, a USB-to-serial port chip 4, a signal input interface 5, a first signal output interface 6, a second signal output interface 7, and a TYPE-C interface 8; the signal switching device 3 is composed of a pin header and a jumper cap. The signal input interface 5 is connected to the voltage comparator 2, and the signal is adjusted by the voltage comparator 2 and then divided into two paths and respectively connected to the signal switching device 3 and the single-chip microcomputer 1; two signals output by the single-chip microcomputer 1 are respectively connected to the signal switching device 3 and the second output interface 7; the output of the signal switching device 3 is connected to the first output interface 6, which is responsible for switching the signals output by the voltage comparator 2 and the single-chip microcomputer 1; the single-chip microcomputer 1 is connected to the USB-to-serial port chip 4 through a serial port, and the USB-to-serial port chip 4 is connected to the TYPE-C interface 8; the TYPE-C interface 8 is connected to a data cable and connected to a computer,

[0029] As Figure 2As shown in the figure, the hardware circuit is divided into the minimum system circuit A of the single-chip microcomputer, the signal input and output circuit B, the TYPE-C interface circuit C, the USB-to-serial port chip circuit D, the serial port signal level conversion circuit E, and the 3.3V signal conversion circuit F.

[0030] As Figure 2 -A shows, the single-chip microcomputer uses STM32L151C8T6 of STMicroelectronics, and a 8MHZ crystal oscillator is used to multiply the frequency through the phase-locked loop inside the single-chip microcomputer to provide a 32M system clock for the single-chip microcomputer.

[0031] As Figure 2 -B shows, in the working condition of Mode 1, use a jumper cap to connect the 1st and 2nd pins of the H2 pin header; the external signal is input from the interface RF-IN to the positive input terminal of the voltage comparator; the resistors R1 and R6 are connected in series to provide a 1.1V reference voltage for the negative input terminal of the voltage comparator. When the external input voltage is less than 1.1V, it is determined as a low level and the output terminal of the voltage comparator outputs 0V. When the external input voltage is greater than 1.1V, it is determined as a high level and the output terminal of the voltage comparator outputs 5V. The output signal of the voltage comparator is connected to the single-chip microcomputer pin PB3 and the signal output interface RF-OUT1.

[0032] As Figure 2 -B shows, in the working condition of Mode 2, use a jumper cap to connect the 2nd and 3rd pins of the H2 pin header; the single-chip microcomputer pin PB0 is connected to RF-OUT1 through a jumper cap.

[0033] As Figure 2 -B shows, in the working modes of Mode 1 and Mode 2, the single-chip microcomputer pin PA7 is connected to RF-OUT2.

[0034] As Figure 2 -C shows, the TYPE-C interface circuit, Function 1: Power the entire circuit board. Function 2: The D+ and D- pins of the TYPE-C interface are connected to the corresponding pins of the USB-to-serial port chip to be responsible for the communication between the computer and the circuit board.

[0035] As Figure 2 -D shows, the USB-to-serial port chip circuit is responsible for the communication protocol conversion, converting the USB protocol to the UART serial port protocol.

[0036] As Figure 2 -E shows, the serial port signal level conversion circuit, the CH340 serial port signal level is 5V, and the single-chip microcomputer serial port signal level is 3.3V. This circuit is used to convert the signal level so that the two sides can communicate normally.

[0037] As Figure 2 -F shows, the linear voltage regulator circuit drops the 5V voltage to 3.3V voltage to power the minimum system of the single-chip microcomputer.

[0038] AsFigure 3 As shown in the figure, for the program flow chart of Mode 1, on the hardware, a jumper cap is used to connect the two pins 1 and 2 of the H2 pin header. PB3 is set as an external interrupt pin, which is responsible for detecting the rising edge and falling edge of the external input signal. When the external interrupt detects a rising edge, the timer TIM2 is started. When the timer TIM2 counts up to the set time, it enters the TIM2 timer interrupt. In the TIM2 interrupt service routine, the PA7 pin is set to 1. When the external interrupt detects a rising edge, the timer TIM3 is started. When the timer TIM3 counts up to the set time, it enters the TIM3 timer interrupt. In the TIM3 interrupt service routine, the PA7 pin is set to 0. In this way, the delay of the second signal relative to the first signal is achieved.

[0039] As Figure 4 shown in the figure, for the program flow chart of Mode 2, on the hardware, a jumper cap is used to connect the two pins 2 and 3 of the H2 pin header. The combination of timer TIM4 and timer TIM6 generates a square wave. TIM4 is responsible for timing the high-level time. When the timer counts up to the set time, it enters the TIM4 timer interrupt. In the TIM4 interrupt service routine, the PB0 pin is set to 0 and the timers TIM3 and TIM6 are started. TIM6 is responsible for timing the low-level time. When the timer counts up to the set time, it enters the TIM6 timer interrupt. In the TIM6 interrupt service routine, the PB0 pin is set to 1 and the timers TIM2 and TIM4 are started. At the same time, the functions of timers TIM2 and TIM3 are the same as those in Mode 1. When the timers TIM2 / 3 count up to the set time, they enter the timer interrupt. In the interrupt service routine, the PA7 pin is set to 1 / 0. The delay of the second signal relative to the first signal is achieved.

[0040] This phase shifter starts working in the default Mode 1 working mode, and then continuously checks whether there is valid data in the serial port receive buffer. If a host computer instruction is received, the corresponding action is executed. The host computer instructions include: switching the working mode, setting the frequency of one output signal in Mode 2, setting the duty cycle of one output signal in Mode 2, and setting the delay time of the second signal relative to the first signal.

[0041] Although the present invention has been described above with reference to the embodiments, various improvements can be made to it and its components can be replaced with equivalents without departing from the scope of the present invention. In particular, as long as there is no structural conflict, the various features in the disclosed embodiments of the present invention can be combined with each other in any way. The exhaustive description of these combinations is not given in this specification only for the sake of saving space and resources. Therefore, the present invention is not limited to the specific embodiments disclosed herein, but includes all technical solutions falling within the scope of the claims.

Claims

1. A square wave phase shifter controlled by serial port instructions, characterized in that, it includes: a single-chip microcomputer (1), a voltage comparator (2), a signal switching device (3), a USB to serial port chip (4), a signal input interface (5), a signal output interface one (6), a signal output interface two (7) and a TYPE-C interface (8); the signal switching device (3) is composed of a pin header and a jumper cap; the signal input interface (5) is electrically connected to the voltage comparator (2), and the output ends of the voltage comparator (2) are respectively electrically connected to the signal switching device (3) and the single-chip microcomputer (1); the output end of the single-chip microcomputer (1) is respectively electrically connected to the signal switching device (3) and the signal output interface two (7); the output end of the signal switching device (3) is electrically connected to the signal output interface one (6); the single-chip microcomputer (1) is electrically connected to the USB to serial port chip (4), and the USB to serial port chip (4) is electrically connected to the TYPE-C interface (8).

2. The square wave phase shifter controlled by serial port instructions according to claim 1, characterized in that, the single-chip microcomputer (1) is also connected with a serial port, and the single-chip microcomputer (1) is connected to the USB to serial port chip (4) through the serial port.

3. The square wave phase shifter controlled by serial port instructions according to claim 1, characterized in that, the model of the single-chip microcomputer (1) is STM32L151C8T6.

4. The square wave phase shifter controlled by serial port instructions according to claim 1, characterized in that, the model of the voltage comparator (2) is LM393.

5. The square wave phase shifter controlled by serial port instructions according to claim 1, characterized in that, the model of the USB to serial port chip is CH340N.

6. A phase shifting method of the square wave phase shifter controlled by serial port instructions according to any one of claims 1-5, characterized in that, it includes the following steps: Step 1: The external anti-wave signal is input to the voltage comparator (2), and after the voltage comparator (2) stabilizes the waveform, it is input to the single-chip microcomputer (1) and the signal switching device (3), and is output from the signal output interface one (6) through the signal switching device (3); Step 2: The single-chip microcomputer (1) outputs through the signal output interface two (7) after delaying for the set time according to the input waveform; or Step A: The single-chip microcomputer (1) generates a square wave with a specified frequency and duty cycle and outputs it from the signal output interface one (6) through the signal switching device (3); Step B: The single-chip microcomputer (1) outputs through the signal output interface two (7) after delaying for the set time on the basis of Step A.

7. The phase shifting method of the square wave phase shifter controlled by serial port instructions according to claim 6, characterized in that, the delay time in Step 2 is set by serial port instructions.

8. The phase shifting method of the square wave phase shifter controlled by serial port instructions according to claim 6, characterized in that, the frequency and duty cycle of the signal output interface one (6) and the delay time of the signal output interface two (7) in Step B are set by serial port instructions.

Citation Information

Patent Citations

  • Comfort control system based on AVR single chip

    CN102426446A

  • Interface level switch device

    CN103916116A