[RESOLVED] RELAY16 - Failed to send I2C data

Hello world,
I connected ZX-RELAY16 to Panda II, some time it not works fine.
I found the problem:

the folow statement (into FEZ_Components_Realy16.cs) I2C.Execute(…) some times is equal to 0, so throws a new Exception. If, in debug mode, I reexecute the statement, it works fine.


if (I2C.Execute(xaction, 100) == 0)
{
      new Exception("Failed to send I2C data");
}


I try to changed the source by follow code:


int result = 0;
int fault = 10;
do
{
      result = I2C.Execute(xaction, 100);
      fault--;
}
while (result == 2 && fault > 0);
if (fault < 0)
{
      new Exception("Failed to send I2C data");
}


this solves 90% of cases in the remaining 10% of the card has unexpected behavior.

Any idea?

Thanks.

I haven’t seen this before! The relay board is plugged into FEZ Connect?

Hello.
Yes, the board is correctly connected on FEZ Connect Shield (SDA+SCL). I bought “FEZ Ultimate Kit”.

Thanks

I don’t have this relay board, so can’t test anything for you. But you only mention SDA and SCL, at a minimum you would need GND as well; do you have that?

Electrically, a relay is often used to switch power supply to devices, and more often than not the power is from a different power source. Different power sources can often interfere with each other. I see the INEX board uses 12v, but I can’t find an english connection diagram that shows whether the control IC on the relay board is powered from the 12v or if it is only from the uC connection - can you tell us what the “three pin connector” on the board shows?

What I was hoping was to find a way to test this completely disconnected from any of the things you want to switch, and just with the Fez connected, to eliminate the 12v supply as an issue. But that may not be possible with this.

My initial bet is GND though - tell us what you did there.

thank you for your idea.
I used the 3-pin cable for SDA and SCL (provided).

For GND there isn’t a terminal, so I tried to connect their both negative poles. Failed.
I tried to use 9V FEZ alimentation to reduce the gap between FEZ and RELAY16. Failed.
I tried to use other FEZ (Ultimate Kit) if was a FEZ problem. Failed.

I think that my board is crazy. It’s so easy to use that is impossible have a mistake. To be sure I should buy other board and try.

what is the third pin marked? Anything?? I can’t find a good picture of the board to see any detail, if you have any pointers that might help that would be good too. A data sheet would help !!

Lets take a step back for a moment.

Have you gone through the basics, made your LED flash, used the pushbuttons etc, with the Fez Ultimate kit? That way we know that your Fez is working. I’ll ask the other question, did you make sure you did the firmware update when you first got your Fez and installed the GHI SDK? Do you have any other I2C device that you can prove you have I2C working as expected?

I started with examples: led, button, thermometer, LCD …
I tried RELAY16 with online example, some time it works, some time it does not.

I’m sure that FEZ working with lastest firmware, but I have not other I2C device.
I have 2 identical FEZ, I can try connect them by I2C terminal, but I don’t know how test the comunication.

I found an error in my previous code, follow the correct version:


int result = 0;
int fault = 10;
do
{
    result = I2C.Execute(xaction, 100);
    fault--;
}
while (result != 2 && fault > 0);
if (fault < 0)
{
    new Exception("Failed to send I2C data");
}


it work better, but not always good :’(
does anyone know what it means 1 from “I2C.Execute(…)” called?

thanks

@ thinkIT
Please use the “code” tag when posting in the forum to make the code more readable.

ok, so now I understand the wiring a bit more. Looks good, the fact that you have VCC and GND in each of the 3-pin JST connectors means ground planes are sorted.

The next thing is “working sometimes”. This seems to be the key to your problem. That typically means it’s not code, its electronics. My personal thought is the 16-port relay is not working as expected and has some fault. I2C is pretty reliable.

You can see what the return code should be from the I2C documentation on the web: [url]Microsoft Learn: Build skills that open doors in your career. it’s the number of bytes transferred.

I had exactly the same problem. To solve this set up a little lower clockrate, for me save is 80:


I2C = new I2CDevice(new I2CDevice.Configuration(0x20, 80));

Hope it helps.

result of I2C.Execute is how many bytes where sent.

Jack

Hi Jack, it works!!! ;D

Thank you a lot!