Disclosure of Invention
The invention aims to provide an electric stimulation instrument sub-machine identification system capable of realizing rapid and accurate identification of any sub-machine number.
In order to solve the technical problems, the invention provides an electrical stimulation instrument sub-machine identification system, which comprises a host machine, a charging cabin connected with the host machine and a plurality of sub-machines, wherein a plurality of charging hatches are arranged in the charging cabin, at least one charging hatch is configured to be connected with the sub-machines in a serial port communication mode, the rest charging hatches are configured to be connected with the sub-machines in an IO port communication mode, and the electrical stimulation instrument sub-machine identification system adopts the following steps to identify the sub-machines:
the charging cabin detects whether a sub-machine is inserted into any charging hatch;
if yes, the charging hatch acquires serial number information from the sub-machine, wherein the serial number information comprises serial communication data and interrupt trigger information, the serial communication data comprises the number of the sub-machine, the interrupt trigger information comprises N interrupt trigger bits, and N=the number of the sub-machine is-1;
If the charging hatch is a charging hatch configured to be connected with the slave machine in a serial port communication mode, the serial port number of the slave machine is directly obtained according to serial port communication data in the number information;
if the charging hatch is a charging hatch configured to be communicatively connected with the slave unit through an IO port, the method is according to the formula Calculating to obtain a sub-machine number k, and sending the sub-machine number k to a host machine for display, wherein the fall_num is the actual interrupt trigger frequency.
The charging cabin acquires the battery electric quantity and the treatment information of the sub-machine and sends the battery electric quantity and the treatment information to the host for display.
The method comprises the further technical scheme that before the charging cabin obtains the battery electric quantity and the treatment information of the sub-machine, the main machine sends the treatment information to the charging cabin, and the charging cabin is transmitted to the corresponding sub-machine.
The further technical scheme is as follows: the host computer with the charging cabin is through serial ports connection, the charging cabin with the sub-machine is through 2.4G communication mode connection.
The charging cabin comprises a charging cabin main control unit, a plurality of charging hatch charging units and a plurality of charging hatch processing units connected with the charging cabin main control unit, wherein the charging hatch charging units charge the charging hatch processing units and the sub-machines, the charging cabin main control unit is connected with the main machine and the sub-machines respectively through a serial port communication mode and a 2.4G communication mode, and the charging hatch processing units are configured to be connected with the sub-machines through a serial port communication mode/IO port communication mode.
The further technical scheme is that the triggering mode of the interrupt triggering bit is configured as falling edge triggering.
The charging cabin is provided with a plurality of main machine charging hatches and a plurality of small machine charging hatches, wherein one main machine charging hatch and one small machine charging hatch are connected with the sub machine in a serial port communication mode, and the other charging hatches are connected with the sub machine in an IO port communication mode.
The charging method comprises the further technical scheme that if the charging hatch is a charging hatch which is configured to be connected with the slave machine in an IO port communication mode, whether interruption is triggered in preset time is detected, and if not, the slave machine is judged to be pulled out of the charging hatch.
The further technical scheme is that the preset time is 1S.
Compared with the prior art, at least one charging hatch in a charging cabin of the recognition system of the electric stimulator is configured to be connected with the sub-machine in a serial port communication mode, other charging hatches are configured to be connected with the sub-machine in an IO port communication mode, and the number information of the sub-machine is acquired when the main machine is inserted by detecting whether the sub-machine is inserted into the charging hatch, if the charging hatch inserted with the sub-machine is detected to be the charging hatch configured to be connected with the sub-machine in the serial port communication mode, the number of the sub-machine is directly acquired according to serial port communication data in the number information, and if the charging hatch inserted with the sub-machine is detected to be the charging hatch configured to be connected with the sub-machine in the IO port communication mode, the sub-machine number is recognized according to IO interrupt triggering times and set interrupt triggering positions, and the sub-machine number is transmitted to the main machine for display.
Detailed Description
The present invention will be further described with reference to the drawings and examples below in order to more clearly understand the objects, technical solutions and advantages of the present invention to those skilled in the art.
Referring to fig. 1, fig. 1 is a schematic structural diagram of an embodiment of a sub-machine recognition system of an electro-stimulator according to the present invention. In the embodiment shown in the drawings, the recognition system of the sub-machine of the electro-stimulator comprises a host 200, a charging cabin 100 connected with the host 200, and a plurality of sub-machines, wherein a plurality of charging hatches are arranged in the charging cabin 100, at least one charging hatch is configured to be connected with the sub-machine in a serial port communication manner, the other charging hatches are configured to be connected with the sub-machine in an IO port communication manner, the charging hatches are used for charging the sub-machine and recognizing the serial numbers of the sub-machine, and the charging cabin 100 is used for realizing bidirectional communication connection between the sub-machine and the host 200 and transmitting information such as treatment information, battery power and the like.
In some embodiments, the sub-machine includes a sub-machine control unit, the charging cabin 100 includes a charging cabin main control unit 101, a plurality of charging hatch charging units, and a plurality of charging hatch processing units connected to the charging cabin main control unit 101, that is, each charging hatch is correspondingly provided with a charging hatch charging unit and a charging hatch processing unit, where the charging hatch charging unit charges the charging hatch processing unit and the sub-machine, the charging cabin main control unit 101 is connected to the main machine 200 and the sub-machine control unit respectively through a serial port communication mode and a 2.4G communication mode, and the charging hatch processing unit is configured to be connected to the sub-machine through a serial port communication mode/an IO port communication mode.
Specifically, in this embodiment, the charging cabin 100 is provided with eight main machine charging hatches (R1, R2, R3, R4, R5, R6, R7, R8) and eight sub machine charging hatches (L1, L2, L3, L4, L5, L6, L7, L8) for a total of 16 charging hatches, and understandably, the main machine charging hatches (R1, R2,) and the sub machine charging hatches (L1, L2,) and the sub machine charging hatches (L7, R8) are different in size, and accordingly, the charging cabin 100 can be simultaneously inserted with eight main machines and eight sub machines, wherein the main machine charging hatches R1 and the sub machine charging hatches L1 of the charging hatches are connected in serial communication with the sub machine control units of the sub machines, and the remaining charging hatches (R2, R7, R8 and L2,) are connected in serial communication with the sub machine charging hatches of the sub machine.
As shown in fig. 2, the sub-machine identification process of the sub-machine identification system of the electro-stimulation instrument comprises the following steps:
s10, the charging cabin detects whether a sub-machine is inserted into any charging hatch.
In this step, the charging bay main control unit detects whether a child is inserted into any of the child charging hatches (R1, R2,..r 7, R8) and any of the child charging hatches (L1, L2,..r 7, L8), and when a child is inserted, the child number needs to be identified.
In this embodiment, the number of the actually transmitted child machines may be represented by binary or hexadecimal numbers, and in this embodiment, the number range of the child machines may be 0x01 to 0x10, that is, the number of the child machine corresponding to the 1 child machine is 0x01, and the number of the child machine corresponding to the 16 child machine is 0x10.
And S20, if so, the charging hatch acquires the number information from the slave machine, wherein the number information comprises serial port communication data and interrupt trigger information.
In the invention, the serial port communication data comprises a number of the sub-machines, the interrupt trigger information comprises N interrupt trigger bits, and N=the number of the sub-machines is numbered-1. In this embodiment, the number of the child devices refers to 1,2, & gt, and the number information sent by the child device number 4, for example, specifically includes 3 (3=4-1) interrupt trigger bits and corresponding child device numbers (as shown in fig. 3).
In this step, the triggering manner of the interrupt may be preferably configured as a falling edge trigger.
And S30, if the charging hatch is a charging hatch configured to be connected with the sub-machine in a serial port communication mode, directly obtaining the serial number of the sub-machine according to serial port communication data in the serial number information.
In the invention, if the charging hatch inserted into the sub-machine is detected to be the charging hatch R1 of the main machine or the charging hatch L1 of the small sub-machine, namely the charging hatch configured to be connected with the sub-machine in a serial port communication mode, serial port communication data can be received through the serial port, the serial port communication data can be directly identified and obtained, and besides the serial numbers of the sub-machine can be identified, the charging hatch R1 of the main machine and the charging hatch L1 of the small sub-machine can be used for carrying out software upgrading and the like on the sub-machine.
S40, if the charging hatch is a charging hatch configured to be connected with the sub-machine in an IO port communication manner, according to a formulaAnd calculating to obtain a sub-machine number k, and sending the sub-machine number k to a host machine for display.
In this step, the fall_num is the actual interrupt trigger number, that is, the actual total interrupt trigger number in this communication process, "/" is rounded off, and decimal places are discarded.
In the invention, if the charging hatch inserted into the slave machine is detected to be the charging hatch (R2, the..the R7) of the master machine or the charging hatch (L2, the..the L7, the L8) of the slave machine, namely the charging hatch configured to be connected with the slave machine in an IO port communication mode, the number of the slave machine is identified by adopting common IO through interruption (falling edge trigger).
In this step, the interrupt trigger bit may be 0xAA (having 4 falling edges, including a start bit and a stop bit), or 0x55 (having 5 falling edges, including a start bit and a stop bit), so that the influence of the number of the sub-machine on the identification of the falling edges can be effectively avoided, each sub-machine reports the number information of the interrupt trigger bit and the number of the sub-machine to the corresponding charging hatch in a period of 0.5s, and the number of the interrupt trigger bits sent by each sub-machine is the number of the sub-machine subtracted by 1.
For example, when 0xAA is used as the interrupt trigger bit of the number 4 submachine, the actual interrupt trigger number of each interrupt trigger bit is 4 times (as shown in fig. 3), and it can be understood that in the whole communication process, i.e. in the data reporting process, the fall_num includes not only the actual interrupt trigger number of the N interrupt trigger bits, but also the interrupt trigger number triggered by transmitting the submachine number in the number information, and because the submachine number range is 0x01 to 0x10, the interrupt trigger number triggered by the submachine number is less than 4 (i.e. the number of falling edges is less than 4).
In some other embodiments, if the charging hatch is a charging hatch configured to be communicatively connected to the slave unit through the IO port, then detecting whether an interrupt is triggered within a preset time, if not, determining that the slave unit has been pulled out of the charging hatch, and preferably, the preset time is 1S, and if no interrupt is triggered within 1S, the slave unit is considered to be pulled out of the charging cabin because a period of reporting data by each slave unit is 0.5S.
It will be appreciated that if the baud rate of the data reported by the slave unit is 9600, the time of one data bit is 1000000/9600=104 us, the minimum interval between two frame data is 10 bits (0 x00 or 0 xFF), i.e. 1040us, preferably 3ms, i.e. 3ms, and the interrupt is not triggered, then one frame data is considered to be ended.
And S50, the host computer sends the treatment information to the charging cabin, and the charging cabin is transmitted to the corresponding sub-machine.
In the step, the main machine sends treatment information to the charging cabin main control unit through the serial port, and the charging cabin main control unit forwards the treatment information to the corresponding sub-machine control unit through a 2.4G communication mode, wherein the treatment information comprises a treatment mode, treatment parameters and the like.
And S60, the charging cabin acquires the battery electric quantity and the treatment information of the secondary machine and sends the battery electric quantity and the treatment information to the host machine for display.
In the step, the sub-machine control unit reports the battery electric quantity and the treatment information to the charging cabin main control unit through a 2.4G wireless communication mode, and the charging cabin main control unit forwards the battery electric quantity and the treatment information to the host machine through a serial port.
In summary, at least one charging hatch in the charging cabin of the recognition system of the electrical stimulation instrument is configured to be connected with the sub-machine in a serial port communication mode, other charging hatches are configured to be connected with the sub-machine in an IO port communication mode, the sub-machine numbers are recognized according to IO interrupt triggering times and set interrupt triggering positions by detecting whether the sub-machine is inserted into the charging hatch, the serial number information of the sub-machine is acquired when the sub-machine is inserted into the charging hatch, if the charging hatch inserted into the sub-machine is detected to be the charging hatch configured to be connected with the sub-machine in the serial port communication mode, the sub-machine numbers are directly acquired according to serial port communication data in the serial number information, and if the charging hatch inserted into the sub-machine is detected to be configured to be connected with the sub-machine in the IO port communication mode, the sub-machine numbers are recognized according to IO interrupt triggering times and set interrupt triggering positions, and the sub-machine numbers are transmitted to the main machine to be displayed, meanwhile, the main machine can also transmit treatment information to the sub-machine through the charging cabin, and the sub-machine can transmit battery electric quantity and actual treatment information to the main machine through the charging cabin at the moment.
The foregoing is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Various equivalent changes and modifications can be made by those skilled in the art based on the above embodiments, and all equivalent changes or modifications made within the scope of the claims shall fall within the scope of the present invention.