Electronic equipment, dof sensor and temperature sensor

By designing the current generation circuit, oscillator and counting circuit in the temperature sensor, the temperature correlation between the current and the clock is used to simplify the counting process, solve the problems of sensor miniaturization and low efficiency, and achieve efficient temperature detection.

CN118603341APending Publication Date: 2024-09-06SHENZHEN ADAPS PHOTONICS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410776674.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

After the existing temperature sensor is reduced in size in the integrated circuit, it is difficult to achieve miniaturization and the complex counting circuit results in low temperature detection efficiency.

Method used

Design a temperature sensor, including a current generation circuit, an oscillator and a counting circuit. The current generates a current that changes with temperature. The oscillator generates a temperature-related clock. The counting circuit uses two D flip-flop counters to count the clocks respectively. When the predetermined value is reached, Output temperature information to simplify the counting process.

Benefits of technology

The effectiveness of temperature detection and the miniaturization of the sensor are achieved, the counting circuit structure is simplified, and the reliability and efficiency are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118603341A
    Figure CN118603341A
Patent Text Reader

Abstract

The invention discloses an electronic device, a dof sensor and a temperature sensor, which are applied to the technical field of temperature detection, and comprise a current generation circuit used for generating a current changing along with the temperature; the oscillator is connected with the current generation circuit and used for generating a first clock based on the current, and the frequency of the first clock changes along with the temperature; the counting circuit comprises a first counter and a second counter, the first counter is connected with the oscillator, the second counter is used for counting the number of second clocks to obtain a second count value, and the second clocks do not change along with the temperature; the first counter is used for counting the number of the first clocks to obtain a first count value; the first counter and the second counter start counting at the same time, and when the first counting value reaches a preset value, a second counting value at the current temperature is obtained to serve as output of the counting circuit. By applying the scheme of the invention, temperature detection can be effectively realized, and miniaturization of the temperature sensor is guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of temperature detection, and in particular to an electronic device, a DTof sensor and a temperature sensor. Background Art

[0002] In some cases, it is necessary to perform real-time temperature detection on chips and other devices. As the process size of integrated circuits continues to shrink and the integration level continues to increase, not only does the heat dissipation problem become more and more important, but the size requirements for temperature sensors are also increasing. For example, in some ADCs (Analog to Digital Converters), if the area of ​​the temperature sensor is too large, the ADC area will be too large, making it inconvenient to arrange the ADC.

[0003] In some current solutions, an RC oscillator is used to realize temperature acquisition, and then the frequency is calculated through a counting circuit. The temperature value is obtained based on the relationship between frequency and temperature. Since the operation of calculating the frequency is relatively complicated, the counting circuit will be more complicated and also requires the use of certain computing resources, which is not conducive to the miniaturization of the temperature sensor.

[0004] In summary, how to effectively realize temperature detection and ensure the miniaturization of the temperature sensor is a technical problem that technicians in this field urgently need to solve. Summary of the invention

[0005] The object of the present invention is to provide an electronic device, a dtof sensor and a temperature sensor, so as to effectively realize temperature detection and ensure the miniaturization of the temperature sensor.

[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0007] In a first aspect, the present invention provides a temperature sensor, comprising:

[0008] A current generating circuit for generating a current that varies with temperature;

[0009] an oscillator, connected to the current generating circuit, and configured to generate a first clock based on the current, wherein the frequency of the first clock varies with temperature;

[0010] A counting circuit includes a first counter and a second counter, wherein the first counter is connected to the oscillator, the second counter is used to count the number of second clocks to obtain a second count value, and the second clock does not change with temperature; the first counter is used to count the number of the first clocks to obtain a first count value; the first counter and the second counter start counting at the same time, and when the first count value reaches a predetermined value, the second count value at the current temperature is obtained as the output of the counting circuit.

[0011] In one implementation, the output of the first counter is represented by n1 binary numbers; the output of the second counter is represented by n2 binary numbers, where n2>n1.

[0012] In one implementation, the first counter includes n1 D flip-flops from the A_1th D flip-flop to the A_n1th D flip-flop; the second counter includes n2 D flip-flops from the B_1th D flip-flop to the B_n2th D flip-flop;

[0013] The D end of each D flip-flop in the first counter is connected to its own QN end, the clock end of the A_1th D flip-flop is connected to the first clock, the clock end of the A_2th D flip-flop is connected to the QN end of the A_1th D flip-flop, and so on, the clock end of the A_n1th D flip-flop is connected to the QN end of the A_(n1-1)th D flip-flop, and the Q end of the A_1th D flip-flop to the Q end of the A_n1th D flip-flop are sequentially used as the low to high bits of the output of the first counter;

[0014] The D end of each D flip-flop in the second counter is connected to its own QN end, the clock end of the B_1th D flip-flop is connected to the second clock, the clock end of the B_2th D flip-flop is connected to the QN end of the B_1th D flip-flop, and so on. The clock end of the B_n2th D flip-flop is connected to the QN end of the B_(n2-1)th D flip-flop, and the Q end of the B_1th D flip-flop to the Q end of the B_n2th D flip-flop are sequentially used as the low to high bits of the second counter output.

[0015] In one embodiment, the counting circuit further includes a sample-and-hold device, the sample-and-hold device includes from the C_1th D flip-flop to the C_n2th D flip-flop, a total of n2 D flip-flops, and also includes from the 1st selector to the n2th selector;

[0016] The D end of each D flip-flop is connected to the output end of the corresponding selector, the selection control end of each selector is connected to the FLAG signal, the first input end of each selector is connected to the Q end of the corresponding D flip-flop, and the second input end of each selector is respectively connected to the low bit to the high bit output by the second counter; the clock end of each D flip-flop is connected to the second clock;

[0017] When the first count value reaches a predetermined value, the FLAG signal is at a high level, and when the first count value does not reach the predetermined value, the FLAG signal is at a low level;

[0018] When the FLAG signal is at a high level, each selector selects the output value of the second counter sampled at this time and outputs it to its corresponding D flip-flop, and the Q-end outputs of all D flip-flops serve as the output of the counting circuit;

[0019] When the FLAG signal is at a low level, each selector selects the output value of the second counter sampled last time and outputs it to its corresponding D flip-flop, and the Q-end outputs of all D flip-flops serve as the output of the counting circuit to maintain the last output result.

[0020] In one implementation, if the current is a current with a negative temperature coefficient, the current generating circuit includes: a first triode, a first resistor, a first operational amplifier, a first PMOS transistor, a second PMOS transistor, and a third PMOS transistor;

