Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Use Of Interfaces

Status
Not open for further replies.
i am confused over when to use interfaces like i2c..so i am giving you a small example ..please explain it to me on the basis of it..

suppose i am making a line follower(a bot which is programmed to follow a black line) . i m using 4 sensors whose output would be connected to 4 comparators giving digital 0s and 1s depending on input voltage. now these 4 comparators are connected to the microcontroller which works according to the combination of these digital inputs.
1) do we require i2c between sensor and comparator.
2) do we require i2c between comparators and microcontroller.(and how do we make sure that all the 4 output data of comparators reach microcontroller at the same time)

if none of these require the use of i2c than please explain when it is used...
 
i am confused over when to use interfaces like i2c..so i am giving you a small example ..please explain it to me on the basis of it..

suppose i am making a line follower(a bot which is programmed to follow a black line) . i m using 4 sensors whose output would be connected to 4 comparators giving digital 0s and 1s depending on input voltage. now these 4 comparators are connected to the microcontroller which works according to the combination of these digital inputs.
1) do we require i2c between sensor and comparator.
2) do we require i2c between comparators and microcontroller.(and how do we make sure that all the 4 output data of comparators reach microcontroller at the same time)

if none of these require the use of i2c than please explain when it is used...

hi,
For the 4 sensors/comparator outputs which are '0 or 1', use 4 input pins on a PIC PORT.
If the external comparators just have a '0 or 1' depending upon the light seen by the sensor, they are not I2C compatible.

Do you follow.?
 
i am confused over when to use interfaces like i2c..so i am giving you a small example ..please explain it to me on the basis of it..

suppose i am making a line follower(a bot which is programmed to follow a black line) . i m using 4 sensors whose output would be connected to 4 comparators giving digital 0s and 1s depending on input voltage. now these 4 comparators are connected to the microcontroller which works according to the combination of these digital inputs.
1) do we require i2c between sensor and comparator.
2) do we require i2c between comparators and microcontroller.(and how do we make sure that all the 4 output data of comparators reach microcontroller at the same time)

if none of these require the use of i2c than please explain when it is used...

1. sensor has analog output and it "does not know how to speak i2c" unless it is special type of sensor (for e.g. AD convertor like PCF8591 but then you will not connect it to comparator)
2. NO, as you wrote, your comparators are returning 0 or 1 so you connect them to digital input of your uC , your 4 comparators are connected to 4 different digital inputs that you can read "in the same time"

i2c is used for communication between 2 devices. it is one of the protocols that can be used for that purpose. for example, if you are communicating with other i2c device (for e.g. port extender or i2c eeprom or i2c lcd driver or ...) then you use i2c protocol to communicate between your uC and the "device" that support that protocol ... different devices support different protocols, for example if you are to communicate with PCF8591 (AD/DA converter) you need to use i2c protocol, or if you use DS1307 real time clock you need to "ask for time" using i2c protocol, on other hand if you want to check temperature from DS1820 you need to use 1wire protocol, or if you DS1305 to check the time you need to use SPI protocol ...

All this different protocols are different, some use 1 some 2 some 3, 4 or more lines, some are differential, other digital, some work only on short distances (i2c) some work on long distances (CAN), some are relativly slow (1wire, i2c) other can be quite fast (SPI) ... in general, you choose protocol based on all this parameters (speed, distance, noise resistance, type of devices you want to connect)

I hope this gives you some perspective.. search a forum, you will find quite a lot about i2c and other protocols
 
Status
Not open for further replies.

Latest threads

Back
Top