Main Site Documentation

Relay X1 Driver


#1

Ellu

I’ve been looking for the Relay X1 Driver and found this info:

The Relay X1 Module was released after the SDK so no Gadgeteer driver or Gadgeteer Designer information is in the SDK. A driver class is included in the Developers’ Guide

but actually, there is no driver class like it says :frowning:
Someone downloaded it before it disappeared?

greez evi


#2

oh… hmmm

is there somewhere a explanation to read how to switch a single pin?


#3

thank you very much


#4

The documentation is very… confusing. it seems they aren’t activating single pins at all… just LED on the board or something >.>

What would be the portID if i want to activate the pin5 on socket 6?

something like this?

Relay = new OutputPort(Cpu.Pin 6.5, true);

I’m a person that totally lives on examples >.<
else I gotta wait till the new sdk is out :confused:


#5

Chokaaay, had to split up the variabe declaration a bit, but it’s working <3

namespace GadgeteerApp1
{
    public partial class Program
    {
        Gadgeteer.Socket socketNr = GT.Socket.GetSocket(6, true, null, "");
        OutputPort relay;

        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            
    
            Debug.Print("Program Started");
            button.ButtonPressed += new GTM.GHIElectronics.Button.ButtonEventHandler(button_ButtonPressed);

            relay = new OutputPort(socketNr.CpuPins[5], false);
            
        }

        void button_ButtonPressed(GTM.GHIElectronics.Button sender, GTM.GHIElectronics.Button.ButtonState state)
        {
            relay.Write(true);
            //throw new NotImplementedException();
        }
    }

How do you ppl figure out in which “format” the numbers and so on must be?
I mean, how you know it must be CpuPins[5] and not Cpu.Pin 5 or anything else?


#6

Indeed the driver was removed from the Doc in preparation for new SDK release, here it is. In order to use it, I suggest a review of http://www.ghielectronics.com/docs/122/gadgeteer-driver-modification

using GTI = Gadgeteer.Interfaces;
using GTM = Gadgeteer.Modules;

namespace Gadgeteer.Modules.GHIElectronics
{
	/// <summary>
	/// A Relay X1 module for Microsoft .NET Gadgeteer
	/// </summary>
	public class Relay_X1 : GTM.Module
	{
		private GTI.DigitalOutput enable;
		private bool state;

		/// <summary>Constructs a new Relay_X1 instance.</summary>
		/// <param name="socketNumber">The socket that this module is plugged in to.</param>
		public Relay_X1(int socketNumber)
		{
			Socket socket = Socket.GetSocket(socketNumber, true, this, null);

			socket.EnsureTypeIsSupported(new char[] { 'X', 'Y' }, this);

			this.enable = new GTI.DigitalOutput(socket, Socket.Pin.Five, false, this);

		}

		/// <summary>
		/// Gets or sets whether the relay is on or off.
		/// </summary>
		public bool Enabled
		{
			get
			{
				return this.state;
			}
			set
			{
				this.enable.Write(value);
				this.state = value;
			}
		}

		/// <summary>
		/// Turns the relay on.
		/// </summary>
		public void TurnOn()
		{
			this.Enabled = true;
		}

		/// <summary>
		/// Turns the relay off.
		/// </summary>
		public void TurnOff()
		{
			this.Enabled = false;
		}
	}
}

#7

Other docs related to pins:

https://www.ghielectronics.com/docs/6/locating-ios

http://www.ghielectronics.com/docs/5/digital-inputs
http://www.ghielectronics.com/docs/7/digital-outputs
http://www.ghielectronics.com/docs/8/analog-inputs
http://www.ghielectronics.com/docs/10/analog-outputs