November 22, 2024, 02:41:24 AM

Changing I2C address of MOD-IO2

Started by ilario, May 14, 2024, 07:12:59 PM

Previous topic - Next topic

ilario

Dear all,
I recently (approx 6 months ago) bought a few MOD-IO2.
Using only one, I can use the relay just fine :)
But I did not manage to change their I2C address so that I can use more than one.

Currently I have 4 of them connected in a line to a A64-OLinuXino-2Ge8G-IND.

Reading the documentation, seems that closing the PROG jumper has two functions:
  • from user's manual revision E section 5.6.1 "When closed this jumper allows addressing a single MOD-IO2 (the one with the closed jumper) over all others stacked to it – since initially all connected MOD-IO2 boards have the same address."
  • from user's manual revision E section 2.4.2 "Changing I2C device address [...] i2cset 2 0x21 0xHH [...] Note that PROG jumper must be closed to be able to change the address."

But for me it had neither of the two functions (or maybe I misunderstood).
Most importantly, I could not change the I2C address using the i2cset 1 0x21 0x22 command (I tried booting the MOD-IO2 with the jumper set, setting it afterwards and then launching the command, power cycling the MOD-IO2, and it is still at 0x21 regardless of what I do).

In the manual I saw that the address can also be changed with modio2tool, should I use that instead?

Thanks!

LubOlimex

You need to power down the board, close jumper PROG, power up the board then issue the change address command, then power down the board, then open the jumper PROG and finally power and check new address. Are you sure it is on I2C port 1? It can be I2C 0 or 2?

Sure you can try modio2tool, there is explanation on how to compile and use:

https://github.com/OLIMEX/OLINUXINO/tree/master/SOFTWARE/UEXT%20MODULES/MOD-IO2/linux-access-tool
Technical support and documentation manager at Olimex

ilario

#2
QuoteYou need to power down the board, close jumper PROG, power up the board then issue the change address command, then power down the board, then open the jumper PROG and finally power and check new address.

Thanks for the clear instructions!

QuoteAre you sure it is on I2C port 1? It can be I2C 0 or 2?

Yes, using i2cset I can open and close the relay using port 1 (which is UEXT).

Interestingly, I can open and close the relay regardless if the PROG was closed or not (changing the state of PROG jumper, then powering up the MOD-IO2 and then running the i2cset command).

I replicated all of this on two MOD-IO2 boards.

QuoteSure you can try modio2tool, there is explanation on how to compile and use:
https://github.com/OLIMEX/OLINUXINO/tree/master/SOFTWARE/UEXT%20MODULES/MOD-IO2/linux-access-tool

Ok!
I tried to use the precompiled one and it gave an unexpected error:

# chmod a+x ./modio2tool
# ./modio2tool
bash: ./modio2tool: No such file or directory

but then I realized that it was because it was the 32 bit executable and I am on A64-Olinuxino so it is a aarch64 platform so I compiled it with "make" and now it works :)

Before trying with modio2tool, I checked its source, and noticed that it was using an undocumented 0xF0 data address, and that this address was used also in the firmware in the OLIMEX.h file:
#define SET_ADDRESS    0xF0
So I tried to add the data address 0xF0 to the i2cset command, and it worked :D

unplug power
close PROG jumper
plug power
i2cset 1 0x21 0xF0 0x22
unplug power
open PROG jumper
plug power
and now the MOD-IO2 has address 0x22

I double checked that if the PROG jumper is open it does not work, and it does not, as expected.

So I would suggest the following changes in the documentation:

In MOD-IO2 user manual revision E:

page 13, section 2.4.2 replace

i2cset 2 0x21 0xHH
with

i2cset 2 0x21 0xF0 0xHH
page 19, section 5.6.1 remove the whole section. From my tests it does not look like the PROG jumper has that described function.

In the readme of the firmware version 4.3:

page 11, section 4.10 correct as above including 0xF0.

Thanks!




LubOlimex

You are right, looking at the source code that is also published, and more specifically in OLIMEX.h there is list of all commands and corresponding code and at the bottom there is:

#define SET_ADDRESS 0xF0

I will be fixing the manuals, sorry for your troubles but thanks for the effort and contribution.
Technical support and documentation manager at Olimex

ilario

Thank you indeed for releasing everything as open source :D