[HELP] How will this be handled?
Forums:
Dear piBorg community,
I have a couple of questions where I am struggling with.
First of all, I am writing an API for the UltraBorg motorcontroller and I2C in global.
In the linux kernel, it is required to have a I2C address.
The UltraBorg is connected at address 0x36. (See picture)
But the devices that are connected to the UltraBorg does not have their own I2C SLAVE address.
How are we still able to communicate with these slaves?
As far as I can see we need an address to communicate with a device.
https://www.kernel.org/doc/Documentation/i2c/dev-interface
Also, i2c_read_word_data prints out 218 in any case for the UltraBord motorcontroller.
But what does this number means?
I hope someone can clear out some things.
Thanks anyway ;)
piborg
Thu, 04/14/2016 - 11:45
Permalink
UltraBorg I2C communications
I think there is a little bit of confusion here :)
The UltraBorg is at address 0x36 is you have said above.
All of the attached servos and ultrasonic sensors are controlled by talking to the UltraBorg at address 0x36 and sending different commands.
If you find the UltraBorg.h code on this page you can see the various command codes.
https://www.piborg.org/ultraborg/examples#code
The commands all start with
UB_COMMAND_
Further down the page is UltraBorg.cpp, this is the source for an Arduino and is fairly similar to what you need to do.
For example the
UbSetServoPosition1
function changes the position for a servo connected in the #1 slot.The setup ready to talk is quite simple:
The commands themselves are fairly simple, they work by sending the command byte first followed by any data bytes.
For example to set the servo #1 position we can simply use the
write
function like this:Reading we need to use both
write
andread
.For example this would read the first ultrasonic sensor (
UbGetDistance1
):