Summary of the invention
Fundamental purpose of the present invention is exactly at the deficiencies in the prior art, and a kind of microcontroller communication circuit, Single Chip Microcomputer (SCM) system and microcontroller communication method that communication line is few, cost is low of using is provided.
For achieving the above object, the present invention is by the following technical solutions:
A kind of microcontroller communication circuit, be used for the communication between first single-chip microcomputer and the second singlechip, described microcontroller communication circuit comprises first power lead, the second source line, first switching device, the second switch device and the second power supply electric capacity, external power source is coupled to the power input of described first single-chip microcomputer by described first power lead, and be coupled to the power input of described second singlechip by described second source line, the signal input part of described first single-chip microcomputer and described second singlechip is coupled to described second source line, the signal output part of described first single-chip microcomputer is coupled to the control end of described first switching device, described first switching device is coupled to described second source line and is configured to described first switching device low level that when opening described second source line is pulled to setting, the signal output part of described second singlechip is coupled to the control end of described second switch device, described second switch device is coupled to described second source line and is configured to described second switch device the low level that when opening described second source line is pulled to setting, and the described second power supply electric capacity is connected described second source line in parallel with described second singlechip.
Preferably, described first switching device is first triode, and the base stage of described first triode connects the signal output part of described first single-chip microcomputer, the grounded emitter of described first triode, and the collector of described first triode connects described second source line.
Described second switch device is second triode, and the base stage of described second triode connects the signal output part of described second singlechip, the grounded emitter of described second triode, and the collector of described second triode connects described second source line.
The circuit that the power input of described second singlechip is connected to described second source line is provided with second diode, and the negative electrode of described second diode connects the power input of described second singlechip.
The signal input part of described first single-chip microcomputer and described second singlechip is the external interrupt interface of single-chip microcomputer, and the signal output part of described first single-chip microcomputer and described second singlechip is the I/O interface of single-chip microcomputer.
Also comprise second filter capacitor that is connected in parallel with the described second power supply electric capacity.
Also comprise the first power supply electric capacity, the described first power supply electric capacity is connected described first power lead in parallel with described first single-chip microcomputer.
Also comprise first filter capacitor that is connected in parallel with the described first power supply electric capacity.
A kind of Single Chip Microcomputer (SCM) system comprises at least two single-chip microcomputers and the microcontroller communication circuit that is connected described at least two single-chip microcomputers, it is characterized in that, described microcontroller communication circuit is as each described microcontroller communication circuit in the claim 1 to 8.
A kind of microcontroller communication method may further comprise the steps:
A. between first single-chip microcomputer and the second singlechip during no communication, external power source is given described first single-chip microcomputer power supply by first power lead, gives described second singlechip power supply and to the second power supply electric capacity charging by the second source line;
B. at described first single-chip microcomputer when described second singlechip sends signal, the signal of described first single-chip microcomputer output is by the break-make of control first switching device, the level signal of described second source line is modulated into corresponding high-low level signal waveform, and be transferred to described second singlechip, when receiving low level signal, described second singlechip gives described second singlechip power supply by the described second power supply capacitance discharges;
C. at described second singlechip when described first single-chip microcomputer sends signal, the signal of described second singlechip output is by the break-make of control second switch device, the level signal of described second source line is modulated into corresponding high-low level signal waveform, and be transferred to described first single-chip microcomputer, when receiving low level signal, described first single-chip microcomputer gives described second singlechip power supply by the described second power supply capacitance discharges.
Beneficial technical effects of the present invention is:
Adopt microcontroller communication circuit of the present invention, only utilize power lead VCC and ground wire GND just can carry out communication between the single-chip microcomputer, compare with existing microcontroller communication circuit, the used communication line of the present invention still less, under the far situation of microcontroller communication distance, the communication line cost reduces especially remarkable.
Embodiment
In conjunction with the accompanying drawings the present invention is further described in detail by the following examples.
Fig. 2 has showed an embodiment of Single Chip Microcomputer (SCM) system of the present invention, and this Single Chip Microcomputer (SCM) system comprises first single-chip microprocessor MCU 1, second singlechip MCU2 and is connected the microcontroller communication circuit of first single-chip microprocessor MCU 1 and second singlechip MCU2.In the present embodiment, the microcontroller communication circuit comprises the first power lead Line1, second source line Line2, first switching device, the second switch device and the second power supply electric capacity E4, wherein, external power source V is coupled to the power input VCC of first single-chip microprocessor MCU 1 by the first power lead Line1, and be coupled to the power input VCC of second singlechip by second source line Line2, the signal input part of first single-chip microprocessor MCU 1 and second singlechip is coupled to second source line Line2, the signal output part of first single-chip microprocessor MCU 1 is coupled to the control end of first switching device, first switching device is coupled to the second source line and is configured to first switching device low level that when opening the second source line is pulled to setting, the signal output part of second singlechip is coupled to the control end of second switch device, the second switch device is coupled to the second source line and is configured to the second switch device low level that when opening the second source line is pulled to setting, and the second power supply electric capacity is connected the second source line in parallel with second singlechip.Compare with the microcontroller communication circuit of routine, the microcontroller communication circuit of present embodiment is only just realized first and second microcontroller communication with power lead and ground wire, has saved CLK clock line and SDA data line, can save cost greatly under communication distance situation far away.
Wherein, the signal input part of first single-chip microcomputer and second singlechip can adopt the external interrupt interface INT of single-chip microcomputer, and it is I/O mouth 1 and I/O mouth 2 that the signal output part of first single-chip microcomputer and second singlechip can adopt the input/output interface of two single-chip microcomputers.
In a preferred embodiment, first switching device is the first triode Q3, the base stage of the first triode Q3 is passed through the signal output part that resistance R 3 connects first single-chip microprocessor MCU 1, the grounded emitter of the first triode Q3, and the collector of the first triode Q3 connects second source line Line2; The second switch device is the second triode Q4, and the base stage of the second triode Q4 is passed through the signal output part that resistance R 5 connects second singlechip MCU2, the grounded emitter of the second triode Q4, and the collector of the second triode Q4 connects second source line Line2.
In a preferred embodiment, the microcontroller communication circuit also comprises the second diode D2, its power input VCC that is arranged on second singlechip is connected on the circuit of second source line Line2, and wherein, the negative electrode of the second diode D2 connects the power input VCC of second singlechip.
In a preferred embodiment, the microcontroller communication circuit also comprises the first power supply electric capacity E3, and the first power supply electric capacity is connected the first power lead Line1 in parallel with E3 first single-chip microcomputer.More preferably, also be connected in parallel to the first filter capacitor C1, also be connected in parallel to the second filter capacitor C2 at the second power supply electric capacity E4 two ends at the first power supply electric capacity E3 two ends.The first power supply electric capacity E3 and the second power supply electric capacity E4 can adopt electrochemical capacitor.
Introduce the principle of work of embodiment shown in Figure 2 below.
1) between first single-chip microprocessor MCU 1 and the second singlechip MCU2 during no communication:
The signal output part I/O mouth 1 of first single-chip microcomputer and the signal output part I/O mouth 2 of second singlechip all are low level, outside input power supply V gives first single-chip microprocessor MCU 1 power supply by the first power lead Line1, and pass through second source line Line2 and give second singlechip MCU2 power supply via the resistance R 1 and the second diode D2, simultaneously to the second power supply electric capacity E4 charging.
2) first single-chip microprocessor MCU 1 is when second singlechip MCU2 sends signal:
The signal of first single-chip microprocessor MCU 1 exports the first triode Q3 to by signal output part I/O mouth 1, control the first triode Q3 according to this signal conduction or shutoff, during the first triode Q3 conducting, the level of second source line Line2 is pulled low to the current potential on ground, promptly form low level at the A point, when the first triode Q3 turn-offs, the level of second source line Line2 remains the input voltage of external power source, for example+5V, promptly form high level at the A point, formed high-low level waveform signal enters the external interrupt interface INT of second singlechip MCU2 from the A point through resistance R 4, and second singlechip MCU2 receives the signal that second singlechip MCU1 sends.
At this moment, the signal output part I/O mouth 2 of second singlechip MCU2 is a low level, and the external interrupt interface INT of first single-chip microprocessor MCU 1 closes.
Fig. 3 schematic presentation the reference waveform of A point when transmission signals., in the process of second singlechip MCU2 transmission signals, when second source line Line2 is low level state, the MCU2 system is powered in first single-chip microprocessor MCU 1 by the second power supply electric capacity E4.
3) second singlechip MCU2 is when first single-chip microprocessor MCU 1 sends signal:
The signal of second singlechip MCU2 exports the second triode Q4 to by signal output part I/O mouth 2, control the second triode Q4 according to this signal conduction or shutoff, during the second triode Q4 conducting, the level of second source line Line2 is pulled low to the current potential on ground, promptly form low level at the A point, when the second triode Q4 turn-offs, the level of second source line Line2 remains the input voltage of external power source, for example+5V, promptly form high level at the A point, formed high-low level waveform signal enters the external interrupt interface INT of first single-chip microprocessor MCU 1 from the A point through resistance R 2, and first single-chip microprocessor MCU 1 receives the signal that second singlechip MCU2 sends.
At this moment, the signal output part I/O mouth 1 of first single-chip microprocessor MCU 2 is a low level, and the external interrupt interface INT of second singlechip MCU2 closes.
Fig. 3 schematic presentation the reference waveform of A point when transmission signals.In the process of first single-chip microprocessor MCU 1 transmission signals between second singlechip MCU2, when second source line Line2 is low level state, second singlechip MCU2 system is powered by the second power supply electric capacity E4.
On the other hand, the present invention also provides a kind of microcontroller communication method, and in one embodiment, this microcontroller communication method may further comprise the steps:
A. between first single-chip microprocessor MCU 1 and the second singlechip MCU2 during no communication, external power source is given the power supply of first single-chip microcomputer by first power lead, by the second source line to the second singlechip power supply and to the second power supply electric capacity E4 charging;
B. in first single-chip microprocessor MCU 1 when second singlechip MCU2 sends signal, the signal of first single-chip microprocessor MCU, 1 output is by the break-make of control first switching device, the level signal of second source line Line2 is modulated into corresponding high-low level signal waveform, and be transferred to second singlechip MCU2, when receiving low level signal, second singlechip MCU2 utilize the second power supply electric capacity E4 to give second singlechip MCU2 power supply;
C. at second singlechip MCU2 when first single-chip microprocessor MCU 1 sends signal, the signal of second singlechip MCU2 output is by the break-make of control second switch device, the level signal of second source line Line2 is modulated into corresponding high-low level signal waveform, and be transferred to first single-chip microprocessor MCU 1, when receiving low level signal, first single-chip microprocessor MCU 1 utilize the second power supply electric capacity E4 to give second singlechip MCU2 power supply.
This method more specifically content of embodiment can repeat no more with reference to the description to as shown in Figure 2 microcontroller communication circuit embodiments.
Above content be in conjunction with concrete preferred implementation to further describing that the present invention did, can not assert that concrete enforcement of the present invention is confined to these explanations.For the general technical staff of the technical field of the invention, without departing from the inventive concept of the premise, can also make some simple deduction or replace, all should be considered as belonging to protection scope of the present invention.