[0021] The base and collector of the first transistor are grounded, the inverting input terminal of the first operational amplifier is respectively connected to the emitter of the first transistor and the drain of the second PMOS transistor, the non-inverting input terminal of the first operational amplifier is respectively connected to the drain of the first PMOS transistor and the first end of the first resistor, and the output terminal of the first operational amplifier is respectively connected to the gate of the first PMOS transistor and the gate of the third PMOS transistor;

[0022] The source of the first PMOS tube, the source of the second PMOS tube and the source of the third PMOS tube are all connected to the positive electrode of the first power supply, and the drain of the third PMOS tube serves as the output end of the current generating circuit to output a current with a negative temperature coefficient that changes with temperature.

[0023] In one embodiment, if the current is a current with a positive temperature coefficient, the current generating circuit includes: a first branch with a second end grounded, a second branch with a second end grounded, a fourth NMOS transistor, a fifth NMOS transistor, a sixth PMOS transistor, a seventh PMOS transistor and an eighth PMOS transistor;

[0024] The first branch includes a second resistor and N PNP transistors connected in parallel, the first end of the second resistor serves as the first end of the first branch, the bases and collectors of the N PNP transistors in the first branch are grounded, and the emitters of the N transistors are connected to the second end of the second resistor;

[0025] The second branch includes M PNP transistors connected in parallel, bases and collectors of the M PNP transistors in the second branch are grounded, emitters of the M PNP transistors in the second branch are connected to each other and serve as the first end of the second branch; M and N are both positive integers and M<N;

[0026] The source of the fourth NMOS tube is connected to the first end of the first branch, the source of the fifth NMOS tube is connected to the first end of the second branch, and the gate of the fourth NMOS tube is connected to the gate of the fifth NMOS tube and the drain of the fifth NMOS tube respectively;

[0027] The drain of the fourth NMOS tube is respectively connected to the drain of the sixth PMOS tube, the gate of the sixth PMOS tube, the gate of the seventh PMOS tube, and the gate of the eighth PMOS tube;

[0028] The source of the sixth PMOS tube, the source of the seventh PMOS tube, and the source of the eighth PMOS tube are all connected to the positive electrode of the second power supply, and the drain of the seventh PMOS tube is connected to the drain of the fifth NMOS tube;

[0029] The drain of the eighth PMOS tube serves as the output end of the current generating circuit to output a current with a positive temperature coefficient that changes with temperature; the sizes of the fourth NMOS tube, the fifth NMOS tube, the sixth PMOS tube, the seventh PMOS tube and the eighth PMOS tube are adjusted so that the voltage of the first end of the first branch is equal to the voltage of the first end of the second branch.

[0030] In one implementation, the oscillator includes a first comparator, a second comparator, an RS trigger, a first capacitor, a second capacitor, a ninth PMOS transistor, a tenth NMOS transistor, an eleventh PMOS transistor, a twelfth NMOS transistor, a third resistor, and a fourth resistor;

[0031] The first input end of the first comparator is respectively connected to the first input end of the second comparator, the second end of the third resistor and the first end of the fourth resistor, the first end of the third resistor is connected to the positive electrode of the third power supply, and the second end of the fourth resistor is grounded;

[0032] The output end of the first comparator is connected to the R end of the RS trigger, and the output end of the second comparator is connected to the S end of the RS trigger;

[0033] The second input end of the first comparator is respectively connected to the first end of the first capacitor, the drain of the ninth PMOS tube and the drain of the tenth NMOS tube; the second input end of the second comparator is respectively connected to the first end of the second capacitor, the drain of the eleventh PMOS tube and the drain of the twelfth NMOS tube;

[0034] The output end of the current generating circuit is connected to the source of the ninth PMOS tube and the source of the eleventh PMOS tube, the gate of the ninth PMOS tube and the gate of the tenth NMOS tube are connected to the Q end of the RS trigger, and the gate of the eleventh PMOS tube and the gate of the twelfth NMOS tube are connected to the QN end of the RS trigger; the second end of the first capacitor, the second end of the second capacitor, the source of the tenth NMOS tube and the source of the twelfth NMOS tube are all grounded;

[0035] The Q terminal or the QN terminal of the RS trigger serves as the output terminal of the oscillator to output the first clock.

[0036] In a second aspect, the present invention provides a DTof sensor, comprising the temperature sensor as described above.

[0037] In a third aspect, the present invention provides an electronic device, comprising the temperature sensor as described above, the electronic device further comprising: a controller and a memory;

[0038] The memory is used to store the corresponding relationship between the second count value and the temperature;

[0039] The controller is used to search for the corresponding relationship according to the second count value at the current temperature, so as to obtain the current temperature value.

[0040] In one implementation, the process of determining the corresponding relationship includes:

[0041] Divide K temperature values ​​within the temperature variation range from T1 to T2;

[0042] For each divided temperature value, when the temperature sensor is in an environment of the temperature value, when the first count value reaches a predetermined value, a second count value at the current temperature is recorded, and it is determined that the current temperature value corresponds to the second count value;

[0043] After testing is performed in turn at each divided temperature value, the established corresponding relationship is obtained.

[0044] In one implementation, if the current generated by the current generating circuit is a current with a negative temperature coefficient, the corresponding relationship is: the higher the temperature, the larger the second count value;

[0045] If the current generated by the current generating circuit is a current with a positive temperature coefficient, the corresponding relationship is: the higher the temperature, the smaller the second count value.

[0046] By applying the technical solution provided by the embodiment of the present invention, the current generating circuit can generate a current that varies with temperature, and the oscillator is connected to the current generating circuit, and a first clock can be generated based on the current output by the current generating circuit, and the frequency of the first clock varies with temperature, which means that the frequency of the first clock reflects the current temperature. In addition, since the present application adopts the design of an oscillator, it is conducive to miniaturization of the temperature sensor. The counting circuit is provided with a first counter and a second counter, and the second counter is used to count the number of the second clock to obtain a second count value, and the second clock does not vary with temperature, that is, the second clock can be used as a reference clock. The first counter needs to be connected to the oscillator, and the first counter is used to count the number of the first clock to obtain the first count value. Since the first counter and the second counter start counting at the same time, when the first count value reaches a predetermined value, the second count value at the current temperature can be obtained as the output of the counting circuit. It can be understood that when the temperature is different, the time taken for the first count value to reach the predetermined value is different, which makes the second count value different, so the second count value output by the counting circuit can reflect the current temperature. In addition, it can be seen that in the solution of the present application, the second count value output by the counting circuit is used to reflect the current temperature. The entire process does not require the calculation of any frequency value, which makes the counting circuit structure of the present application simple and highly reliable, and is also conducive to the miniaturization of the temperature sensor of the present application.

