Method, device, electronic device and storage medium for detecting mechanical lock body stroke
By combining the motor and gear with the encoder, the stroke of the mechanical lock body is detected, which solves the problem of the inability to accurately detect the intermediate position in the prior art, and realizes the stroke calibration and adaptation of the intelligent mechanical lock body.
Patent Information
- Application Number
- CN202211086921.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-06
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2042-09-06
AI Technical Summary
The prior art cannot accurately detect the intermediate position when detecting the position of the mechanical lock body switch, and the installation of sensors inside may lead to structural incompatibility and cost increase.
The motor drives multiple gears to rotate the mechanical lock body, rotate it in the opposite direction to the blockage, and use the encoder to obtain the coded value, calculate the coded value difference to determine the calibration stroke of the mechanical lock body.
实现了机械锁体行程的准确校准,适配市面上大部分智能机械锁,避免了结构不兼容和成本增加的问题。
Smart Images

Figure CN115325980B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of intelligent mechanical locks, and particularly to a method, device, electronic device and storage medium for detecting the stroke of a mechanical lock body. Background Art
[0002] Currently, the technology for automatically detecting the switch position of a general mechanical lock body can install a door magnetic sensor on the door lock to judge the switch position of the lock by the opening and closing of the door; or an internal feedback sensor can be installed inside the mechanical lock body to judge the position of the lock. However, using a door magnetic sensor to judge the switch position of the lock body can only simply detect the position where the lock body is fully opened or closed, and cannot detect the intermediate position, nor can it detect when the lock body is jammed; installing a sensor inside the lock body will first damage the original door and lock, secondly increase the cost, and may even cause problems such as structural incompatibility. Summary of the Invention
[0003] In view of the above problems, the present application provides a method, device, electronic device and storage medium for detecting the stroke of a mechanical lock body, which can realize the stroke calibration of the mechanical lock body of an intelligent panel lock without generating incompatibility problems. At the same time, it can be adapted to most intelligent mechanical locks on the market.
[0004] To achieve the above object, in the first aspect of the embodiments of the present application, a method for detecting the stroke of a mechanical lock body is provided, and the method includes:
[0005] Driving a plurality of gears by a motor to rotate the mechanical lock body, rotating in a first direction until jamming, and driving an encoder to perform encoding to obtain a first encoding value;
[0006] Driving a plurality of gears by a motor to rotate the mechanical lock body, rotating in a second direction until jamming, and driving an encoder to perform encoding to obtain a second encoding value, where the first direction and the second direction are opposite;
[0007] Calculating the absolute value of the difference between the first encoding value and the second encoding value to obtain the calibration stroke of the mechanical lock body, where the calibration stroke is the stroke of the mechanical lock body from being jammed when locking to being jammed when unlocking.
[0008] In combination with the first aspect, in a possible implementation manner, driving an encoder to perform encoding to obtain a first encoding value includes:
[0009] Obtaining a first electrical signal diagram when the encoder completes encoding, an initial electrical signal diagram when the encoder does not perform encoding, and an initial encoding value;
[0010] Obtaining the number of pulse changes according to the first electrical signal diagram and the initial electrical signal diagram, where a pulse includes an adjacent low level and a high level;
[0011] Obtain the change value of the encoder according to the number of pulse changes;
[0012] Determine the change direction of the encoder according to the pulse edge increment values of the A and B phase pulses in the initial electrical signal diagram and the pulse edge increment values of the A and B phase pulses in the first electrical signal diagram, where the A and B phase pulses are two orthogonal pulses sent by the encoder during encoding, and the pulse edge increment value is determined by the A and B phase pulses;
[0013] Obtain the first coding value according to the initial coding value, the change value of the encoder, and the change direction of the encoder.
[0014] Combined with the first aspect, in a possible implementation manner, the method further includes:
[0015] When the mechanical lock body is powered on again, the mechanical lock body is recalibrated based on the calibration stroke.
[0016] Combined with the first aspect, in a possible implementation manner, the mechanical lock body is recalibrated based on the calibration stroke, including:
[0017] Take the coding value when the mechanical lock body rotates to the first stall as the third coding value, where the first stall is any one of the locking stall or the unlocking stall;
[0018] Take the coding value when the mechanical lock body rotates to the second stall as the fourth coding value, where the second stall is opposite to the first stall in direction;
[0019] Recalibrate the mechanical lock body according to the third coding value, the fourth coding value, and the calibration stroke.
[0020] Combined with the first aspect, in a possible implementation manner, recalibrating the mechanical lock body according to the third coding value, the fourth coding value, and the calibration stroke includes:
[0021] When the absolute value of the difference between the third coding value and the fourth coding value is the same as the calibration stroke, display a first prompt message, where the first prompt message is used to indicate that the recalibration of the mechanical lock body is successful;
[0022] When the absolute value of the difference between the third coding value and the fourth coding value is not the same as the calibration stroke, display a second prompt message, where the second prompt message is used to indicate that the recalibration of the mechanical lock body fails.
[0023] Combined with the first aspect, in a possible implementation manner, after obtaining the calibration stroke of the mechanical lock body, the method further includes:
[0024] Obtain the working state of the mechanical lock body;
[0025] Determine that the first encoded value is the locked stall encoded value or the unlocked stall encoded value according to the working state of the mechanical lock body.
[0026] Combined with the first aspect, in a possible implementation manner, after recalibrating the mechanical lock body, the panel further includes an indicator light, and the method further includes:
[0027] When the mechanical lock body is turned to the unlocked position, turn on the indicator light to indicate that the mechanical lock body has been opened;
[0028] When the mechanical lock body is turned to the locked position, turn on the indicator light to indicate that the mechanical lock body has been closed.
[0029] A second aspect of the embodiments of the present application provides a method for detecting the travel of a mechanical lock body. This method is applied to a device for detecting the travel of a mechanical lock body, and the method includes:
[0030] An acquisition unit for driving a plurality of gears by a motor to rotate the mechanical lock body, rotating to a stall in the first direction, and driving an encoder to perform encoding to obtain a first encoded value;
[0031] The acquisition unit is further configured to drive a plurality of gears by a motor to rotate the mechanical lock body, rotate to a stall in the second direction, and drive an encoder to perform encoding to obtain a second encoded value, where the first direction and the second direction are opposite;
[0032] A processing unit for calculating the absolute value of the difference between the first encoded value and the second encoded value to obtain the calibration travel of the mechanical lock body, where the calibration travel is the travel of the mechanical lock body from the locked stall to the unlocked stall.
[0033] A third aspect of the embodiments of the present application provides an electronic device. The electronic device includes an input device and an output device, and further includes a processing chip adapted to implement one or more instructions; and a memory storing one or more computer programs, and the one or more computer programs are adapted to be loaded and executed by the processing chip to perform the steps in the method of the first aspect as described above.
[0034] A fourth aspect of the embodiments of the present application provides a computer storage medium storing one or more instructions, and the one or more instructions are adapted to be loaded and executed by the processing chip to perform the steps in the method of the first aspect as described above.
[0035] The above solution of the present application has at least the following beneficial effects:
[0036] In this embodiment, the lock body is connected to the panel by using a motor, multiple gears, and an encoder. First, the motor drives multiple gears to rotate the mechanical lock body, rotates it in two opposite directions until it stalls, and drives the encoder to perform encoding, obtaining a first encoding value and a second encoding value. Calculate the absolute value of the difference between the first encoding value and the second encoding value to obtain the calibration travel of the mechanical lock body. By using the motor to drive multiple gears and the encoder to achieve the travel calibration of the mechanical lock body of the intelligent panel lock, no incompatibility problems will occur, and at the same time, it can be adapted to most intelligent mechanical locks on the market. At the same time, by using the motor to drive multiple gears and the encoder, not only can the travel be calibrated, but also the position change of the lock body can be obtained according to the change of the encoding value, and the intermediate position of the lock body travel can also be determined by the encoder. Description of the Drawings
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained according to these drawings.
[0038] Figure 1 System architecture diagram of a method for detecting the travel of a mechanical lock body provided by an embodiment of the present application;
[0039] Figure 2 Specific application scenario diagram of a method for detecting the travel of a mechanical lock body provided by an embodiment of the present application;
[0040] Figure 3 Flow schematic diagram of a method for detecting the travel of a mechanical lock body provided by an embodiment of the present application;
[0041] Figure 4 First calibration schematic diagram provided by an embodiment of the present application;
[0042] Figure 5 Schematic diagram of the first calibration in the first direction provided by an embodiment of the present application;
[0043] Figure 6 Initial electrical signal schematic diagram provided by an embodiment of the present application;
[0044] Figure 7 First electrical signal schematic diagram provided by an embodiment of the present application;
[0045] Figure 8 Schematic diagram of the first calibration in the second direction provided by an embodiment of the present application;
[0046] Figure 9A schematic diagram for determining the locked-rotor state provided by an embodiment of the present application;
[0047] Figure 10 A schematic diagram for re-calibration after power-off provided by an embodiment of the present application;
[0048] Figure 11 A schematic diagram for the lock being in place provided by an embodiment of the present application;
[0049] Figure 12 A schematic diagram for the lock being locked in place provided by an embodiment of the present application;
[0050] Figure 13 A structural schematic diagram of a device for detecting the travel of a mechanical lock body provided by an embodiment of the present application;
[0051] Figure 14 A schematic diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0052] In order to enable those skilled in the art to better understand the solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0053] The terms "include" and "have" and any variations thereof appearing in the specification, claims and drawings of the present application are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally further include steps or units not listed, or may optionally further include other steps or units inherent to these processes, methods, products or devices. In addition, the terms "first", "second", "third", etc. are used to distinguish different objects, rather than to describe a specific order.
[0054] Please refer to Figure 1 , Figure 1 A system architecture diagram of a method for detecting the travel of a mechanical lock body provided by an embodiment of the present application. This system architecture diagram includes a lock body 10 and a panel 20.
[0055] In this embodiment, the panel 20 is installed outside the keyhole of the lock body 10. Among them, the panel 20 includes a motor 201, a plurality of gears 202, and an encoder 203. Among them, the motor 201 drives the plurality of gears 202, the plurality of gears 202 drive the key to retract, and drive the encoder 203 to perform encoding, and the encoder 203 obtains an encoded value.
[0056] Among them, the mechanical lock body formed by the lock body 10 and the panel 20 installed outside the keyhole of the lock body 10 includes, but is not limited to, a fingerprint recognition intelligent mechanical lock and a password input intelligent mechanical lock.
[0057] In this embodiment, first, the motor 201 drives a plurality of gears 202 to drive the key to move. The key moves in the first direction, and the plurality of gears 202 drive the encoder 203 to perform encoding to obtain a first encoding value. Among them, the first direction is any direction. Then, the motor 201 drives the plurality of gears 202 again to drive the key to move. The key moves in the second direction, and the plurality of gears 202 drive the encoder 203 to perform encoding to obtain a second encoding value. Among them, the first direction and the second direction are opposite. Finally, after obtaining the encoding values of the mechanical lock body in two directions, calculate the absolute value of the difference between the first encoding value and the second encoding value. This absolute value is the calibration stroke of the mechanical lock body, where the calibration stroke is the stroke of the key from the locked position to the unlocked position.
[0058] Please refer to Figure 2 , Figure 2 which is a specific application scenario diagram of a method for detecting the stroke of a mechanical lock body provided by an embodiment of the present application. This scenario is the scenario where the user obtains the calibration stroke of the mechanical lock body.
[0059] The specific scenario is as follows:
[0060] First, the user clicks the lock body first calibration button on the APP. Then, the motor drives a plurality of gears to rotate in any direction until they can no longer rotate, that is, the first stall. At this time, the key also moves to the limit value in any direction. Inside the mechanical lock body, the motor drives a plurality of gears to rotate in the first direction until they stall, and at the same time drives the key of the mechanical lock body to move, and drives the encoder to perform encoding to obtain a first encoding value.
[0061] Then, the motor drives a plurality of gears to rotate in the opposite direction of the above-mentioned any direction until they can no longer rotate, that is, the second stall, to obtain a second encoding value.
[0062] Finally, calculate the absolute value of the difference between the first encoding value and the second encoding value to obtain the calibration stroke of the mechanical lock body, where the calibration stroke is the overall stroke of the key of the mechanical lock body, that is, the stroke of the key of the mechanical lock body from the stall position on one side to the stall position in the opposite direction.
[0063] Please refer to Figure 3 , Figure 3 which is a flow schematic diagram of a method for detecting the stroke of a mechanical lock body provided by an embodiment of the present application. This method is applied to a device for detecting the stroke of a mechanical lock body, as Figure 3 shown, and includes steps 301-303:
[0064] 301: Drive a mechanical lock body with a motor to rotate multiple gears, rotate to a stall in the first direction, and drive an encoder to perform encoding to obtain a first encoding value.
[0065] In this embodiment, the mechanical lock body composed of a lock body and a panel is different from a traditional mechanical lock. The mechanical lock body composed of a lock body and a panel can be opened not only with a key but also with fingerprints or passwords. When a user uses the mechanical lock body composed of a lock body and a panel for the first time, the mechanical lock body has not been calibrated for travel at this time. Therefore, when the user uses fingerprints or a password to unlock the lock, there is a problem that the lock cannot be opened. Therefore, the user needs to perform travel calibration when using it for the first time.
[0066] Please refer to Figure 4 , Figure 4 which is a schematic diagram of the first calibration provided by an embodiment of this application. The user can first install the corresponding APP in the mobile device or directly perform calibration on the panel. This embodiment will be described by taking the user as an example who has installed the corresponding APP.
[0067] Please refer to Figure 5 , Figure 5 which is a schematic diagram of the first calibration in the first direction provided by an embodiment of this application. The user first clicks the first calibration button of the lock body on the APP. Then, the motor in the panel drives multiple gears to rotate; when the multiple gears rotate, they drive the key in the lock body to move in the first direction; at the same time, the multiple gears also drive the connected encoder to perform encoding. When the key can no longer move in the first direction, it means that the lock body has reached the first stall, that is, the end point of rotation in the first direction. At this time, the first encoding value obtained by the encoder through encoding is used for subsequent calculations.
[0068] Among them, driving the encoder to perform encoding to obtain a first encoding value includes:
[0069] First, please refer to Figure 6 , Figure 6 which is a schematic diagram of an initial electrical signal provided by an embodiment of this application. When the encoder performs encoding, it will emit two orthogonal pulses, namely, A-phase pulse and B-phase pulse, and the phase difference between the A-phase pulse and the B-phase pulse is 90°. Obtain the initial electrical signal diagram of the encoder and its initial encoding value when the mechanical lock body has not been calibrated. Please refer to Figure 7 , Figure 7 which is a schematic diagram of a first electrical signal provided by an embodiment of this application. When starting to calibrate the mechanical lock body, when the mechanical lock body rotates from the first direction to a stall, the first electrical signal diagram of the encoder is as shown in Figure 7 , including the initial electrical signal diagram.
[0070] Then, according to the changes in the A-phase and B-phase pulses of the first electrical signal diagram and the initial electrical signal diagram, the change value of the encoder can be obtained. Please refer to Figure 6 and Figure 7 , it can be seen that in the initial electrical signal diagram and the first electrical signal diagram, both the upper and lower A-phase and B-phase pulses change. Among them, one high level and one low level in the A-phase pulse are one pulse, and one high level and one low level in the B-phase pulse are also one pulse. Therefore, from Figure 7 , the number of pulse changes obtained is four. And a change in one pulse also represents a change in the encoded value of the encoder. Therefore, the change value of the encoded value of the encoder during the first stall can also be obtained as 4.
[0071] Then, obtain the pulse edge increment value in the first electrical signal diagram and the pulse edge increment value in the initial electrical signal diagram. According to the pulse edge increment value in the first electrical signal diagram and the pulse edge increment value in the initial electrical signal diagram, determine the direction of the pulse edge increment value in the first electrical signal diagram, where the pulse edge increment value is determined by the changes in the A-phase and B-phase pulses in the first electrical signal diagram; if the signs of the pulse edge increment value in the first electrical signal diagram and the pulse edge increment value in the initial electrical signal diagram are the same, the direction remains unchanged; if the signs of the pulse edge increment value in the first electrical signal diagram and the pulse edge increment value in the initial electrical signal diagram are opposite, the direction is opposite.
[0072] Among them, please refer to Figure 7 , in the figure, the pulse edge increment value is obtained when the A-phase and B-phase pulses change.
[0073] As Figure 7 shown, when the level state of the A-phase pulse is a rising edge and the level state of the B-phase pulse remains unchanged, the pulse edge increment value is determined to be 1; when the level state of the A-phase pulse is a falling edge and the level state of the B-phase pulse remains unchanged, the pulse edge increment value is determined to be -1; when the level state of the A-phase pulse remains unchanged and the level state of the B-phase pulse is a rising edge, the pulse edge increment value is determined to be 1; when the level state of the A-phase pulse remains unchanged and the level state of the B-phase pulse is a falling edge, the pulse edge increment value is determined to be -1.
[0074] Based on this, the pulse edge increment value in the first electrical signal diagram and the pulse edge increment value in the initial electrical signal diagram can be obtained, and the direction of the pulse edge increment value in the first electrical signal diagram can be determined. Please refer to Figure 7 , the pulse edge increment value in the initial electrical signal diagram is 4, and the pulse edge increment value in the first electrical signal diagram is 0, then the directions of the initial electrical signal diagram and the first electrical signal diagram are the same, that is, the encoded value increases by 4.
[0075] Finally, obtain the first encoded value according to the initial encoded value and the change value of the encoder.
[0076] 302: Drive a mechanical lock body to rotate multiple gears through a motor, rotate in a second direction until it stalls, and drive an encoder to perform encoding to obtain a second encoded value, where the first direction and the second direction are opposite.
[0077] In this embodiment, please refer to Figure 8 , Figure 8 This is a schematic diagram of the first calibration in the second direction provided by the embodiment of the present application. When the motor can no longer drive multiple gears to drive the key in the first direction, the motor will drive multiple gears, and the multiple gears will drive the key in the opposite direction of the first direction, that is, the second direction. At the same time, the multiple gears drive the encoder to perform encoding. Until the motor can no longer drive multiple gears to drive the key in the second direction, that is, the second stall, obtain the second encoded value in the encoder.
[0078] 303: Calculate the absolute value of the difference between the first encoded value and the second encoded value to obtain the calibration stroke of the mechanical lock body, where the calibration stroke is the stroke of the mechanical lock body from the locked stall to the unlocked stall.
[0079] In this embodiment, the first encoded value corresponds to when the mechanical lock body rotates in the first direction until it can no longer rotate. At this time, the first encoded value is the first direction stall value. The second encoded value corresponds to the second encoded value when the mechanical lock body stalls from the first encoded value of the first direction stall to the second direction stall. Among them, the entire stroke of the first encoded value of the first direction stall to the second encoded value of the second direction stall is opposite to the calibration stroke direction of the mechanical lock body. Therefore, the calibration stroke of the mechanical lock body is the absolute value of the difference between the second encoded value and the first encoded value. Through two opposite direction stall detections, the calibration stroke of the mechanical lock body can be obtained, which allows the user to calibrate as soon as possible and use the mechanical lock body.
[0080] In this embodiment, in order to obtain the working state of the mechanical lock body when it stalls in the first direction or the second direction, the user will upload whether the mechanical lock body is in the unlocked state or the locked state when it stalls during calibration.
[0081] Please refer to Figure 9 , Figure 9 This is a schematic diagram of determining the stall state provided by the embodiment of the present application. For example, when the mechanical lock body reaches the locked stall, the user confirms that the working state of the mechanical lock body is the locked state in the APP based on whether the mechanical lock body is open or closed as seen. Then, when the mechanical lock body reaches the unlocked stall, the working state of the mechanical lock body is the unlocked state.
[0082] In another embodiment, the mechanical lock body can be a fingerprint intelligent recognition lock or a password intelligent recognition lock. For the mechanical lock body to be operational, it needs to be powered on. However, when the mechanical lock body loses power due to unstable factors, the user will use the key to unlock or lock, or use the knob on the mechanical lock body to unlock or lock. At this time, if the mechanical lock body is powered on again, the mechanical lock body cannot determine the calibration stroke. Since the user manually unlocks or locks, each unlocking or locking may not reach the stall position, resulting in the mechanical lock body being unable to determine whether it reaches the stall position when intelligently locking or unlocking, and thus unable to unlock or lock.
[0083] Therefore, when the mechanical lock body is powered on again after a power outage, the mechanical lock body needs to be recalibrated based on the calibration stroke during the initial use.
[0084] The method adopted for this recalibration is to obtain the absolute value of the difference between the encoded values when the mechanical lock body is rotated to the stall in two directions and compare it with the calibration stroke, thereby determining whether the mechanical lock body is successfully recalibrated. This is similar to the method of obtaining the calibration stroke of the mechanical lock body described above.
[0085] Please refer to Figure 10 , Figure 10 which is a schematic diagram of recalibration after a power outage provided by an embodiment of the present application. First, the encoded value when the mechanical lock body is rotated to the stall in any direction is used as the third encoded value, where the stall can be either the locking stall or the unlocking stall.
[0086] Then, the encoded value when the mechanical lock body is rotated to the stall in the opposite direction is used as the fourth encoded value, and then the absolute value of the difference between the third encoded value and the fourth encoded value is calculated.
[0087] Finally, when the absolute value of the difference between the third encoded value and the fourth encoded value is equal to the calibration stroke, it is confirmed that the mechanical lock body has been successfully recalibrated.
[0088] In another embodiment, when the mechanical lock body has been successfully recalibrated and can operate normally, in order to reduce damage to the mechanical lock body, a threshold value for the lock body in place and an indicator light are set in the panel. The lock body in place includes the locking in place and the unlocking in place. Please refer to Figure 11 , Figure 11 which is a schematic diagram of unlocking in place provided by an embodiment of the present application. Unlocking in place refers to the position where the mechanical lock body is just opened, and there is a certain distance from this position to the unlocking stall, and this distance is the first preset value. Please refer to Figure 12 , Figure 12 which is a schematic diagram of locking in place provided by an embodiment of the present application. Locking in place refers to the position where the mechanical lock body is just locked, and there is a certain distance from this position to the unlocking stall, and this distance is the second preset value. The first preset value and the second preset value vary according to different requirements of the mechanical lock body.
[0089] Among them, when the mechanical lock body is in the unlocked position, it is already in the open state. To avoid damage to the lock body, at this time, the indicator light is turned on to remind the user that the mechanical lock body has been opened and there is no need to continue turning the mechanical lock body. On the one hand, the indicator light is used to prompt the user that the door is opened or closed. On the other hand, it also avoids the locked-rotor state during each unlocking or locking process, which may cause damage to the mechanical lock body. The situation when the lock is in the locked position is the same as the above and will not be elaborated here.
[0090] It can be seen that based on the description of the method embodiment for detecting the stroke of the mechanical lock body above, the embodiment of the present application connects the lock body and the panel by using a motor, multiple gears and an encoder. First, the motor drives multiple gears to rotate the mechanical lock body, rotates in two opposite directions until locked-rotor, and drives the encoder to perform encoding to obtain a first encoding value and a second encoding value. Calculate the absolute value of the difference between the first encoding value and the second encoding value to obtain the calibration stroke of the mechanical lock body. By driving multiple gears and the encoder with the motor to realize the stroke calibration of the mechanical lock body of the intelligent panel lock, no incompatibility problem will occur, and at the same time, it can be adapted to most intelligent mechanical locks on the market. At the same time, by driving multiple gears and the encoder with the motor, not only can the stroke be calibrated, but also the position change of the lock body can be obtained according to the change of the encoding value, and the intermediate position of the lock body stroke can also be determined by the encoder.
[0091] Please refer to Figure 13 , Figure 13 which is a schematic structural diagram of a device for detecting the stroke of a mechanical lock body provided by an embodiment of the present application. As Figure 13 shown, the device for detecting the stroke of the mechanical lock body includes an acquisition unit 1301 and a processing unit 1302; where:
[0092] The acquisition unit is configured to drive multiple gears with a motor to rotate the mechanical lock body, rotate in a first direction until locked-rotor, and drive the encoder to perform encoding to obtain a first encoding value;
[0093] The acquisition unit is further configured to drive multiple gears with a motor to rotate the mechanical lock body, rotate in a second direction until locked-rotor, and drive the encoder to perform encoding to obtain a second encoding value, where the first direction and the second direction are opposite;
[0094] The processing unit is configured to calculate the absolute value of the difference between the first encoding value and the second encoding value to obtain the calibration stroke of the mechanical lock body, where the calibration stroke is the stroke of the mechanical lock body from the locked state during locking to the locked state during unlocking.
[0095] It can be seen that in Figure 13In the device for detecting the stroke of the mechanical lock body shown, the acquisition unit 1301 and the processing unit 1302 are used to calibrate the lock body stroke. The coverage is complete, and the problem of adapting multiple intelligent mechanical locks can be solved. It is beneficial to realize the connection between an electronic device such as a mobile phone and the mechanical lock body. The lock body and the panel are connected together by a motor, multiple gears, and an encoder. First, the motor drives multiple gears to rotate the mechanical lock body, rotates in two opposite directions until it is blocked, and drives the encoder to encode to obtain a first encoded value and a second encoded value. Calculate the absolute value of the difference between the first encoded value and the second encoded value to obtain the calibration stroke of the mechanical lock body. The stroke calibration of the mechanical lock body of the intelligent panel lock is realized by driving multiple gears and an encoder with a motor, which will not cause incompatibility problems and can adapt to most intelligent mechanical locks on the market at the same time. At the same time, by driving multiple gears and an encoder with a motor, not only can the stroke be calibrated, but also the position change of the lock body can be obtained according to the change of the encoded value, and the middle position of the lock body stroke can also be determined by the encoder.
[0096] In a possible implementation manner, in terms of driving the encoder to encode to obtain a first encoded value, the processing unit 1302 is specifically configured to:
[0097] Obtain a first electrical signal diagram when the encoder completes encoding, an initial electrical signal diagram when the encoder does not perform encoding, and an initial encoded value;
[0098] According to the first electrical signal diagram and the initial electrical signal diagram, obtain the number of pulse changes, where the pulse includes an adjacent low level and a high level;
[0099] According to the number of pulse changes, obtain the change value of the encoder;
[0100] According to the pulse edge increment values of the A and B phase pulses in the initial electrical signal diagram and the pulse edge increment values of the A and B phase pulses in the first electrical signal diagram, determine the change direction of the encoder, where the A and B phase pulses are two orthogonal pulses sent by the encoder during encoding, and the pulse edge increment value is determined by the A and B phase pulses;
[0101] According to the initial encoded value, the change value of the encoder, and the change direction of the encoder, obtain the first encoded value.
[0102] In a possible implementation manner, the processing unit 1302 is specifically configured to:
[0103] When the mechanical lock body is powered on again, the mechanical lock body is recalibrated based on the calibration stroke.
[0104] In a possible implementation manner, in terms of the mechanical lock body being recalibrated based on the calibration stroke, the processing unit 1302 is specifically configured to:
[0105] Use the encoded value when the mechanical lock body rotates to the first stall as the third encoded value, where the first stall is either the locking stall or the unlocking stall;
[0106] Use the encoded value when the mechanical lock body rotates to the second stall as the fourth encoded value, where the second stall is in the opposite direction to the first stall;
[0107] Re - calibrate the mechanical lock body according to the third encoded value, the fourth encoded value, and the calibration stroke.
[0108] In a possible implementation manner, in terms of re - calibrating the mechanical lock body according to the third encoded value, the fourth encoded value, and the calibration stroke, the processing unit 1302 is specifically configured to:
[0109] When the absolute value of the difference between the third encoded value and the fourth encoded value is the same as the calibration stroke, display a first prompt message, where the first prompt message is used to indicate that the re - calibration of the mechanical lock body is successful;
[0110] When the absolute value of the difference between the third encoded value and the fourth encoded value is not the same as the calibration stroke, display a second prompt message, where the second prompt message is used to indicate that the re - calibration of the mechanical lock body fails.
[0111] In a possible implementation manner, after obtaining the calibration stroke of the mechanical lock body, the processing unit 1302 is specifically configured to:
[0112] Obtain the working state of the mechanical lock body;
[0113] According to the working state of the mechanical lock body, determine whether the first encoded value is the locking - stall encoded value or the unlocking - stall encoded value.
[0114] In a possible implementation manner, after re - calibrating the mechanical lock body, the panel further includes an indicator light, and the processing unit 1302 is specifically configured to:
[0115] When the mechanical lock body is twisted to the unlocking - in - place position, turn on the indicator light to indicate that the mechanical lock body is opened;
[0116] When the mechanical lock body is twisted to the locking - in - place position, turn on the indicator light to indicate that the mechanical lock body is closed. According to an embodiment of the present application, Figure 13Each unit of the cloud server shown can be separately or all combined into one or several other units to form, or a certain one (or some) of the units can be further split into multiple smaller units in terms of function to form. This can achieve the same operations without affecting the realization of the technical effects of the embodiments of this application. The above units are divided based on logical functions. In practical applications, the function of one unit can also be realized by multiple units, or the functions of multiple units can be realized by one unit. In other embodiments of this application, the cloud server can also include other units. In practical applications, these functions can also be assisted by other units and can be realized by the cooperation of multiple units.
[0117] According to another embodiment of this application, it can be achieved by running a computer program (including program code) that can execute each step involved in the corresponding method shown in Figure 3 on a general computing device such as a computer including processing elements and storage elements such as a central processing unit (CPU), a random access storage medium (RAM), and a read-only storage medium (ROM), to construct a device for detecting the stroke of a mechanical lock body as shown in Figure 13 and to implement the method for detecting the stroke of a mechanical lock body in the embodiments of this application. The computer program can be recorded on, for example, a computer-readable recording medium, loaded into the above computing device through the computer-readable recording medium, and run therein.
[0118] Based on the descriptions of the above method embodiments and device embodiments, the embodiments of this application also provide an electronic device. Please refer to Figure 14 , this electronic device at least includes a processor 1401, an input device 1402, an output device 1403, and a memory 1404. Among them, the processor 1401, the input device 1402, the output device 1403, and the memory 1404 in the electronic device can be connected through a bus or other means.
[0119] The memory 1404 can be stored in the memory of the electronic device. The memory 1404 is used to store a computer program. The computer program includes program instructions. The processor 1401 is used to execute the program instructions stored in the memory 1404. The processor 1401 (or CPU (Central Processing Unit, central processor)) is the computing core and control core of the electronic device, and is suitable for implementing one or more instructions. Specifically, it is suitable for loading and executing one or more instructions to thereby implement the corresponding method flow or corresponding function.
[0120] In one embodiment, the processor 1401 of the electronic device provided in the embodiments of this application can be used to perform a series of processes of the method for detecting the stroke of a mechanical lock body:
[0121] Drive a mechanical lock body to rotate through a motor driving multiple gears, rotate to a stall in the first direction, and drive an encoder to perform encoding to obtain a first encoding value;
[0122] Drive a mechanical lock body to rotate through a motor driving multiple gears, rotate to a stall in the second direction, and drive an encoder to perform encoding to obtain a second encoding value, where the first direction and the second direction are opposite;
[0123] Calculate the absolute value of the difference between the first encoding value and the second encoding value to obtain the calibration travel of the mechanical lock body, where the calibration travel is the travel of the mechanical lock body from being locked to a stall to being unlocked to a stall.
[0124] It can be seen that in Figure 14 In the electronic device shown, it is beneficial to realize that in the scenario where an electronic device such as a mobile phone is connected to a mechanical lock body, the lock body and the panel are connected together by using a motor, multiple gears, and an encoder. First, drive a mechanical lock body to rotate through a motor driving multiple gears, rotate to a stall in two opposite directions, and drive an encoder to perform encoding to obtain a first encoding value and a second encoding value. Calculate the absolute value of the difference between the first encoding value and the second encoding value to obtain the calibration travel of the mechanical lock body. The travel calibration of the mechanical lock body of the intelligent panel lock is realized by driving multiple gears and an encoder through a motor, which will not cause incompatibility problems and can be adapted to most intelligent mechanical locks on the market at the same time. At the same time, by driving multiple gears and an encoder through a motor, not only can the travel be calibrated, but also the position change of the lock body can be obtained according to the change of the encoding value, and the intermediate position of the lock body travel can also be determined through the encoder.
[0125] In another embodiment, the processor 1401 executes driving the encoder to perform encoding to obtain a first encoding value, including:
[0126] Obtain a first electrical signal diagram when the encoder completes encoding, an initial electrical signal diagram when the encoder does not perform encoding, and an initial encoding value;
[0127] According to the first electrical signal diagram and the initial electrical signal diagram, obtain the number of pulse changes, where a pulse includes an adjacent low level and a high level;
[0128] According to the number of pulse changes, obtain the change value of the encoder;
[0129] According to the pulse edge increment values of the A and B phase pulses in the initial electrical signal diagram and the pulse edge increment values of the A and B phase pulses in the first electrical signal diagram, determine the change direction of the encoder, where the A and B phase pulses are two orthogonal pulses A and B emitted by the encoder during encoding, and the pulse edge increment value is determined by the A and B phase pulses;
[0130] According to the initial encoding value, the change value of the encoder, and the change direction of the encoder, obtain the first encoding value.
[0131] In another embodiment, the processor 1401 executes:
[0132] When the mechanical lock body is powered on again, the mechanical lock body is recalibrated based on the calibration stroke.
[0133] In another embodiment, the processor 1401 executes that the mechanical lock body is recalibrated based on the calibration stroke, including:
[0134] Taking the encoded value when the mechanical lock body rotates to the first stall as the third encoded value, where the first stall is any one of the locking stall or the unlocking stall;
[0135] Taking the encoded value when the mechanical lock body rotates to the second stall as the fourth encoded value, where the second stall is opposite to the first stall in direction;
[0136] Recalibrating the mechanical lock body according to the third encoded value, the fourth encoded value, and the calibration stroke.
[0137] In another embodiment, the processor 1401 executes recalibrating the mechanical lock body according to the third encoded value, the fourth encoded value, and the calibration stroke, including:
[0138] When the absolute value of the difference between the third encoded value and the fourth encoded value is the same as the calibration stroke, displaying a first prompt message, where the first prompt message is used to indicate that the recalibration of the mechanical lock body is successful;
[0139] When the absolute value of the difference between the third encoded value and the fourth encoded value is not the same as the calibration stroke, displaying a second prompt message, where the second prompt message is used to indicate that the recalibration of the mechanical lock body fails. In another embodiment, after obtaining the calibration stroke of the mechanical lock body, the processor 1401 further executes:
[0140] Obtaining the working state of the mechanical lock body;
[0141] Determining whether the first encoded value is the locking stall encoded value or the unlocking stall encoded value according to the working state of the mechanical lock body.
[0142] In another embodiment, after the processor 1401 recalibrates the mechanical lock body, and the panel further includes an indicator light, the processor 1401 further executes:
[0143] When the mechanical lock body is turned to the unlocking in-place position, turning on the indicator light to indicate that the mechanical lock body has been opened;
[0144] When the mechanical lock body is twisted until it is locked in place, turn on the indicator light to indicate that the mechanical lock body is closed. Exemplarily, the electronic device can be an ultrasonic examination device, a computer, etc. The electronic device includes but is not limited to a processor 1401, an input device 1402, an output device 1403, and a memory 1404. It can also include memory, power supply, application client module, etc. The input device 1402 can be a scanning device, a keyboard, a touch screen, a radio frequency receiver, etc., and the output device 1403 can be a speaker, a display, a radio frequency transmitter, etc. Those skilled in the art can understand that the schematic diagram is only an example of the electronic device and does not constitute a limitation on the electronic device. It can include more or fewer components than those shown, or combine certain components, or different components.
[0145] It should be noted that since the processor 1401 of the electronic device implements the steps in the above method for detecting the travel of the mechanical lock body when executing the computer program, the embodiments of the above method for detecting the travel of the mechanical lock body are all applicable to this electronic device and can achieve the same or similar beneficial effects.
[0146] The embodiment of the present application also provides a computer storage medium (Memory). The computer storage medium is a memory device in the electronic device and is used to store programs and data. It can be understood that the computer storage medium here can include both the built-in storage medium in the terminal and, of course, the extended storage medium supported by the terminal. The computer storage medium provides a storage space, and the operating system of the terminal is stored in this storage space. And, one or more instructions suitable for being loaded and executed by the processor 1401 are stored in this storage space. These instructions can be one or more computer programs (including program codes). It should be noted that the computer storage medium here can be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory; optionally, it can also be at least one computer storage medium located far from the aforementioned processor 1401. In one embodiment, one or more instructions stored in the computer storage medium can be loaded and executed by the processor 1401 to implement the corresponding steps of the above method for detecting the travel of the mechanical lock body.
[0147] Exemplarily, a computer program on a computer storage medium includes computer program code, which can be in the form of source code, object code, executable files, or some intermediate forms, etc. The computer-readable medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, mobile hard disks, magnetic disks, optical disks, computer memories, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), electrical carrier signals, telecommunication signals, and software distribution media, etc.
[0148] It should be noted that since the computer program on the computer storage medium implements the steps in the above method for detecting the stroke of the mechanical lock body when executed by the processor, all embodiments of the above method for detecting the stroke of the mechanical lock body are applicable to this computer storage medium and can achieve the same or similar beneficial effects.
[0149] The above has introduced the embodiments of the present application in detail. Specific examples are used herein to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A method for detecting the stroke of a mechanical lock body, characterized in that, Applied to a mechanical lock body, wherein the mechanical lock body includes a lock body and a panel, and the panel includes a motor, a plurality of gears, and an encoder. The method includes: Driving the plurality of gears by the motor to rotate the mechanical lock body, rotating to a stall in a first direction, and driving the encoder to perform encoding to obtain a first encoded value; Driving the plurality of gears by the motor to rotate the mechanical lock body, rotating to a stall in a second direction, and driving the encoder to perform encoding to obtain a second encoded value, wherein the first direction and the second direction are opposite; Calculating the absolute value of the difference between the first encoded value and the second encoded value to obtain the calibration stroke of the mechanical lock body, wherein the calibration stroke is the stroke of the mechanical lock body from being locked to a stall to being unlocked to a stall; When the mechanical lock body is powered on again, taking the encoded value when the mechanical lock body rotates to the first stall as a third encoded value, wherein the first stall is any one of being locked to a stall or being unlocked to a stall; taking the encoded value when the mechanical lock body rotates to the second stall as a fourth encoded value, wherein the second stall is opposite to the first stall in direction; When the absolute value of the difference between the third encoded value and the fourth encoded value is the same as the calibration stroke, displaying a first prompt message, wherein the first prompt message is used to indicate that the mechanical lock body is successfully recalibrated; When the absolute value of the difference between the third encoded value and the fourth encoded value is not the same as the calibration stroke, displaying a second prompt message, wherein the second prompt message is used to indicate that the mechanical lock body fails to be recalibrated.
2. The method according to claim 1, wherein The driving the encoder to perform encoding to obtain a first encoded value includes: Obtaining a first electrical signal diagram when the encoder completes encoding, an initial electrical signal diagram when the encoder does not perform encoding, and an initial encoded value; Obtaining the number of pulse changes according to the first electrical signal diagram and the initial electrical signal diagram, wherein the pulse includes an adjacent low level and a high level; Obtaining the change value of the encoder according to the number of pulse changes; Determining the change direction of the encoder according to the pulse edge increment values of the A and B phase pulses in the initial electrical signal diagram and the pulse edge increment values of the A and B phase pulses in the first electrical signal diagram, wherein the A and B phase pulses are two orthogonal pulses emitted by the encoder during encoding, and the pulse edge increment value is determined by the A and B phase pulses; Obtaining the first encoded value according to the initial encoded value, the change value of the encoder, and the change direction of the encoder.
3. The method according to claim 1 or 2, characterized in that, After obtaining the calibration stroke of the mechanical lock body, the method further includes: Obtaining the working state of the mechanical lock body; Determining that the first encoded value is a locked-to-stall encoded value or an unlocked-to-stall encoded value according to the working state of the mechanical lock body.
4. The method according to claim 1 or 2, characterized in that, After recalibrating the mechanical lock body, the panel further includes an indicator light. The method further includes: When the mechanical lock body is turned to the unlocked position, turning on the indicator light to indicate that the mechanical lock body is opened; When the mechanical lock body is twisted to the locked position, turn on the indicator light to indicate that the mechanical lock body is closed.
5. A device for detecting the stroke of a mechanical lock body, characterized in that, The device for detecting the stroke of the mechanical lock body is used to implement the method according to any one of claims 1-4. The device for detecting the stroke of the mechanical lock body includes: An acquisition unit, configured to drive the mechanical lock body to rotate by the motor driving the plurality of gears, rotate in a first direction until blocked, and drive the encoder to perform encoding to obtain a first encoded value; The acquisition unit is further configured to drive the mechanical lock body to rotate by the motor driving the plurality of gears, rotate in a second direction until blocked, and drive the encoder to perform encoding to obtain a second encoded value, wherein the first direction and the second direction are opposite; A processing unit, configured to calculate the absolute value of the difference between the first encoded value and the second encoded value to obtain the calibrated stroke of the mechanical lock body, wherein the calibrated stroke is the stroke of the mechanical lock body from the locked blocked state to the unlocked blocked state.
6. An electronic device, characterized in that, Comprising: A processor and a memory, the processor is connected to the memory, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory so that the electronic device executes the method according to any one of claims 1-4.
7. A computer-readable storage medium, characterized in that, A computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1-4.
Citation Information
Patent Citations
Inteligent self-adaptive driving system and method for electronic lock
CN109403730A
Intelligent motor and control system thereof
CN113137139A
Motor encoder decoding method and device, electronic equipment and storage medium
CN114499697A
Switch lock structure and intelligent lock
CN214835486U