Optical module manchester code processing method, system and single-chip microcomputer
By oversampling and eigenvalue calculation of Manchester code, and utilizing a combination of analog-to-digital converter, memory, and processing unit, the accuracy of the microcontroller in processing Manchester code is improved. Sampling, decoding, and transmission are performed in parallel, thus solving the problem of low processing accuracy of the microcontroller.
Patent Information
- Application Number
- CN202410032960.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-09
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2044-01-09
AI Technical Summary
The accuracy of current microcontrollers in processing Manchester code is relatively low.
By oversampling the received Manchester code and calculating eigenvalues to determine the binarized signal, the decoded information is finally obtained. Parallel processing of the Manchester code is achieved using an analog-to-digital converter, memory, and processing unit.
It improves the accuracy of the microcontroller in processing Manchester code, performs sampling, decoding and transmission in parallel, increases the efficiency of time resource utilization, and avoids software interruption services.
Smart Images

Figure CN117834038B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and particularly relates to a method and system for processing Manchester code of an optical module and a single-chip microcomputer. BACKGROUND
[0002] In order to increase the stability of data transmission, Manchester code format can be used to transmit data at present. Manchester code represents actual data through switching of 0 and 1.
[0003] At present, a single-chip microcomputer can be used to sample, decode and send Manchester code in the prior art.
[0004] However, the inventors have found that the prior art at least has the following technical problem: the accuracy of the processing process of Manchester code by the single-chip microcomputer is low. SUMMARY
[0005] The present application provides a method and system for processing Manchester code of an optical module and a single-chip microcomputer, so as to solve the problem of low accuracy of the processing process of Manchester code by the single-chip microcomputer.
[0006] In a first aspect, the present application provides a method for processing Manchester code of an optical module, applied to a single-chip microcomputer, the single-chip microcomputer comprising an analog-to-digital converter, a memory and a processing unit; the method comprising: receiving, by the analog-to-digital converter, Manchester code to be processed; oversampling, by the analog-to-digital converter, the Manchester code to be processed to obtain processed Manchester code with a preset number of bits; writing, by the analog-to-digital converter, the processed Manchester code into the memory; reading, by the processing unit, N pieces of processed Manchester code in the memory, wherein N is a positive integer; calculating, by the processing unit, characteristic values of the N pieces of processed Manchester code; determining, by the processing unit, binary signals corresponding to the N pieces of processed Manchester code respectively according to the characteristic values; and determining, by the processing unit, decoding information according to the binary signals.
[0007] In a possible implementation, the determining the decoding information according to the N binary signals comprises: determining N continuous binary signals as a group of binary signals to be decoded; determining each two adjacent binary signals in the binary signals to be decoded as a traversal data group; determining an actual value corresponding to a target traversal data group according to two binary signals in the target traversal data group, wherein the target traversal data group is any traversal data group; deleting the target traversal data group and a traversal data group before the target traversal data group if the two binary signals in the target traversal data group are the same; adding a new binary signal to the binary signals to be decoded to obtain new binary signals to be decoded; re-executing the step of determining the actual value by using the new binary signals to be decoded until actual values corresponding to all the traversal data groups are obtained; determining the actual values corresponding to the traversal data groups as partial decoding information corresponding to the binary signals to be decoded; and splicing the partial decoding information corresponding to the binary signals to be decoded to obtain the decoding information.
[0008] In a possible implementation, the determining the actual value corresponding to the target traversal data group according to the two binary signals in the target traversal data group comprises: determining 1 as the actual value corresponding to the target traversal data group if the first binary signal in the target traversal data group is 0 and the second binary signal is 1; and determining 0 as the actual value corresponding to the target traversal data group if the first binary signal in the target traversal data group is 1 and the second binary signal is 2.
[0009] In a possible implementation, the calculating the characteristic value of the N processed Manchester codes comprises: calculating a sum of the N processed Manchester codes to obtain a binary sum; right-shifting the binary sum by N 2th root bits to obtain an average value; and rounding the average value to obtain the characteristic value of the N processed Manchester codes.
[0010] In a possible implementation, the single-chip microcomputer further comprises a timer; the memory comprises at least one first memory and a second memory; and the method, after receiving the Manchester code to be processed, further comprises: the timer receiving a clock signal and counting according to the clock signal to obtain a target value; if the target value is greater than a preset value, sending a data sending instruction to the analog-to-digital converter; the analog-to-digital converter sampling the Manchester code to be processed according to the data sending instruction to obtain a processed Manchester code with a preset bit number; the analog-to-digital converter writing the processed Manchester code into the first memory; and the first memory writing the processed Manchester code into the second memory.
[0011] In a possible implementation, the single-chip microcomputer further includes a timer and a digital-to-analog converter; and the method further includes, after receiving the Manchester code to be processed, the processing unit acquiring the global time corresponding to each memory and the current time; if the global time corresponding to a target memory is greater than the current time, reading the data to be sent in the target memory, where the target memory is any memory; the processing unit sending the data to be sent to the digital-to-analog converter; and the digital-to-analog converter converting the data to be sent into a Manchester code format to obtain target data to be sent in response to receiving a data sending instruction sent by the timer; and the digital-to-analog converter outputting the target data to be sent.
[0012] In a possible implementation, after the processing unit acquires the global time corresponding to each memory and the current time, the method further includes, if there is data being sent currently and the global time corresponding to a target memory is greater than the current time, the digital-to-analog converter waiting for the data being sent to be completed, and then reading the data to be sent in the target memory.
[0013] In a second aspect, the application provides a Manchester code processing system of an optical module, including: an analog-to-digital converter, a memory, and a processing unit; the analog-to-digital converter is configured to receive a Manchester code to be processed; the analog-to-digital converter is configured to oversample the Manchester code to be processed to obtain a processed Manchester code with a preset bit number; the analog-to-digital converter is configured to write the processed Manchester code into the memory; the processing unit is configured to read N processed Manchester codes in the memory, where N is a positive integer; the processing unit is configured to calculate characteristic values of the N processed Manchester codes; the processing unit is configured to determine binary signals corresponding to the N processed Manchester codes respectively according to the characteristic values; and the processing unit is configured to determine decoding information according to the binary signals.
[0014] In a possible implementation, the processing unit is configured to determine N continuous binary signals as a group of binary signals to be decoded; starting from a first binary signal in the binary signals to be decoded, each two adjacent binary signals are determined as a traversal data group; an actual value corresponding to a target traversal data group is determined according to two binary signals in the target traversal data group, where the target traversal data group is any traversal data group; if the two binary signals in the target traversal data group are the same, the target traversal data group and a traversal data group preceding the target traversal data group are deleted; a new binary signal is added to the binary signals to be decoded to obtain new binary signals to be decoded; the step of determining the actual value is re-executed using the new binary signals to be decoded until actual values corresponding to all traversal data groups are obtained; the actual values corresponding to the traversal data groups are determined as decoding information corresponding to the binary signals to be decoded; and the decoding information corresponding to the binary signals to be decoded is spliced to obtain the decoding information.
[0015] In a third aspect, the present application provides a single-chip microcomputer, comprising: an analog-to-digital converter, a memory and a processing unit; an output end of the analog-to-digital converter is connected to an input end of the memory, and an output end of the memory is connected to an input end of the processing unit; the analog-to-digital converter, the memory and the processing unit are used to execute the optical module Manchester code processing method as described in the first aspect.
[0016] The optical module Manchester code processing method, system and single-chip microcomputer provided by the present application can increase the accuracy of the Manchester code processing of the single-chip microcomputer and the optical module, and the hardware does not generate a software interrupt service in the process of starting the sampling of the analog-to-digital converter, so as not to interrupt the running of the firmware. In addition, the sampling, decoding and sending of the Manchester code can be executed in parallel by using the analog-to-digital converter, the memory and the processing unit, so as to increase the utilization efficiency of the time resources. BRIEF DESCRIPTION OF DRAWINGS
[0017] The accompanying drawings, which are incorporated herein and constitute part of the specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0018] Figure 1 An application scenario diagram of the optical module Manchester code processing method provided by the embodiment of the present application is shown in the following figure.
[0019] Figure 2 A flowchart of the optical module Manchester code processing method provided by the embodiment of the present application is shown in the following figure.
[0020] Figure 3 A correspondence relationship diagram between the to-be-decoded binary signal and the traversal data group provided by the embodiment of the present application is shown in the following figure.
[0021] Figure 4 A process diagram for determining a new to-be-decoded binary signal provided by the embodiment of the present application is shown in the following figure.
[0022] Figure 5 A structure diagram of the optical module Manchester code processing system provided by the embodiment of the present application is shown in the following figure.
[0023] The above-described figures have shown the specific embodiments of the present application, and the following will have a more detailed description. These figures and the written description are not intended to limit the scope of the concept of the present application by any means, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0024] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0025] To improve the stability of data transmission, Manchester code uses 0 and 1 transformations to transmit data. Currently, a microcontroller can be used to sample, decode, and transmit Manchester code.
[0026] However, the accuracy of current microcontrollers in processing Manchester code is relatively low.
[0027] To address the aforementioned technical problems, the inventors propose the following technical concept: oversample and store the received Manchester code, determine the eigenvalues of the stored Manchester code, use the eigenvalues to determine the binarized signal of the stored Manchester code, and obtain the decoding information from the binarized signal.
[0028] Figure 1 This is a schematic diagram illustrating an application scenario of the Manchester code processing method for optical modules provided in this application embodiment. For example... Figure 1 The scenario includes: a microcontroller 100, which includes a direct access memory 101, a timer 102, an analog-to-digital converter 103, a processing unit 104, and a digital-to-analog converter 105.
[0029] In the specific implementation process, the analog-to-digital converter 103 in the microcontroller 100 receives Manchester code sent from the outside, and the timer 102 receives a clock signal. When the clock signal received by the timer 102 reaches a preset encoding period, the timer 102 sends a data transmission command to the analog-to-digital converter 103. After receiving the data transmission command, the analog-to-digital converter 103 oversamples the received Manchester code to obtain processed Manchester code, and sends the processed Manchester code to the direct access memory 101 through the storage channel. The direct access memory 101 may include at least one first memory 1011 and at least one second memory 1012. The first memory 1011 receives the data first, and then sends the received data to the second memory 1012 for storage. During decoding, the processing unit 104 reads the data stored in the second memory 1012 and performs decoding. The decoding process may include calculating the feature value of the cached data in the second memory, and determining the decoding information corresponding to the cached data based on the feature value.
[0030] It is understood that the structure illustrated in the embodiments of this application does not constitute a specific limitation on the Manchester code processing of the optical module. In other feasible embodiments of this application, the above architecture may include more or fewer components than illustrated, or combine some components, or split some components, or arrange different components, which can be determined according to the actual application scenario and is not limited here. Figure 1 The components shown can be implemented by hardware, software, or a combination of both.
[0031] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0032] Figure 2 This is a flowchart illustrating the Manchester code processing method for optical modules provided in this application embodiment. The execution entity of this application embodiment can be... Figure 1 The microcontroller 100 in the example. Figure 2 As shown, the method includes:
[0033] S201: The analog-to-digital converter receives the Manchester code to be processed.
[0034] In this step, the Manchester code to be processed can be received by receiving electrical signals or signals with different high and low levels.
[0035] S202: The analog-to-digital converter oversamples the Manchester code to be processed to obtain a processed Manchester code of a preset number of bits.
[0036] In this step, the Manchester code to be processed can be converted into a pre-defined number of processed Manchester codes by oversampling.
[0037] S203: The analog-to-digital converter writes the processed Manchester code into memory.
[0038] This step may include an analog-to-digital converter sending the processed Manchester code to a memory so that the memory automatically stores the received data; it may also include obtaining the memory address and sending the processed Manchester code and a storage instruction together to the memory address so that the memory stores the processed Manchester code according to the storage instruction.
[0039] S204: The processing unit reads N processed Manchester codes from the memory, where N is a positive integer.
[0040] This step may include reading the first N processed Manchester codes from memory, where N can be preset by the operator. Since a 16-bit Manchester code can represent eight 0s or 1s, thus forming a byte, N can also be 16. Other values can be used if more data needs to be stored at once.
[0041] S205: The processing unit calculates the feature values of N processed Manchester codes.
[0042] This step may include calculating the average value of these N processed Manchester codes.
[0043] S206: The processing unit determines the binarized signals corresponding to the N processed Manchester codes based on the feature values.
[0044] This step may include comparing the magnitude of each of the N processed Manchester codes with the eigenvalue. If the magnitude is greater than or equal to the eigenvalue, the corresponding binarized signal is determined to be 1; otherwise, it is 0.
[0045] S207: The processing unit determines the decoding information based on each binarized signal.
[0046] This step may include obtaining decoding information based on changes in the binarized signal.
[0047] As can be seen from the description of the above embodiments, the embodiments of this application oversample the received Manchester code and calculate the feature values of the oversampled processed Manchester code. The binarized signal corresponding to the processed Manchester code is determined by the feature values, and finally the decoding information is obtained. This achieves the effect of increasing the accuracy of the microcontroller and optical module in processing Manchester code. In addition, the hardware does not generate software interrupt services during the sampling process of the analog-to-digital converter, so as not to interrupt the operation of the firmware. Furthermore, due to the use of analog-to-digital converter, memory and processing unit, the sampling, decoding and transmission of Manchester code can be executed in parallel, increasing the efficiency of time resource utilization.
[0048] In one possible implementation, step S207 above, determining the decoding information based on each binarized signal, includes:
[0049] S2071: Determine N consecutive binarized signals as a set of binarized signals to be decoded.
[0050] In this step, N is the same as N in step S206 above. For example, if there are 16 binarized signals "0101101001100110", then these 16 binarized signals are determined as the binarized signals to be decoded. If more data is taken, the binarized signals contained in the binarized signals to be decoded can also be more.
[0051] S2072: Starting from the first binarized signal in the binary signal to be decoded, determine every two adjacent binarized signals as a traversal data group.
[0052] In this step, for example, in the example "0101101001100110" in step S2071 above, the first "01" is the first traversed data group, the second "01" is the second traversed data group, the subsequent "10" is the third traversed data group, and so on.
[0053] Figure 3 This is a schematic diagram illustrating the correspondence between the binarized signal to be decoded and the traversed data groups provided in an embodiment of this application. For example... Figure 3 As shown, the binary signal to be decoded has a total of 16 bits. Two adjacent binary signals are used as a traversal data group, and there are a total of 8 traversal data groups.
[0054] S2073: Determine the actual value corresponding to the target traversal data group based on the two binarized signals in the target traversal data group, where the target traversal data group is any traversal data group.
[0055] This step may include obtaining the actual value corresponding to the target traversed data group based on the magnitude relationship between the two binarized signals in the target traversed data group. When the first binarized signal is less than the second binarized signal, the actual value corresponding to the target traversed data group is 1, and when the first binarized signal is greater than the second binarized signal, the actual value corresponding to the target traversed data group is 0.
[0056] S2074: If two binarized signals in the target traversal data group are identical, delete the target traversal data group and the preceding traversal data group. Add a new binarized signal to the binarized signal to be decoded, resulting in a new binarized signal to be decoded. Re-execute the steps to determine the actual value using the new binarized signal to be decoded until the actual value corresponding to each traversal data group is obtained.
[0057] In this step, for example, if the target traversal data group includes a binary signal with two "1"s or two "0"s, then the target traversal data group and its preceding traversal data group are deleted. The new binary signal can be the binary signal to be decoded following the current binary signal to be decoded. The process of adding the new binary signal to the binary signal to be decoded can be to move the data selection bits backward until the data selection bits do not include the target traversal data group, thereby forming a new binary signal to be decoded from the binary signals in the data selection bits. The step of determining the actual value can include the above step S2073. If two identical binary signals occur during the process of performing step S2073, this step is also included.
[0058] The preceding traversal data group of the target traversal data group can be the traversal array that precedes the target traversal array.
[0059] Figure 4 This is a schematic diagram illustrating the process of determining a new binarized signal to be decoded, as provided in an embodiment of this application. Figure 4 As shown in the image above, since "bit13" and "bit12" are identical (framed by the dashed line on the left), the preceding bits "bit14" and "bit15" are deleted along with "bit13" and "bit12". New binarized signals "bit3", "bit2", "bit1", and "bit0" are then added after the target traversal data set. Figure 4 (The part enclosed by the dashed line in the image below) thus maintains the original number of binarized signals in the new binary signal to be decoded.
[0060] S2075: Determine the actual value corresponding to each traversed data group as the partial decoding information corresponding to the binarized signal to be decoded.
[0061] This step may include concatenating the actual values corresponding to each traversed data group in the binarized signal to be decoded in the order of the traversed data groups to obtain the partial decoding information corresponding to the binarized signal to be decoded.
[0062] For example, if the current binarized signal to be decoded is "0101101001011010", and the actual values corresponding to each traversed data group are "1", "1", "0", "0", "1", "1", "0", "0", then the partial decoding information corresponding to the binarized signal to be decoded is "11001100".
[0063] S2076: Concatenate the partial decoding information corresponding to each binarized signal to be decoded to obtain the decoding information.
[0064] In this step, for example, if there are 4 binarized signals to be decoded, the partial decoding information corresponding to the 4 binarized signals to be decoded is concatenated in sequence to obtain the decoding information.
[0065] As can be seen from the description of the above embodiments, the embodiments of this application start with the first binarized signal in a continuous binarized signal, determine two adjacent binarized signals as a traversal data group, determine the corresponding actual value from the binarized signals in the traversal data group, delete this traversal data group and the previous traversal data group if there are identical binarized signals in the traversal data group, thereby reducing erroneous data and increasing the accuracy of data processing, and finally concatenate the actual values to obtain the partial decoding information corresponding to the binarized signal to be decoded, concatenate the partial decoding information corresponding to the binarized signal to be decoded to obtain the decoding information, and obtain the final decoding information used.
[0066] In one possible implementation, step S2073 above: determining the actual value corresponding to the target traversal data group based on the two binarized signals in the target traversal data group, including:
[0067] S731: If the first binarized signal in the target traversal data group is 0 and the second binarized signal is 1, then 1 is determined as the actual value corresponding to the target traversal data group.
[0068] In this step, for example, if the binarized signal in the target traversal data group is "01", then the corresponding actual value is 1.
[0069] S732: If the first binarized signal in the target traversal data group is 1 and the second binarized signal is 2, then 0 is determined as the actual value corresponding to the target traversal data group.
[0070] In this step, for example, if the binarized signal in the target traversal data group is "10", then the corresponding actual value is 0.
[0071] As can be seen from the description of the above embodiments, the embodiments of this application define the actual value corresponding to the target traversal data group by the value of the binarized signal in the target traversal data group, avoiding the situation where the actual value of the target traversal data value is obtained when two identical binarized signals appear, thereby increasing the accuracy of processing Manchester codes.
[0072] In one possible implementation, step S205 above involves calculating the eigenvalues of N processed Manchester codes, including:
[0073] S2051: Calculate the sum of N processed Manchester codes to obtain the binary sum.
[0074] In this step, a preset program or script can be used to calculate the sum of these N processed Manchester codes.
[0075] S2052: The average value is obtained by right-shifting the binary representation by N square roots.
[0076] In this step, for example, if N is currently 16, the binary sum is shifted right by 4 bits to obtain the average value. Or, for example, if N is currently 64, the binary sum is shifted right by 8 bits to obtain the average value.
[0077] S2053: Round the average value to obtain N processed Manchester code eigenvalues.
[0078] In this step, the rounding method can be either rounding up or rounding down.
[0079] As can be seen from the description of the above embodiments, the embodiments of this application calculate the sum of the processed Manchester code, shift the calculated sum to the right by the square root of N bits to obtain the average value, and then round the average value to obtain the feature value. This realizes the use of the average value as the feature value, which facilitates the subsequent accurate acquisition of the binarized signal corresponding to the processed Manchester code and improves the accuracy of Manchester code processing.
[0080] In one possible implementation, the microcontroller also includes a timer; the memory includes at least one first memory and a second memory;
[0081] The timer can be a 16-bit counter, a 32-bit counter, a 64-bit counter, etc. Random access memory can be used as the first memory and the second memory.
[0082] The method, after receiving the Manchester code to be processed in step S201 above, further includes:
[0083] S210: The timer receives the clock signal and counts according to the clock signal to obtain the target value; if the target value is greater than the preset value, a data transmission command is sent to the analog-to-digital converter.
[0084] This step may include timing based on the number of pulses in the received clock signal to obtain the target value. The preset value may include N as described in the above embodiments. The data transmission command may be a preset command or an electrical signal, etc.
[0085] S211: In response to receiving a data transmission command, the analog-to-digital converter oversamples the Manchester code to be processed to obtain a processed Manchester code of a preset number of bits.
[0086] In this step, the oversampling method is similar to that in step S202 above, and will not be repeated here.
[0087] S212: The analog-to-digital converter writes the processed Manchester code into the first memory.
[0088] This step is similar to step S203 above, and will not be repeated here.
[0089] S213: The first memory writes the processed Manchester code into the second memory.
[0090] In this step, since there is at least one first memory, when writing to the second memory, the processed Manchester code can be written to the second memory in sequence from each of the first memories.
[0091] As can be seen from the description of the above embodiments, the embodiments of this application combine a timer and two types of memory to enable the digital-to-analog converter to oversample the Manchester code to be processed only when the timer count exceeds a preset value, and write the obtained processed Manchester code into the first memory. The first memory then transfers the processed Manchester code to the second memory, so that each component operates periodically and the reception, parsing and transmission of Manchester code do not interfere with each other.
[0092] In one possible implementation, the microcontroller further includes a timer and a digital-to-analog converter; the method, after receiving the Manchester code to be processed, also includes:
[0093] S220: The processing unit obtains the global time and current time corresponding to each memory; if the global time corresponding to the target memory is greater than the current time, it reads the data to be sent from the target memory, where the target memory can be any memory.
[0094] In this step, the current time can be obtained by acquiring a timestamp. If the global time is pre-set by the time processing unit, it can be found by looking up the memory identifier or by accessing the memory. Reading the data to be sent from the target memory can be done using preset commands, programs, or scripts.
[0095] S221: The processing unit sends the data to be sent to the digital-to-analog converter.
[0096] This step may include sending the data to be sent to the digital-to-analog converter in the form of an electrical signal, or it may include sending the data to be sent to the digital-to-analog converter in the form of a voltage level.
[0097] S222: The digital-to-analog converter responds to the data transmission command sent by the timer by converting the data to be transmitted into Manchester code format to obtain the target data to be transmitted.
[0098] In this step, the method for generating the data transmission command can be similar to that in step S210 above, and will not be repeated here. Converting the data to be transmitted into Manchester code format can include converting the data to be transmitted as "01" if the data to be transmitted is 1, and converting the data to be transmitted as "10" if the data to be transmitted is 0.
[0099] S223: The digital-to-analog converter outputs the target data to be sent.
[0100] This step may include sending the target data to be sent to a preset device, or it may include transmitting the target data to be sent to other connected units.
[0101] As can be seen from the description of the above embodiments, the embodiments of this application obtain the global time corresponding to the memory, compare the global time with the current time, and when the global time exceeds the current time, read the data in the memory, convert the data format, and send it, so as to realize the parallel transmission of Manchester code and reduce the impact on other processes.
[0102] In one possible implementation, when no valid data frame needs to be sent, the storage source of the data source channel is set to a fixed Manchester code "0", i.e., an idle frame is sent to ensure better communication compatibility.
[0103] In one possible implementation, after the processing unit obtains the global time and current time corresponding to each memory in step S220 above, the method further includes:
[0104] S224: If data is currently being transmitted and the global time corresponding to the target memory is greater than the current time, the digital-to-analog converter waits for the data being transmitted to be completed before reading the data to be transmitted from the target memory.
[0105] In this step, data is currently being transmitted, which could be due to a digital-to-analog converter transmitting data.
[0106] For example, if the current digital-to-analog converter is sending data from memory A, and the global time corresponding to memory B is already greater than the current time, then the data from memory B will be sent after the data from memory A has been sent.
[0107] As can be seen from the description of the above embodiments, the embodiments of this application, when data is being sent, wait for the data being sent to be completed before sending data in the memory with a global time greater than the current time, thereby avoiding data transmission failure and data transmission channel occupancy.
[0108] During the execution of the above embodiments, no software interruption service is generated, thus ensuring the firmware operation is not interrupted, thereby increasing the efficiency of time resource utilization compared to the microcontroller in existing optical modules. The technical period of the timer is the Manchester encoding period, that is, every time interval of one Manchester code, an instruction is generated to trigger the analog-to-digital converter to oversample the received Manchester encoding, and / or to cause the digital-to-analog converter to output Manchester encoding.
[0109] Figure 5 This is a schematic diagram of the structure of the optical module Manchester code processing system provided in an embodiment of this application. Figure 5 As shown, the optical module Manchester code processing system 500 includes: an analog-to-digital converter 501, a memory 502, and a processing unit 503.
[0110] Analog-to-digital converter 501 is used to receive Manchester code to be processed.
[0111] The analog-to-digital converter 501 is used to oversample the Manchester code to be processed to obtain a processed Manchester code of a preset number of bits.
[0112] Analog-to-digital converter 501 is used to write processed Manchester code into memory.
[0113] Processing unit 503 is used to read N processed Manchester codes from memory 502, where N is a positive integer.
[0114] Processing unit 503 is used to calculate the eigenvalues of N processed Manchester codes.
[0115] The processing unit 503 is used to determine the binarized signals corresponding to the N processed Manchester codes based on the feature values.
[0116] The processing unit 503 is used to determine the decoding information based on each binarized signal.
[0117] The system provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.
[0118] In one possible implementation, processing unit 503 is specifically used to determine N consecutive binarized signals as a group of binarized signals to be decoded. Starting from the first binarized signal in the group of binarized signals to be decoded, every two adjacent binarized signals are determined as traversal data groups. Based on the two binarized signals in the target traversal data group, the actual value corresponding to the target traversal data group is determined, where the target traversal data group is any traversal data group. If the two binarized signals in the target traversal data group are the same, the target traversal data group and the traversal data group preceding the target traversal data group are deleted. A new binarized signal is added to the binarized signals to be decoded to obtain a new binarized signal to be decoded. The step of determining the actual value is repeated using the new binarized signal to be decoded until the actual value corresponding to each traversal data group is obtained. The actual value corresponding to each traversal data group is determined as the partial decoding information corresponding to the binarized signal to be decoded. The partial decoding information corresponding to each binarized signal to be decoded is concatenated to obtain the decoding information.
[0119] The system provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.
[0120] In one possible implementation, the processing unit 503 is specifically configured to determine 1 as the actual value corresponding to the target traversal data group if the first binarized signal in the target traversal data group is 0 and the second binarized signal is 1. If the first binarized signal in the target traversal data group is 1 and the second binarized signal is 2, then 0 is determined as the actual value corresponding to the target traversal data group.
[0121] The system provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.
[0122] In one possible implementation, processing unit 503 is specifically used to calculate the sum of N processed Manchester codes to obtain a binary sum. The binary sum is then right-shifted by the square root of N bits to obtain the average value. The average value is then rounded to obtain the eigenvalues of the N processed Manchester codes.
[0123] The system provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.
[0124] In one possible implementation, the optical module Manchester code processing system 500 further includes a timer 504. The memory 502 includes at least one first memory 5021 and a second memory 5022.
[0125] The timer receives a clock signal and counts according to the clock signal to obtain a target value. If the target value is greater than a preset value, a data transmission command is sent to the analog-to-digital converter (ADC). In response to the received data transmission command, the ADC oversamples the Manchester code to be processed to obtain a processed Manchester code of a preset number of bits. The ADC writes the processed Manchester code into the first memory. The first memory then writes the processed Manchester code into the second memory.
[0126] The system provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.
[0127] In one possible implementation, the optical module Manchester code processing system 500 also includes a timer 504 and a digital-to-analog converter 505.
[0128] The processing unit acquires the global time and current time corresponding to each memory. If the global time corresponding to the target memory is greater than the current time, it reads the data to be transmitted from the target memory, where the target memory can be any memory. The processing unit sends the data to be transmitted to the digital-to-analog converter (DAC). In response to receiving the data transmission command from the timer, the DAC converts the data to be transmitted into Manchester code format to obtain the target data to be transmitted. The DAC outputs the target data to be transmitted.
[0129] The system provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.
[0130] This application also provides a microcontroller, including: an analog-to-digital converter (ADC), a memory, and a processing unit. The output terminal of the ADC is connected to the input terminal of the memory, and the output terminal of the memory is connected to the input terminal of the processing unit. The ADC, memory, and processing unit are used to execute the optical module Manchester code processing method provided in any of the above embodiments.
[0131] The above description is merely a preferred embodiment of this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of disclosure in this application is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this application.
[0132] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0133] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A method for processing Manchester code in an optical module, characterized in that, The method is applied to a microcontroller, wherein the microcontroller includes an analog-to-digital converter, a memory, and a processing unit; the method includes: The analog-to-digital converter receives the Manchester code to be processed; The analog-to-digital converter oversamples the Manchester code to be processed to obtain a processed Manchester code of a preset number of bits. The analog-to-digital converter writes the processed Manchester code into the memory; The processing unit reads N processed Manchester codes from the memory, where N is a positive integer; The processing unit calculates the feature values of the N processed Manchester codes; The processing unit determines the binarized signals corresponding to the N processed Manchester codes based on the feature values. The processing unit determines N consecutive binarized signals as a group of binarized signals to be decoded; starting from the first binarized signal in the group of binarized signals to be decoded, it determines every two adjacent binarized signals as a traversal data group; based on the two binarized signals in the target traversal data group, it determines the actual value corresponding to the target traversal data group, wherein the target traversal data group is any traversal data group; if the two binarized signals in the target traversal data group are the same, it deletes the target traversal data group and the traversal data group preceding the target traversal data group; it adds a new binarized signal to the group of binarized signals to be decoded, obtaining a new binarized signal to be decoded; it re-executes the step of determining the actual value using the new binarized signal to be decoded, until the actual value corresponding to each traversal data group is obtained; it determines the actual value corresponding to each traversal data group as the partial decoding information corresponding to the binarized signal to be decoded; it concatenates the partial decoding information corresponding to each binarized signal to be decoded to obtain the decoding information.
2. The method according to claim 1, characterized in that, The step of determining the actual value corresponding to the target traversal data group based on the two binarized signals in the target traversal data group includes: If the first binarized signal in the target traversal data group is 0 and the second binarized signal is 1, then 1 is determined as the actual value corresponding to the target traversal data group. If the first binarized signal in the target traversal data group is 1 and the second binarized signal is 2, then 0 is determined as the actual value corresponding to the target traversal data group.
3. The method according to claim 1, characterized in that, The calculation of the eigenvalues of the N processed Manchester codes includes: Calculate the sum of the N processed Manchester codes to obtain the binary sum; The average value is obtained by right-shifting the binary number by N to the power of square. The average value is rounded down to obtain the N feature values of the processed Manchester code.
4. The method according to any one of claims 1 to 3, characterized in that, The microcontroller further includes a timer; the memory includes at least one first memory and a second memory; the method, after receiving the Manchester code to be processed, further includes: The timer receives a clock signal and counts according to the clock signal to obtain a target value; if the target value is greater than a preset value, a data transmission command is sent to the analog-to-digital converter. In response to receiving the data transmission instruction, the analog-to-digital converter oversamples the Manchester code to be processed to obtain a processed Manchester code of a preset number of bits. The analog-to-digital converter writes the processed Manchester code into the first memory; The first memory writes the processed Manchester code into the second memory.
5. The method according to any one of claims 1 to 3, characterized in that, The microcontroller also includes a timer and a digital-to-analog converter; The method, after receiving the Manchester code to be processed, further includes: The processing unit obtains the global time and current time corresponding to each memory; if the global time corresponding to the target memory is greater than the current time, it reads the data to be sent from the target memory, wherein the target memory is any memory. The processing unit sends the data to be sent to the digital-to-analog converter; The digital-to-analog converter, in response to receiving a data transmission command from a timer, converts the data to be transmitted into Manchester code format to obtain the target data to be transmitted. The digital-to-analog converter outputs the target data to be sent.
6. The method according to claim 5, characterized in that, After the processing unit obtains the global time and current time corresponding to each memory, the process further includes: If data is currently being transmitted and the global time corresponding to the target memory is greater than the current time, the digital-to-analog converter waits for the transmitted data to be completed before reading the data to be transmitted from the target memory.
7. A Manchester code processing system for an optical module, characterized in that, include: Analog-to-digital converters, memory, and processing units; The analog-to-digital converter is used to receive the Manchester code to be processed; The analog-to-digital converter is used to oversample the Manchester code to be processed to obtain a processed Manchester code of a preset number of bits. The analog-to-digital converter is used to write the processed Manchester code into the memory; The processing unit is used to read N processed Manchester codes from the memory, where N is a positive integer; The processing unit is used to calculate the feature values of the N processed Manchester codes; The processing unit is used to determine the binarized signals corresponding to the N processed Manchester codes based on the feature values. The processing unit is used to determine N consecutive binarized signals into a set of binarized signals to be decoded; Starting from the first binarized signal in the binary signal to be decoded, each pair of adjacent binarized signals is determined as a traversal data group; The actual value corresponding to the target traversal data group is determined based on the two binarized signals in the target traversal data group, wherein the target traversal data group is any traversal data group; If the two binarized signals in the target traversal data group are the same, then the target traversal data group and the traversal data group preceding the target traversal data group are deleted. A new binarized signal is added to the binarized signal to be decoded to obtain a new binarized signal to be decoded; the step of determining the actual value is re-executed using the new binarized signal to be decoded until the actual value corresponding to each traversed data group is obtained; the actual value corresponding to each traversed data group is determined as the decoding information corresponding to the binarized signal to be decoded; the decoding information corresponding to each binarized signal to be decoded is concatenated to obtain the decoding information.
8. A microcontroller, characterized in that, include: Analog-to-digital converters, memory, and processing units; The output terminal of the analog-to-digital converter is connected to the input terminal of the memory, and the output terminal of the memory is connected to the input terminal of the processing unit. The analog-to-digital converter, memory, and processing unit are used to execute the optical module Manchester code processing method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Modulation and demodulation system adaptive to carrier waveform
CN107070564A