[0047] In summary, the solution of the present application can effectively realize temperature detection and ensure the miniaturization of the temperature sensor. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0049] Figure 1 A schematic diagram of the structure of a temperature sensor provided by a specific embodiment of the present invention;

[0050] Figure 2A schematic diagram of the structure of a current generating circuit for outputting a negative temperature coefficient current in a specific implementation manner of the present invention;

[0051] Figure 3 A schematic diagram of the structure of a current generating circuit for outputting a positive temperature coefficient current in a specific implementation manner of the present invention;

[0052] Figure 4 A schematic diagram of the structure of an oscillator in a specific implementation manner of the present invention;

[0053] Figure 5 It is a schematic diagram of the structure of the first counter and the second counter in a specific implementation manner of the present invention;

[0054] Figure 6 A schematic diagram of the structure of a sample holder in a specific implementation manner of the present invention;

[0055] Figure 7 It is a schematic diagram of the corresponding relationship established in a specific implementation manner of the present invention. DETAILED DESCRIPTION

[0056] The core of the present invention is to provide an electronic device, a dtof sensor and a temperature sensor, which can effectively realize temperature detection and ensure the miniaturization of the temperature sensor.

[0057] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0058] Please refer to Figure 1 , Figure 1 This is a schematic diagram of the structure of a temperature sensor provided in a specific embodiment of the present invention. The temperature sensor may include:

[0059] The current generating circuit 10 is used to generate a current that varies with temperature;

[0060] an oscillator 20 connected to the current generating circuit 10 and configured to generate a first clock based on the current, wherein the frequency of the first clock varies with temperature;

[0061] The counting circuit 30 includes a first counter 31 and a second counter 32. The first counter 31 is connected to the oscillator 20. The second counter 32 is used to count the number of second clocks to obtain a second count value, and the second clock does not change with temperature. The first counter 31 is used to count the number of first clocks to obtain a first count value. The first counter 31 and the second counter 32 start counting at the same time. When the first count value reaches a predetermined value, the second count value at the current temperature is obtained as the output of the counting circuit 30.

[0062] Specifically, in the scheme of the present application, it is necessary to utilize a current generating circuit 10 to generate a current that varies with temperature. The specific circuit structure of the current generating circuit 10 can be set and adjusted according to actual needs. The current that varies with temperature can be a current with a positive temperature coefficient or a current with a negative temperature coefficient. However, it can be understood that a current generating circuit 10 that can output a current that varies with temperature and whose output current is little affected by factors other than temperature can be used, which is beneficial to ensure the accuracy of the temperature sensor of the scheme of the present application.

[0063] For example, in a specific embodiment of the present invention, if the current is a current with a negative temperature coefficient, the current generating circuit 10 includes: a first transistor P1, a first resistor R1, a first operational amplifier OP1, a first PMOS transistor Q1, a second PMOS transistor Q2, and a third PMOS transistor Q3;

[0064] The base and collector of the first transistor P1 are grounded, the inverting input terminal of the first operational amplifier OP1 is respectively connected to the emitter of the first transistor P1 and the drain of the second PMOS transistor Q2, the non-inverting input terminal of the first operational amplifier OP1 is respectively connected to the drain of the first PMOS transistor Q1 and the first end of the first resistor R1, and the output terminal of the first operational amplifier OP1 is respectively connected to the gate of the first PMOS transistor Q1 and the gate of the third PMOS transistor Q3;

[0065] The source of the first PMOS transistor Q1, the source of the second PMOS transistor Q2 and the source of the third PMOS transistor Q3 are all connected to the positive electrode of the first power supply, and the drain of the third PMOS transistor Q3 serves as the output end of the current generating circuit 10 to output a current with a negative temperature coefficient that changes with temperature.

[0066] See also Figure 2 , is a structural schematic diagram of a current generating circuit 10 for outputting a negative temperature coefficient current in a specific implementation manner. The first transistor P1 is a PNP transistor. It can be seen from the circuit structure that the first operational amplifier OP1, the first PMOS transistor Q1 and the second PMOS transistor Q2 can play a clamping function, that is, through feedback, the terminal voltage of the first resistor R1 is kept consistent with Vbe, where Vbe refers to the voltage between the base and the emitter of the first transistor P1.

[0067] Vbe is a negative temperature coefficient. Through the clamping of the first operational amplifier OP1, the voltage of the first resistor R1 is also equal to Vbe. Vbe is divided by the resistance value R1 of the first resistor R1, and the current of the branch where the first PMOS tube Q1 is located can be obtained as Vbe / R1.

[0068] The source electrodes of the first PMOS tube Q1 and the third PMOS tube Q3 are both connected to the positive electrode of the first power supply. Figure 2 In the figure, the positive electrode of the first power supply is marked as V1, and the bases of the first PMOS tube Q1 and the third PMOS tube Q3 are connected to the output terminal of the first operational amplifier OP1, so that the first PMOS tube Q1 and the third PMOS tube Q3 form a current mirror structure, that is, the current output by the drain of the third PMOS tube Q3 is equal to Vbe / R1, that is, the current generated by the current generating circuit 10 in this embodiment. When designing, the temperature coefficient of R1 is set to 0 as much as possible. It can be seen that the current generating circuit 10 generates a current with a negative temperature coefficient. Figure 2 Marked as I CTAT , which indicates a negative temperature coefficient, that is, I CTAT Decreases as temperature increases.

[0069] It can be seen that in this embodiment, the current I generated by the current generating circuit 10 CTAT It is linearly related to Vbe, that is, when the detected temperature changes, it will affect the Vbe of the first transistor P1, which will be reflected in the current output by the current generating circuit 10. The Vbe of the first transistor P1 is related to the temperature and is almost not affected by the corner (process angle) of the device. The stability is very high, which is conducive to ensuring the accuracy of the temperature detected by the present application.

[0070] In this embodiment, the current generating circuit 10 is composed of a first transistor P1, a first resistor R1, a first operational amplifier OP1, a first PMOS transistor Q1, a second PMOS transistor Q2, and a third PMOS transistor Q3, and has a very simple structure, which is conducive to miniaturization of the temperature sensor.

[0071] In addition, it should be noted that in order to reduce the impact of the temperature coefficient of R1, a first resistor R1 with a very low temperature coefficient can be selected. For example, a suitable resistor R01 with a positive temperature coefficient and a suitable resistor R02 with a negative temperature coefficient can be selected. The first resistor R1 of the present application can be realized by connecting the two in series to achieve a temperature coefficient of 0.

