![]() On your robot, the master will be your controller and the slaves will be our modules such as the SRF08 or CMPS03. It is possible to have multiple masters, but it is unusual and not covered here. ![]() There can be, and usually are, multiple slaves on the I2C bus, however there is normally only one master. A slave cannot initiate a transfer over the I2C bus, only a master can do that. The slaves are the devices that respond to the master. The master is always the device that drives the SCL clock line. The devices on the I2C bus are either masters or slaves. If the resistors are missing, the SCL and SDA lines will always be low - nearly 0 volts - and the I2C bus will not work. I recommend 1k8 as this gives you the best performance. 1k8, 4k7 and 10k are common values, but anything in this range should work OK. I have seen anything from 1k8 (1800 ohms) to 47k (47000 ohms) used. The value of the resistors is not critical. You only need one set of pull-up resistors for the whole I2C bus, not for each device, as illustrated below: There should be a resistor from the SCL line to the 5v line and another from the SDA line to the 5v line. For the line to be able to go high you must provide pull-up resistors to the 5v supply. What this means is that the chip can drive its output low, but it cannot drive it high. Both SCL and SDA lines are "open drain" drivers. There may also be a 5volt wire is power is being distributed to the devices. There needs to be a third wire which is just the ground or 0 volts. The SCL & SDA lines are connected to all devices on the I2C bus. It is used to synchronize all data transfers over the I2C bus. This is just two wires, called SCL and SDA. ![]() This short article therefore tries to de-mystify the I2C bus, I hope it doesn't have the opposite effect! I have lots of examples on using the I2C bus on the website, but many of these are using high level controllers and do not show the detail of what is actually happening on the bus. Judging from my emails, it is quite clear that the I2C bus can be very confusing for the newcomer. ![]()
0 Comments
Leave a Reply. |