I am currently using a custom arduino (though it's practically a UNO), and I am currently controlling a IC2 pwm controller using SDA/SCL, and I want to add a LED screen for debugging and information purposes, however, it too requires SDA and SCL connections.
I haven't messed around with adresses much, I guess this is what it's for?
Do I just split the output with paralell connections, hook up the display, and it should work as long as it has a unique address? Anything else I need to keep in mind? Caps for noise reduction or something like that?
It's a bus so you can add what you like in parallel. The main thing is to avoid address clashes. If each device has its own pull up resistors, eventually the effective resistance may be too low. But 2 or 3 devices is normally no problem.
Cheers! Both of my devices are already set to their own addresses, but I am not seeing them being defined any way in the example codes I have based my sketch on. I believe the IC2 library just happens to default to the same address as the device it's made for, but I don't think the LED screen would be, as it's a generic graphics library (u8glib). But it is displaying printed messages at the moment.
Each device work fine on their own already. But what I for instance wanted to add a second screen with it's own address? How would one make sure they get their own signal in software?
All I am doing at the moment is using a graphics library to draw and print text. I haven't set any addresses anywhere.
The real limitation you are going to run into is the length of the I2C bus. I've had problems with wires as short as 10cm. If you are lucky, you might get a meter.
Also keep an eye on the total pullup load on the bus.
If there are supported displays that may take more than one address (in some controllers the address is fixed - you cannot have two such displays on the same I2C bus), the library will provide a way to specify the address. Consult the documentation for the library - how this is specified depends on the library; often it's passed in the constructor, maybe as an optional argument.
DrAzzy:
If there are supported displays that may take more than one address (in some controllers the address is fixed - you cannot have two such displays on the same I2C bus), the library will provide a way to specify the address. Consult the documentation for the library - how this is specified depends on the library; often it's passed in the constructor, maybe as an optional argument.
I see, I see. There's probably a function or variable I can use to re-set them then that I haven't found so far. The IC2 can be chained with 32 of the same unit with different adresses, so I guess there's just hidden functionality that sets defaults somewhere in the library or initialization functions.
Grumpy_Mike:
That is because you do not know what those sketches are doing. Post one using code tags, and we can point out to you where the address is defined.
Their is not enough memory in an Arduino to run two OLED displays of 128 by 64.
I wrote the sketch I am using myself, just used examples for syntaxes and refernces to how to use the various functions and variables.
However, setting any addresses is not apparent within what I write myself. So I assume it would be set from the library itself? I am not new to OOR programming, but I haven't experienced how libraries work yet.
There's probably a function or variable I can use to re-set them then that I haven't found so far.
No, the address can only be changes, if it can be changed at all, by changing the logic level of one or more pins on the device.
The IC2 can be chained with 32 of the same unit with different adresses
No, you can access 128 devices if they have different addresses.
I wrote the sketch I am using myself, just used examples for syntaxes and refernces to how to use the various functions and variables.
If you want to know where the address is set then post your code. Don’t ask a question if you don’t want to cooperate in helping to find an answer.
The address or addresses of any I2C device will be found in the data sheet of that device.
If device’s have the same address or you want to use more than one device with a fixed address there are things you can do to get round this. But talking without mentioning specific devices is just arm waving.
BabyGeezer:
from what i understand of I2C, you only need ONE set of pull-up resistors for the whole bus, not one EACH per device.
It depends.
If all the devices are very close to the Arduino, then yes.
If long wires are uses (several meters), then it could be better to also use resistors at the end of the wire.
What matters is to stay within the I2C current specs (3mA for standard I2C, 30mA for FM+).
That works out to a combined minimum of ~1k66 for a 5volt Arduino and standard I2C devices.
Leo..
Wawa:
It depends.
If all the devices are very close to the Arduino, then yes.
If long wires are uses (several meters), then it could be better to also use resistors at the end of the wire.
What matters is to stay within the I2C current specs (3mA for standard I2C, 30mA for FM+).
That works out to a combined minimum of ~1k66 for a 5volt Arduino and standard I2C devices.
Leo..
i see - i guess i have to learn the fundamentals of how 'buses' work then.
Grumpy_Mike:
No, you can access 128 devices if they have different addresses.
Sorry, the device I was talking about is literally set up to have 32 unique potential addresses in hardware.
Grumpy_Mike:
If you want to know where the address is set then post your code. Don’t ask a question if you don’t want to cooperate in helping to find an answer.
I'm not refusing, there's literally no relevant code for me to post, which is why I am asking if it's possible that when you set the library and intialize it, it could set some default directly from there, since libraries is the only thing I'm unsure about.
I've done everything from scratch so far so I haven't needed libraries, and my previous programming experience in other fields hasn't had something like libraries. Is it similar to a parent/chiild class in object oriented programming, except there's no hierarchy? Or is it more like a casting a new class instance from within your current class, so that you have access to the instance's functionality?
All in all, do libraries inherently define and give values to variables and functions, without you calling them directly in your own sketch? Put hardware aside.
That's all I really need answered.
there's literally no relevant code for me to post,
Yes their is, it is the code you wrote that used a device on the I2C bus, but which you did not specifically use an I2C address. I want to see what you put and what libraries you used. Then I can see where the address came from.
do libraries inherently define and give values to variables and functions, without you calling them directly in your own sketch?
No.
When you have a libiary you must call one or more of its methods. It could be that the address is passed back to your program and you use that, or it could be that all address are contained in the libiary and you call some methods that use that address.