[0072] The positive temperature coefficient resistor R01 can be specifically expressed as R01 = R 01base×(1+K1×T), where T represents temperature, K1 is greater than 0, which is a positive temperature coefficient. The resistor R02 with a negative temperature coefficient can be specifically expressed as R02=R 02base ×(1+K2×T), K2 is less than 0, which is a negative temperature coefficient. After connecting in series, we can get: R1=R 01base ×(1+K1×T)+R 02base ×(1+K2×T). After transforming this formula, we can get: R1=R 01base +R 02base +T×(R 01base ×K1+R 02base × K2). It can be seen that to achieve a zero temperature coefficient of R1, R 01base ×K1+R 02base ×K2 is equal to 0, that is, when selecting the above positive temperature coefficient resistor R01 and negative temperature coefficient resistor R02, it is required that R 01base / R 02base =K2 / K1.

[0073] In one embodiment of the present invention, if the current is a current with a positive temperature coefficient, the current generating circuit 10 may include: a first branch Z1 with a second end grounded, a second branch Z2 with a second end grounded, a fourth NMOS tube Q4, a fifth NMOS tube Q5, a sixth PMOS tube Q6, a seventh PMOS tube Q7 and an eighth PMOS tube Q8.

[0074] See also Figure 3 , is a schematic diagram of the structure of a current generating circuit 10 for outputting a positive temperature coefficient current in a specific implementation. The first branch Z1 includes a second resistor R2 and N PNP transistors connected in parallel, the first end of the second resistor R2 serves as the first end of the first branch Z1, the bases and collectors of the N PNP transistors in the first branch Z1 are both grounded, and the emitters of the N transistors are all connected to the second end of the second resistor R2. Figure 3 For ease of viewing, only a single PNP transistor is shown in the first branch Z1.

[0075] The second branch Z2 includes M PNP transistors in parallel, the bases and collectors of the M PNP transistors in the second branch Z2 are grounded, the emitters of the M PNP transistors in the second branch Z2 are interconnected and serve as the first end of the second branch Z2; M and N are both positive integers and M<N. Figure 3 For ease of viewing, only a single PNP transistor is shown in the second branch Z2, and the ratio of the number of PNP transistors in the first branch Z1 to the number of PNP transistors in the second branch Z2 is marked as M:N.

[0076] The source of the fourth NMOS transistor Q4 is connected to the first end of the first branch Z1, the source of the fifth NMOS transistor Q5 is connected to the first end of the second branch Z2, and the gate of the fourth NMOS transistor Q4 is connected to the gate of the fifth NMOS transistor Q5 and the drain of the fifth NMOS transistor Q5 respectively;

[0077] The drain of the fourth NMOS tube Q4 is respectively connected to the drain of the sixth PMOS tube Q6, the gate of the sixth PMOS tube Q6, the gate of the seventh PMOS tube Q7, and the gate of the eighth PMOS tube Q8;

[0078] The source of the sixth PMOS tube Q6 , the source of the seventh PMOS tube Q7 , and the source of the eighth PMOS tube Q8 are all connected to the second positive power supply, and the drain of the seventh PMOS tube Q7 is connected to the drain of the fifth NMOS tube Q5 . Figure 3 The positive pole of the second power supply is marked as V2. In addition, in practical applications, the second power supply and the first power supply in the above implementation manner can usually be implemented by the system power supply VDD.

[0079] The drain of the eighth PMOS transistor Q8 serves as the output terminal of the current generating circuit 10 to output a current with a positive temperature coefficient that varies with temperature. Figure 3 Marked as I PTAT , which indicates a positive temperature coefficient, that is, I PTAT The sizes of the fourth NMOS transistor, the fifth NMOS transistor, the sixth PMOS transistor, the seventh PMOS transistor and the eighth PMOS transistor are adjusted to make the voltage of the first end of the first branch equal to the voltage of the first end of the second branch.

[0080] In this implementation, it can be seen from the circuit structure that the fourth NMOS transistor Q4 and the fifth NMOS transistor Q5 form a common gate amplifier circuit, and the voltage of the source of the fourth NMOS transistor Q4 and the source of the fifth NMOS transistor Q5 are approximately equal. VR2 represents the voltage drop of the second resistor R2, then VR2 = Vbe0-Vbe1 = VT × ln (M / N). Here, Vbe0 is the voltage to ground of the first end of the second branch Z2, that is, the voltage drop of the second branch Z2, and Vbe1 is the voltage to ground at the second end of the second resistor R2, which is easy to understand. Figure 3 The positions of Vbe0 and Vbe1 are shown in FIG. M / N is the ratio of the number of PNP transistors in the first branch Z1 to the number of PNP transistors in the second branch Z2. VT is the thermal voltage, that is, the value of VT is proportional to the temperature. The current flowing through the second resistor R2 is equal to VR2 / R2. If the temperature coefficient of R2 is made to be 0 as much as possible, the current is a current with a positive temperature coefficient of 1.

[0081] And from the circuit structure, it can be known that the sixth PMOS tube Q6, the seventh PMOS tube Q7 and the eighth PMOS tube Q8 form a current mirror structure, and the current VR2 / R2 flowing through the sixth PMOS tube Q6 is mirrored to the eighth PMOS tube Q8 through the current mirror, so that the drain of the eighth PMOS tube Q8 outputs a current I PTAT Equal to VR2 / R2.

[0082] In this embodiment, the current I generated by the current generating circuit 10 is PTAT It is linearly related to VR2, that is, linearly related to VT. When the temperature of the position to be measured changes, it will affect VT and then be reflected in the current output by the current generating circuit 10. And VT is almost not affected by the corner (process angle) of the device, and has high stability, which is conducive to ensuring the accuracy of the temperature detected by the present application solution.

[0083] In addition, similarly to the above, in order to reduce the impact of the temperature coefficient of R2, a second resistor R2 with a very low temperature coefficient can be selected. Alternatively, as in the above principle, a suitable positive temperature coefficient resistor and a suitable negative temperature coefficient resistor can be selected in series to realize a second resistor R2 with a zero temperature coefficient.

[0084] according to Figure 1 As shown, the oscillator 20 is connected to the current generating circuit 10, and can generate a first clock based on the current generated by the current generating circuit 10. It can be understood that when the current generated by the current generating circuit 10 is different, the frequency of the first clock generated by the oscillator 20 is different, that is, the frequency of the first clock changes with the temperature, and subsequently the counting circuit 30 can extract the temperature information carried therein based on the first clock. The specific structure of the oscillator 20 can be set according to actual needs, as long as the functional requirements of the present application can be achieved.

[0085] In a specific embodiment of the present invention, please refer to Figure 4 The oscillator 20 may include a first comparator CMP1, a second comparator CMP2, an RS trigger 40, a first capacitor C1, a second capacitor C2, a ninth PMOS transistor Q9, a tenth NMOS transistor Q10, an eleventh PMOS transistor Q11, a twelfth NMOS transistor Q12, a third resistor R3 and a fourth resistor R4.

