relayISOx16

Hello again Folks
I feel really bad to post here again :confused:

I was pretty sure to get that working without any help… but it seems not :S

After I got the Button and Joystick to work i gave a try to the RelayISOx16 Module.
The implementation was pretty easy and i found also it’s methods to use… but somehow is nothing happening when I enable a Relay.

            button.ButtonPressed += new GTM.GHIElectronics.Button.ButtonEventHandler(button_ButtonPressed);
        }

        void button_ButtonPressed(GTM.GHIElectronics.Button sender, GTM.GHIElectronics.Button.ButtonState state)
        {
            relayISOx16.EnableRelay(5);
            throw new NotImplementedException();
        }

it looks as simple as it should be…
Did I do something wrong?
I couldn’t find any code on the Seed site or the Sharecode page :S
Someone a small tipp?

I use a FEZ Hydra

thx in advance.
greez evi

Are you sure it’s not working?
This line needs to be removed as its just making the hydra throw an exception which will just confuse things.


 throw new NotImplementedException();

Do you have anything connected to relay 5 to prove its working or not? If you can add pics that’s always a help for us to see.

No camera to hand. I have a Multimeter to check if it switched.
But the Module itself has LEDs on it.

When I give the 12V to the RelayModule all LEDs are red and none of the connections on the relays is active… the opener neither the closer.

When I plug the Hydra all Relays are ready in the opener position. the multimeter comfirms that.
When i activate the button i get into the button methode and i get also my debug.print…
I also tried it with DisableRelay(); just to be sure…
is it correct to have just a number as argument? this “ushort relay” is a bit confusing…
cuz it doesn’t accept an variable like int RelayNr = 1; Edit: ok… it’s not working cuz of the datatype^^

relayISOx16.EnableRelay(RelayNr);

 Debug.Print("Program Started");

            button.ButtonPressed += new GTM.GHIElectronics.Button.ButtonEventHandler(button_ButtonPressed);
        }

        void button_ButtonPressed(GTM.GHIElectronics.Button sender, GTM.GHIElectronics.Button.ButtonState state)
        {
            relayISOx16.EnableRelay(5);
            Debug.Print("Enabled!");
            //throw new NotImplementedException();
        }

Relays are defined as a bitmask. So they go like this:
Relay1 = 1
Relay2 = 2
Relay3 = 4
Relay4 = 8 etc.
Now you just sum the numbers of relays you want to enable. For example: 5 will enable Relay1 & Relay3.

You don’t have to input numbers directly you can use constants defined in RelayISOx16.Relay:
RelayISOx16.Relay.Relay_1
RelayISOx16.Relay.Relay_2
RelayISOx16.Relay.Relay_3 etc.
and to enable Relay1 & 3 this way you need to use boolean OR like this: .EnableRelay(RelayISOx16.Relay.Relay_1 | RelayISOx16.Relay.Relay_3);

1 Like

hmm, it would look so simple…

 Debug.Print("Program Started");

            button.ButtonPressed += new GTM.GHIElectronics.Button.ButtonEventHandler(button_ButtonPressed);
        }

        void button_ButtonPressed(GTM.GHIElectronics.Button sender, GTM.GHIElectronics.Button.ButtonState state)
        {
            relayISOx16.EnableRelay([em]RelayISOx16[/em].Relay.Relay_1);
            Debug.Print("Enabled!");
            //throw new NotImplementedException();
        }

RelayISOx16 is unknown in this context. i also tried small letters… then it says “Error 1 “Relay”: On a Type can not be referenced by an expression. Instead, use “Gadgeteer.Modules.GHIElectronics.RelayISOx16.Relay”.”

Replacing Relay with “Gadgeteer.Modules.GHIElectronics.RelayISOx16.Relay” didn’t help either

argh… :confused:

chokay, no error by

relayISOx16.EnableRelay(Gadgeteer.Modules.GHIElectronics.RelayISOx16.Relay.Relay_1);

but still no activation on the physical relay >.<

   Debug.Print("Program Started");
            relayISOx16.DisableAllRelays();
           
            button.ButtonPressed += new GTM.GHIElectronics.Button.ButtonEventHandler(button_ButtonPressed);
        }

        void button_ButtonPressed(GTM.GHIElectronics.Button sender, GTM.GHIElectronics.Button.ButtonState state)
        {
            
            relayISOx16.EnableRelay(Gadgeteer.Modules.GHIElectronics.RelayISOx16.Relay.Relay_1);
            Debug.Print("Enabled!");
            //throw new NotImplementedException();
        }

Choaaaaay. The last posted CODE is WORKING!!!

I bumped via google into a older thread… it has no question about the code in it so i probably skipped it before.

But I found out that the Relay Module only works on socket 3 and 4 ^^

https://www.ghielectronics.com/community/forum/topic?id=9972

Thank you very much to complete the code.

greez evi

The problem with only working on sockets 3 and 4 was specifically related to the Gadgeteer Designer part of Visual Studio. Additionally that bug is fixed in the latest/current SDK.