Through the data bus, an exchange takes place between the master and various electronic devices, according to certain signals supplied by the master to the slaves. Data is transmitted according to a special protocol developed by the manufacturer. The bus has start and stop bits. The bits are intended for the microcontroller to understand what needs to be done on a rising or falling pulse, transmitting or receiving. We study in more detail the principle of operation and the logic of the operation of buses in the course on electronics and circuitry.
I2C (Inter Integrated Circuit) is a simple bidirectional data exchange bus. It has two wires. Developed by Philips in the 80s. Widely used in integrated circuits. The bus is designed as a simple signal bus.
The wires have the following names:
Devices connected to the bus are attached to each of the wires. The main one is the MASTER (master unit). It generates clock signals, the beginning and end of the transfer on the data bus. Thus, impulses come from it, and data can pass in both directions.
Data can be generated by both MASTER and other “slave” devices:
All listed devices are connected to the bus in parallel. On one electronic board, there can be a large number of slave devices. The bus standard has an address. 7 bits are allocated, that is, two to the seventh power, and means the number of devices of the order of 100.
Frequencies on the bus f = 100 – 10 kbps. Therefore, it is low speed. The total capacitance on the bus must not exceed 400 pF (which is the sum of all devices connected to it). The bus power can be:
The signal lines are pulled up to the power supply through resistors, the resistance of which is from 5 to 10 kOhm. This is important because it changes the parasitic capacitance, which in turn affects the number of SLAVEs and the speed of information transfer. The length of the bus can reach several meters.
Data transfer algorithm:
This means that the MASTER wants to exchange information with the “slave” devices and issues the “ATTENTION” command. During the transition:
It is important to remember that the SCL signal can only be generated by the MASTER. The entire transmission is transmitted in bytes. Bytes are transmitted bit by bit, starting with the most significant bit. In response to each received byte, the receiver exposes either an acknowledgment or a refusal.
Advantages of the I2C bus:
Disadvantages of the I2C bus:
SPI (Serial Peripheral Interface) is a four-wire interface used in circuits with microcontrollers. Provides synchronous duplex data exchange. SPI works on the principle of a shift register. Registers are in different devices. One of them is MASTER. It can be a microcontroller with a clock generator that has a specific program.
Another device could be:
The INPUT and OUTPUT signals are used to exchange information between the master and devices. The name of the tires was formed from the abbreviated words for devices and signals:
The main signal on this bus is SLK (CLOCK).
When the microcontroller works with several devices, additional signals will be needed to select the appropriate device with which to exchange. In this case, a sample signal – SS (Slave Select) is required. If there are N devices, then the number of outputs from MASTER increases. In this case, the signals coming from MASTER are paralleled.
In this case, when SS is received on one output, data is transferred only from the necessary device selected by the master for exchange. In order for the devices not to interfere with each other’s work during the exchange, strobe occurs, which is carried out by the SS signal for each device.
Advantages of the SPI bus:
Disadvantages of the SPI bus – lack of control. For example, an open MISO or MOSI bus is superimposed using software tools.
The USB bus (Universal Serial Bus) is the most common way to connect external devices to the motherboard of a TV, laptop and other devices. This bus was developed in 1996, and has been widely used since 2000, with the advent of the first Flash.
At the moment, the bus has three standards that differ in data transfer speed:
The USB bus is asymmetric and works like a MASTER-SLAVE. The bus drivers are different. One of them is Downstream – controls the behavior of the data bus from the device.
The device bus consists of four conductors, which are signal wires wrapped in a protective earth. Wires come with standard color marking: red, white, green, black. The supply voltage – 5V – is transmitted through the red and black wires. And it is designed for a current of 100 mA for one device. Up to 5 external devices can be connected to one device, respectively up to 500 mA.
The device connection diagram is as follows:
Differential signal transmission is carried out on the white and green wires. The transmission is controlled by encoder control transmitters, according to the appropriate signals.
The second driver is Upstream. Located on the side of the receiver, controlled by the encoder for data transmission, similar to Downstream.
The bus connectors look like this:
The CAN bus is designed for automotive applications. This one consists of two wires in the form of a twisted pair, closed with 120 ohm resistors. Since the wave impedance of the bus is 120 ohms. In this regard, there are no reflective signals on it, which is a great advantage in terms of noise immunity.
Any number of transceivers can be connected to the bus. from which signals are generated. If no signals are coming to the bus, the voltage on both wires is 2.5V. When a signal is received, a voltage difference is formed, and on one of the wires (high level), the voltage rises to 3.5V. And on the second wire (low level), the voltage drops to 1.5V.
Thus, a voltage of 2.0V is formed between the wires, which is recorded by all devices as an incoming signal. If there is 2.0V between the wires, then there is a signal. If there is no such difference, then there is no signal. Therefore, if there is a signal, then the level is active. This means that there is a logical 0 at the input of the transceiver. And if there is a logical unit at the input of the transceiver, this means there is no signal. Zero is formed if there is a signal on the high-level wire.
An important property of the line is noise immunity, since it is made in the form of a twisted pair, and if there is pickup from the operation of devices, then they come in phase. And these pickups do not change the difference. Since the receiver responds to the difference, the pickup on the bus wires is the same, and the pickup voltage difference will be zero. What does not affect the useful signal.
CAN bus can be up to 1000 meters long. The limitation is the data transfer rate:
Currently, there are various CAN bus transceivers. Controllers with this bus are also available.