[0086] The first input terminal of the first comparator CMP1 is respectively connected to the first input terminal of the second comparator CMP2, the second terminal of the third resistor R3 and the first terminal of the fourth resistor R4, the first terminal of the third resistor R3 is connected to the positive electrode of the third power supply, and the second terminal of the fourth resistor R4 is grounded; Figure 4 In the example, the positive terminal of the third power supply is denoted as VDD.

[0087] The output terminal of the first comparator CMP1 is connected to the R terminal of the RS trigger 40, and the output terminal of the second comparator CMP2 is connected to the S terminal of the RS trigger 40. Figure 4 In the example, the first input terminal of the first comparator CMP1 is its positive input terminal, and the second input terminal of the first comparator CMP1 is its negative input terminal. The first input terminal of the second comparator CMP2 is its positive input terminal, and the second input terminal of the second comparator CMP2 is its negative input terminal.

[0088] The second input end of the first comparator CMP1 is respectively connected to the first end of the first capacitor C1, the drain of the ninth PMOS transistor Q9 and the drain of the tenth NMOS transistor Q10; the second input end of the second comparator CMP2 is respectively connected to the first end of the second capacitor C2, the drain of the eleventh PMOS transistor Q11 and the drain of the twelfth NMOS transistor Q12;

[0089] The output end of the current generating circuit 10 is connected to the source of the ninth PMOS transistor Q9 and the source of the eleventh PMOS transistor Q11, the gate of the ninth PMOS transistor Q9 and the gate of the tenth NMOS transistor Q10 are connected to the Q end of the RS trigger 40, the gate of the eleventh PMOS transistor Q11 and the gate of the twelfth NMOS transistor Q12 are connected to the QN end of the RS trigger 40; the second end of the first capacitor C1, the second end of the second capacitor C2, the source of the tenth NMOS transistor Q10 and the source of the twelfth NMOS transistor Q12 are all grounded;

[0090] In this implementation, the Q terminal or QN terminal of the RS trigger 40 serves as the output terminal of the oscillator 20 to output the first clock.

[0091] In this embodiment, in the initial state, there is no voltage in the first capacitor C1 and the second capacitor C2. The third resistor R3 and the fourth resistor R4 can usually adopt the same model so that the resistance values ​​of the two are the same, that is, the voltage at the connection end of the two is equal to 1 / 2VDD. For example, in the initial state, the Q end of the RS trigger 40 is 0, and the QN end is 1. At this time, the tenth NMOS tube Q10 and the eleventh PMOS tube Q11 are disconnected, and the twelfth NMOS tube Q12 and the ninth PMOS tube Q9 are closed, so that the current generated by the current generating circuit 10 can charge the first capacitor C1. As the first capacitor C1 is continuously charged, the voltage at the second input terminal of the first comparator CMP1 will be higher than the voltage at its first input terminal, which will cause the output of the first comparator CMP1 to flip, and then cause the Q terminal of the RS trigger 40 to be 1, and the QN terminal to be 0. At this time, the tenth NMOS tube Q10 and the eleventh PMOS tube Q11 are closed, and the twelfth NMOS tube Q12 and the ninth PMOS tube Q9 are disconnected, so that the current generated by the current generating circuit 10 can charge the second capacitor C2. As the second capacitor C2 is continuously charged, the voltage at the second input terminal of the second comparator CMP2 will be higher than the voltage at its first input terminal, which will cause the output of the second comparator CMP2 to flip.

[0092] It can be seen that in this implementation, the Q end or the QN end of the RS trigger 40 can be used as the output end of the oscillator 20, thereby outputting the first clock. The larger the current generated by the current generating circuit 10, the more frequent the oscillation, that is, the larger the frequency of the first clock and the shorter the period.

[0093] It should also be emphasized that the circuit of the conventional oscillator 20 is usually based on MOS tubes for comparison to achieve oscillation, so that the oscillator 20 will be affected by factors such as the temperature coefficient VTH of the MOS tube and the process angle of the MOS tube, thereby affecting the relationship between the count and the temperature of the oscillator 20. In this embodiment of the present application, two comparators are used, and the comparison reference is always 1 / 2VDD, which is a value independent of temperature, which is conducive to ensuring the counting accuracy of the oscillator 20, and is also conducive to ensuring the accuracy of the temperature sensor.

[0094] according to Figure 1 As shown, the first counter 31 in the counting circuit 30 is connected to the oscillator 20, and can count the number of the first clock to obtain a first count value. The second counter 32 is used to count the number of the second clock to obtain a second count value, and the second clock needs not to change with temperature, so that in the present application, the second clock is used as a reference standard.

[0095] The first counter 31 and the second counter 32 start counting at the same time, and when the first count value reaches the predetermined value, the second count value at the current temperature can be obtained as the output of the counting circuit 30. It can be understood that, since the frequency of the first clock reflects the magnitude of the current generated by the current generating circuit 10, the time taken for the first count value to reach the predetermined value is different at different temperatures, which means that when the first count value reaches the predetermined value, the value of the second count value is different. Therefore, after the relevant corresponding relationship is predetermined, the electronic device receiving the second count value can obtain the currently detected temperature value based on the second count value.

[0096] The specific structures of the first counter 31 and the second counter 32 in the counting circuit 30 can be set and adjusted according to actual needs. For example, they can usually be implemented based on a number of D flip-flops.

[0097] It should also be noted that after the first counter 31 and the second counter 32 start counting at the same time, if the second count value reaches a predetermined value, the first count value at the current temperature is obtained as the output of the counting circuit 30, and the electronic device receiving the first count value can also obtain the current temperature value based on the first count value, that is, such a scheme can also be implemented in theory, but if such a scheme is adopted, since the second clock is the system standard clock and the first clock is not the system standard clock, when the first count value is output, the processing process will be more complicated, and the first count value needs to be converted into the corresponding value under the system clock for further processing. Therefore, in the scheme of the present application, the counting circuit 30 outputs the second count value for subsequent processing.

[0098] In a specific implementation of the present invention, the output of the first counter 31 is represented by n1 binary numbers; the output of the second counter 32 is represented by n2 binary numbers, where n2>n1.

[0099] This implementation is based on the consideration that, since the counting circuit 30 of the present application needs to obtain the second counting value at the current temperature as the output of the counting circuit 30 when the first counting value reaches a predetermined value, at different temperatures, the second counting value will have different values, which may be higher than or lower than the predetermined value. Therefore, the range of the output data of the second counter 32 should be larger, that is, n2 needs to be greater than n1.

