The Drawback of I2C Connection on Inter Controller Communication from Software Architectural Perspective
Inter-Integrated Circuit (I2C) is often favored by embedded system designer among other peripherals for its simplicity. By just using two wires: one for clock (SCL) and one for data (SDA), we could achieve bidirectional communication between two ICs. But from my recent studies and experience, it is not however suitable for inter-controller communication.
What is inter-controller communication and why it is used? Inter-controller is a system solution which two controllers are connected to form one embedded solution entity. In context of IoT, one controller can be used to gather the sensor data while the other acting as gateway to connect to cloud. The sensor data is transferred to the gateway controller via peripheral. Another example is for medical measurement instrument. One controller is again responsible to collect the analog sensor data from patient e.g. breath, pressure, temperature etc while the other controller is responsible for the GUI. I have experiences on both examples and this gives me certain interest and insight on inter-controller architecture.
Of all my projects, mostly it uses UART as peripheral to connect the two controllers and so far it works well. However there is one particular instance which I2C was used and at first this seemed innocence till I was deep on the software implementation. Can you guess what is it? It is something to do with the fact that I2C is a master-slave protocol. Can you now guess it?
To understand it, let's take an example in case of IoT solution in which controller1 is responsible to gather the sensor data while controller2 is responsible to publish the data into the cloud. Let's assume controller1 is the slave while controller2 is the master. So controller1 is collecting the sensor data, probably do preliminary analysis like collecting statistics. When the data is ready, how does controller1 pass it to controller2? Well, it needs to wait for controller2 as the master to retrieve it. This mean, controller1 does not have the communication initiative since it is slave. This forces controller2 to poll the data and this is where it gets ugly from the software architectural perspective.
领英推荐
Would not it be nice if controller1 can initiate communication too? A controller is powerful computation device which can collect and perform deep analysis to discover critical event which need to be immediately feedback to controller2 instead of waiting for the counterpart to poll it.
In conclusion, I think I2C is not the best option as inter-controller peripheral, UART would be a better alternative. In UART, both controllers have the capability to initiate the communication and therefore no need polling. Information can just be passed as it occurred.
I could be wrong and would be glad for discussion.
Software Developer/trading/quant/crypto/golang/Android/C/C++/C#/Python/EagleCAD/PCB design/Mechanical Design/Solidworks/Hardware/Embedded System
2 年why not let controller1 be the master haha, so controller2 can just take data and push to the cloud