-
1. Re: connecting multiple sensors on I2C
user_78878863 Jan 2, 2017 7:43 AM (in response to fa235_1780096)As long as your accelerometer supports assigning different addresses to different devices (usually by pin configuration), you can do this. If not, you need two different I2C ports (which works when your device has two I2C modules)
-
2. Re: connecting multiple sensors on I2C
bob.marlowe Jan 2, 2017 7:52 AM (in response to fa235_1780096)1. when should I use master I2C and when a slave I2C?
Usually a sensor is an I2C slave, so the PSoC will act as master.
Bob
-
3. Re: connecting multiple sensors on I2C
fa235_1780096 Jan 2, 2017 10:54 AM (in response to fa235_1780096)Thank you for replying Hli and Bob. Do you know if there is such an example in PSOC?
@Hli: how do I know that a board has multiple I2C ports such as CYBLE-022001. I searched but failed because i lack the right knowledge. and how do do i know which pins can be assigned to I2C?
@Bob: I would like to use PSOC as master and two accelerometers as slave. Now, do i drop multiple I2C icons on psoc creator workspace and name them slave?
thank you again. apoorva
-
4. Re: connecting multiple sensors on I2C
bob.marlowe Jan 2, 2017 11:30 AM (in response to fa235_1780096)and name them slave? Not name but configure as master. And usually, as hli pointed out, you will need only one I2C component for both slaves. Do not assign pins to the sda and scl lines and build the project, the fitter will assign the correct pins.
Bob
-
5. Re: connecting multiple sensors on I2C
user_78878863 Jan 2, 2017 11:42 AM (in response to fa235_1780096)1 of 1 people found this helpfulLook at the data sheet for your device, it should state that. Or just place a second I2C component and try to compile.
-
6. Re: connecting multiple sensors on I2C
fa235_1780096 Jan 2, 2017 11:45 AM (in response to fa235_1780096)Thank you so much Hli and Bob for your prompt reply. I now try what you suggested.
-
7. Re: connecting multiple sensors on I2C
fa235_1780096 Jan 3, 2017 10:49 PM (in response to fa235_1780096)Hli and Bob. could you please have a look at my project. I added two I2C which thrown an error "two many clocks allocated for SBC" followed another error "maximu number of SBC" exceeded. What will the work around for that?
Thanks,
Apoorva
-
8. Re: connecting multiple sensors on I2C
bob.marlowe Jan 3, 2017 11:54 PM (in response to fa235_1780096)1 of 1 people found this helpfulIn Creator on the very right side is a tab named "Resource meter". This shows that you are trying to use 3 of only 2 available SCBs.
There is no need for 2 I2C masters, you can address up to ~100 slaves. The MPU6050 allows for setting the slave address, so you can address each module individually.
Bob
-
9. Re: connecting multiple sensors on I2C
fa235_1780096 Jan 4, 2017 12:38 AM (in response to fa235_1780096)Thank you Bob, thats very helpful. Could you also point me to an example where an I2C is used for addressing 2 or more slaves. I went through a PSOC document on I2C bus, and I hope I will understand better if I see an example.
-
10. Re: connecting multiple sensors on I2C
bob.marlowe Jan 4, 2017 2:17 AM (in response to fa235_1780096)1 of 1 people found this helpfulThis is too easy for creating an eyample:
The API I2C_MasterWriteBuf(SlaveAddress,DataPtr,Count,I2C_MODE_COMPLETE_XFER); (see I2C datasheet) contains the slave address (which is a value between 1 and 126). Look into the sensor's datasheet for the basic 7-bit address.
Bob
-
11. Re: connecting multiple sensors on I2C
bob.marlowe Jan 4, 2017 2:19 AM (in response to fa235_1780096)1 of 1 people found this helpfulThis is too easy for creating an example:
The API I2C_MasterWriteBuf(SlaveAddress,DataPtr,Count,I2C_MODE_COMPLETE_XFER); (see I2C datasheet) contains the slave address (which is a value between 1 and 126). Look into the sensor's datasheet for the basic 7-bit address.
Bob