[0100] For example, in a specific embodiment of the present invention, the first counter 31 includes from the A_1th D flip-flop to the A_n1th D flip-flop, a total of n1 D flip-flops; the second counter 32 includes from the B_1th D flip-flop to the B_n2th D flip-flop, a total of n2 D flip-flops;

[0101] See also Figure 5 , Figure 5The upper half is a schematic diagram of the structure of the first counter 31 in this implementation mode. The D terminal of each D flip-flop in the first counter 31 is connected to its own QN terminal, and the clock terminal of the A_1th D flip-flop is connected to the first clock. Figure 5 The first clock is recorded as CTAT_CLK. The clock terminal of the A_2th D flip-flop is connected to the QN terminal of the A_1th D flip-flop, and so on. The clock terminal of the A_n1th D flip-flop is connected to the QN terminal of the A_(n1-1)th D flip-flop, and the Q terminal of the A_1th D flip-flop to the Q terminal of the A_n1th D flip-flop are sequentially used as the low to high bits of the output of the first counter 31.

[0102] Figure 5 In the example, the Q-end output of the A_1th D flip-flop is denoted as QC1, the Q-end output of the A_2th D flip-flop is denoted as QC2, and so on. The Q-end output of the A_n1th D flip-flop is QCn1, that is, the output of the first counter 31 in this example can be represented by n1 binary numbers, the Q-end of the A_n1th D flip-flop is the highest bit, and the Q-end of the A_1th D flip-flop is the lowest bit.

[0103] In addition, in practical applications, the specific value of the predetermined value can be set and selected according to actual needs. Figure 5 For example, when n1 binary numbers of the first counter 31 are all 1, it is usually considered that the predetermined value has been reached, and then it can be cleared to perform the next detection.

[0104] Figure 5 The lower half is a schematic diagram of the structure of the second counter 32 in this embodiment. The D terminal of each D flip-flop in the second counter 32 is connected to its own QN terminal, and the clock terminal of the B_1th D flip-flop is connected to the second clock. Figure 5 The second clock is recorded as RAF_CLK. The clock terminal of the B_2th D flip-flop is connected to the QN terminal of the B_1th D flip-flop, and so on. The clock terminal of the B_n2th D flip-flop is connected to the QN terminal of the B_(n2-1)th D flip-flop, and the Q terminal of the B_1th D flip-flop to the Q terminal of the B_n2th D flip-flop are sequentially used as the low to high bits of the output of the second counter 32.

[0105] Figure 5 In the example, the Q-end output of the B_1th D flip-flop is denoted as QR1, the Q-end output of the B_2th D flip-flop is denoted as QR2, and so on. The Q-end output of the B_n2th D flip-flop is QRn2, that is, the output of the second counter 32 in this example can be represented by n2 binary numbers, the Q-end of the B_n2th D flip-flop is the highest bit, and the Q-end of the B_1th D flip-flop is the lowest bit.

[0106] In a specific implementation of the present invention, the counting circuit 30 may also include a sample-and-hold device, as shown in FIG. Figure 6 , the sample-and-hold device includes from the C_1th D flip-flop to the C_n2th D flip-flop, a total of n2 D flip-flops, and also includes from the 1st selector to the n2th selector;

[0107] The D terminal of each D flip-flop is connected to the output terminal of the corresponding selector, the selection control terminal of each selector is connected to the FLAG signal, the first input terminal A0 of each selector is connected to the Q terminal of the corresponding D flip-flop, and the second input terminal A1 of each selector is respectively connected to the low bit to the high bit output by the second counter 32; the clock terminal of each D flip-flop is connected to the second clock;

[0108] When the first count value reaches a predetermined value, such as 11111111111, the FLAG signal is at a high level "1", indicating that the second count value needs to be stored at this time.

[0109] Accordingly, when the first count value does not reach the predetermined value, the FLAG signal is at a low level "0";

[0110] When the FLAG signal is at a high level, each selector selects the output value of the second counter 32 sampled at this time and outputs it to its corresponding D flip-flop, and the Q-end outputs of all D flip-flops serve as the output of the counting circuit 30;

[0111] When the FLAG signal is at a low level, each selector selects the output value of the second counter 32 sampled last time and outputs it to its corresponding D flip-flop. The Q-end outputs of all D flip-flops serve as the output of the counting circuit 30, maintaining the last output result.

[0112] In this implementation, it is set that storage is triggered once when the FLAG signal is at a high level. Specifically, when the first count value reaches a predetermined value, the FLAG signal connected to the selection control end of each selector will generate a high-level pulse. At this time, each of the n2 selectors will store the level state of its second input end A1 to the D end of the D flip-flop to which it is connected, and at the falling edge of REF_CLK, the data can be stored in the Q end of the D flip-flop, that is, stored in DATA 1 to DATAn2.

[0113] It can be understood that when the first count value does not reach the predetermined value, the FLAG signal is always at a low level, and the level states of DATA 1 to DATAn2 will not be changed.

[0114] By applying the technical solution provided in the embodiment of the present invention, the current generating circuit 10 can generate a current that varies with temperature, and the oscillator 20 is connected to the current generating circuit 10, and can generate a first clock based on the current output by the current generating circuit 10, and the frequency of the first clock varies with temperature, which means that the frequency of the first clock reflects the current temperature. In addition, since the present application adopts the design of the oscillator 20, it is conducive to ensuring the miniaturization of the temperature sensor. The counting circuit 30 is provided with a first counter 31 and a second counter 32, and the second counter 32 is used to count the number of the second clock to obtain a second count value, and the second clock does not vary with temperature, that is, the second clock can be used as a reference clock. The first counter 31 needs to be connected to the oscillator 20, and the first counter 31 is used to count the number of the first clock to obtain a first count value. Since the first counter 31 and the second counter 32 start counting at the same time, when the first count value reaches the predetermined value, the second count value at the current temperature can be obtained as the output of the counting circuit 30. It can be understood that when the temperature is different, the time taken for the first count value to reach the predetermined value is different, which also makes the second count value different. Therefore, the second count value output by the counting circuit 30 can reflect the current temperature. In addition, it can be seen that in the solution of the present application, the second count value output by the counting circuit 30 is used to reflect the current temperature. The whole process does not need to calculate any frequency value, so that the counting circuit 30 of the present application has a simple structure and high reliability, which is also conducive to the miniaturization of the temperature sensor of the present application.

[0115] In summary, the solution of the present application can effectively realize temperature detection and ensure the miniaturization of the temperature sensor.

[0116] Corresponding to the above embodiments of the temperature sensor, an embodiment of the present invention further provides a dtof sensor, which may include the temperature sensor in any of the above embodiments.

[0117] Corresponding to the above embodiment of the temperature sensor, an embodiment of the present invention further provides an electronic device, which may include the temperature sensor in any of the above embodiments, and the electronic device may further include: a controller and a memory;

[0118] A memory, used for storing a corresponding relationship between the second count value and the temperature;

[0119] The controller is used to find the corresponding relationship according to the second count value at the current temperature, so as to obtain the current temperature value.

[0120] In the solution of the present application, it can be seen from the above description that the temperature sensor can realize accurate temperature detection, and the detected temperature information is reflected in the numerical value of the second count value. In this regard, the electronic device can parse the current temperature based on the numerical value of the second count value.

[0121] In this embodiment, the controller in the electronic device specifically searches for the pre-stored corresponding relationship according to the second count value at the current temperature, thereby obtaining the current temperature value. This table lookup implementation enables the controller to determine the current temperature value very conveniently and quickly.

[0122] Specifically, in a specific implementation of the present invention, the process of determining the stored corresponding relationship includes:

[0123] Divide K temperature values ​​within the temperature variation range from T1 to T2;

[0124] For each divided temperature value, when the temperature sensor is in an environment of the temperature value, when the first count value reaches a predetermined value, a second count value at the current temperature is recorded, and it is determined that the current temperature value corresponds to the second count value;

[0125] After testing is performed in turn at each divided temperature value, the established corresponding relationship is obtained.

[0126] T1 and T2 are both preset values. For example, the lower limit of the temperature detection of the temperature sensor can be selected as T1, and the upper limit of the temperature detection of the temperature sensor can be selected as T2. K temperature values ​​need to be divided within the temperature variation range from T1 to T2, where K is a positive integer. It can be understood that the larger the number of K is set, the more accurate the corresponding relationship is. Of course, as the preliminary preparation work, the workload is also greater.

[0127] For each divided temperature value, it is necessary to perform a test under the temperature value, that is, when the temperature sensor is in an environment of the temperature value, let the temperature sensor perform temperature detection. It can be understood that according to the above principle, when the first count value reaches a predetermined value, the temperature sensor will output a second count value. At this time, it is necessary to record the second count value in this case and determine whether the current temperature value corresponds to the second count value.

[0128] For each divided temperature value, after testing according to the above process, the correspondence between K temperature values ​​and the corresponding second count values ​​can be obtained, and then a curve can be obtained by fitting, that is, the established correspondence is obtained. In addition, when the number of K is set to be large, the two adjacent points on the curve can be regarded as a straight line, and the error is very small.

[0129] See also Figure 7 , is a schematic diagram of a corresponding relationship established in a specific implementation, wherein the horizontal axis is temperature and the vertical axis is the second count value. Figure 7In the example, for each divided temperature value, after determining the second count value corresponding to the temperature value, a curve can be obtained by fitting as the established corresponding relationship.

[0130] In a specific implementation of the present invention, if the current generated by the current generating circuit is a current with a negative temperature coefficient, the corresponding relationship is: the higher the temperature, the larger the second count value;

[0131] If the current generated by the current generating circuit is a current with a positive temperature coefficient, the corresponding relationship is: the higher the temperature, the smaller the second count value.

[0132] This implementation takes into account that the solution of the present application needs to determine the detected temperature based on the second count value. From the above principle, it can be seen that when the current generated by the current generating circuit is a current with a negative temperature coefficient, the higher the temperature, the lower the frequency of the first clock, which means that the first count value takes longer to reach the predetermined value. Therefore, when the first count value reaches the predetermined value, the value of the second count value is larger.

[0133] Correspondingly, if the current generated by the current generating circuit is a current with a positive temperature coefficient, the higher the temperature, the greater the frequency of the first count, which means that the first count value takes a shorter time to reach the predetermined value, and thus the second count value is smaller.

[0134] For example, Figure 7 In the example, the sensor has a negative temperature coefficient, and the corresponding relationship is an upward arc, indicating that the temperature is positively correlated with the second count value. If the sensor has a positive temperature coefficient, the corresponding relationship is a downward arc, that is, as the temperature increases, the second count value decreases, indicating that the temperature is negatively correlated with the second count value. Figure 7 It can be seen that when the first counter is 10 bits, the maximum count value is 1024, and when the second counter is 11 bits, the maximum count value is 2048. When the temperature is 40 degrees, the second count value is 1127, when the temperature is 125 degrees, the second count value is 1457, and when the temperature is -40 degrees, the second count value is 965.

[0135] It should also be noted that, in this application, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0136] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this application can be implemented with electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0137] The present application uses specific examples to illustrate the principles and implementation methods of the present invention, and the description of the above embodiments is only used to help understand the technical solution and core ideas of the present invention. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, the present invention can also be improved and modified, and these improvements and modifications also fall within the scope of protection of the present invention.

Claims

1. A temperature sensor, characterized in that: include: A current generating circuit for generating a current that varies with temperature; an oscillator, connected to the current generating circuit, and configured to generate a first clock based on the current, wherein the frequency of the first clock varies with temperature; A counting circuit includes a first counter and a second counter, wherein the first counter is connected to the oscillator, the second counter is used to count the number of second clocks to obtain a second count value, and the second clock does not change with temperature; the first counter is used to count the number of the first clocks to obtain a first count value; the first counter and the second counter start counting at the same time, and when the first count value reaches a predetermined value, the second count value at the current temperature is obtained as the output of the counting circuit.

2. The temperature sensor according to claim 1, characterized in that: The output of the first counter is represented by n1 binary numbers; the output of the second counter is represented by n2 binary numbers, where n2>n1.

3. The temperature sensor according to claim 2, characterized in that: The first counter includes n1 D flip-flops from the A_1th D flip-flop to the A_n1th D flip-flop; the second counter includes n2 D flip-flops from the B_1th D flip-flop to the B_n2th D flip-flop; The D end of each D flip-flop in the first counter is connected to its own QN end, the clock end of the A_1th D flip-flop is connected to the first clock, the clock end of the A_2th D flip-flop is connected to the QN end of the A_1th D flip-flop, and so on, the clock end of the A_n1th D flip-flop is connected to the QN end of the A_(n1-1)th D flip-flop, and the Q end of the A_1th D flip-flop to the Q end of the A_n1th D flip-flop are sequentially used as the low to high bits of the output of the first counter; The D end of each D flip-flop in the second counter is connected to its own QN end, the clock end of the B_1th D flip-flop is connected to the second clock, the clock end of the B_2th D flip-flop is connected to the QN end of the B_1th D flip-flop, and so on. The clock end of the B_n2th D flip-flop is connected to the QN end of the B_(n2-1)th D flip-flop, and the Q end of the B_1th D flip-flop to the Q end of the B_n2th D flip-flop are sequentially used as the low to high bits of the second counter output.

4. The temperature sensor according to claim 1, characterized in that: The counting circuit further includes a sample-and-hold device, wherein the sample-and-hold device includes a C_1th D flip-flop to a C_n2th D flip-flop, a total of n2 D flip-flops, and also includes a 1st selector to an n2th selector; The D end of each D flip-flop is connected to the output end of the corresponding selector, the selection control end of each selector is connected to the FLAG signal, the first input end of each selector is connected to the Q end of the corresponding D flip-flop, and the second input end of each selector is respectively connected to the low bit to the high bit output by the second counter; the clock end of each D flip-flop is connected to the second clock; When the first count value reaches a predetermined value, the FLAG signal is at a high level, and when the first count value does not reach the predetermined value, the FLAG signal is at a low level; When the FLAG signal is at a high level, each selector selects the output value of the second counter sampled at this time and outputs it to its corresponding D flip-flop, and the Q-end outputs of all D flip-flops serve as the output of the counting circuit; When the FLAG signal is at a low level, each selector selects the output value of the second counter sampled last time and outputs it to its corresponding D flip-flop, and the Q-end outputs of all D flip-flops serve as the output of the counting circuit to maintain the last output result.

5. The temperature sensor according to claim 1, characterized in that: If the current is a current with a negative temperature coefficient, the current generating circuit includes: a first triode, a first resistor, a first operational amplifier, a first PMOS transistor, a second PMOS transistor, and a third PMOS transistor; The base and collector of the first transistor are grounded, the inverting input terminal of the first operational amplifier is respectively connected to the emitter of the first transistor and the drain of the second PMOS transistor, the non-inverting input terminal of the first operational amplifier is respectively connected to the drain of the first PMOS transistor and the first end of the first resistor, and the output terminal of the first operational amplifier is respectively connected to the gate of the first PMOS transistor and the gate of the third PMOS transistor; The source of the first PMOS tube, the source of the second PMOS tube and the source of the third PMOS tube are all connected to the positive electrode of the first power supply, and the drain of the third PMOS tube serves as the output end of the current generating circuit to output a current with a negative temperature coefficient that changes with temperature.

6. The temperature sensor according to claim 1, characterized in that: If the current is a current with a positive temperature coefficient, the current generating circuit includes: a first branch with a second end grounded, a second branch with a second end grounded, a fourth NMOS transistor, a fifth NMOS transistor, a sixth PMOS transistor, a seventh PMOS transistor and an eighth PMOS transistor; The first branch includes a second resistor and N PNP transistors connected in parallel, the first end of the second resistor serves as the first end of the first branch, the bases and collectors of the N PNP transistors in the first branch are grounded, and the emitters of the N transistors are connected to the second end of the second resistor; The second branch includes M PNP transistors connected in parallel, bases and collectors of the M PNP transistors in the second branch are grounded, emitters of the M PNP transistors in the second branch are connected to each other and serve as the first end of the second branch; M and N are both positive integers and M<N; The source of the fourth NMOS tube is connected to the first end of the first branch, the source of the fifth NMOS tube is connected to the first end of the second branch, and the gate of the fourth NMOS tube is connected to the gate of the fifth NMOS tube and the drain of the fifth NMOS tube respectively; The drain of the fourth NMOS tube is respectively connected to the drain of the sixth PMOS tube, the gate of the sixth PMOS tube, the gate of the seventh PMOS tube, and the gate of the eighth PMOS tube; The source of the sixth PMOS tube, the source of the seventh PMOS tube, and the source of the eighth PMOS tube are all connected to the positive electrode of the second power supply, and the drain of the seventh PMOS tube is connected to the drain of the fifth NMOS tube; The drain of the eighth PMOS tube serves as the output end of the current generating circuit to output a current with a positive temperature coefficient that changes with temperature; the sizes of the fourth NMOS tube, the fifth NMOS tube, the sixth PMOS tube, the seventh PMOS tube and the eighth PMOS tube are adjusted so that the voltage of the first end of the first branch is equal to the voltage of the first end of the second branch.

7. The temperature sensor according to claim 1, characterized in that: The oscillator includes a first comparator, a second comparator, an RS trigger, a first capacitor, a second capacitor, a ninth PMOS transistor, a tenth NMOS transistor, an eleventh PMOS transistor, a twelfth NMOS transistor, a third resistor and a fourth resistor; The first input end of the first comparator is respectively connected to the first input end of the second comparator, the second end of the third resistor and the first end of the fourth resistor, the first end of the third resistor is connected to the positive electrode of the third power supply, and the second end of the fourth resistor is grounded; The output end of the first comparator is connected to the R end of the RS trigger, and the output end of the second comparator is connected to the S end of the RS trigger; The second input end of the first comparator is respectively connected to the first end of the first capacitor, the drain of the ninth PMOS tube and the drain of the tenth NMOS tube; the second input end of the second comparator is respectively connected to the first end of the second capacitor, the drain of the eleventh PMOS tube and the drain of the twelfth NMOS tube; The output end of the current generating circuit is connected to the source of the ninth PMOS tube and the source of the eleventh PMOS tube, the gate of the ninth PMOS tube and the gate of the tenth NMOS tube are connected to the Q end of the RS trigger, and the gate of the eleventh PMOS tube and the gate of the twelfth NMOS tube are connected to the QN end of the RS trigger; the second end of the first capacitor, the second end of the second capacitor, the source of the tenth NMOS tube and the source of the twelfth NMOS tube are all grounded; The Q terminal or the QN terminal of the RS trigger serves as the output terminal of the oscillator to output the first clock.

8. A dtof sensor, comprising the temperature sensor according to claims 1-7.

9. An electronic device, characterized in that: The electronic device comprises the temperature sensor as claimed in claims 1 to 7, and further comprises: a controller and a memory; The memory is used to store the corresponding relationship between the second count value and the temperature; The controller is used to search for the corresponding relationship according to the second count value at the current temperature, so as to obtain the current temperature value.

10. The electronic device according to claim 9, characterized in that: The process of determining the corresponding relationship includes: Divide K temperature values ​​within the temperature variation range from T1 to T2; For each divided temperature value, when the temperature sensor is in an environment of the temperature value, when the first count value reaches a predetermined value, a second count value at the current temperature is recorded, and it is determined that the current temperature value corresponds to the second count value; After testing is performed in turn at each divided temperature value, the established corresponding relationship is obtained.

11. The electronic device according to claim 9, characterized in that: If the current generated by the current generating circuit is a current with a negative temperature coefficient, the corresponding relationship is: the higher the temperature, the larger the second count value; If the current generated by the current generating circuit is a current with a positive temperature coefficient, the corresponding relationship is: the higher the temperature, the smaller the second count value.