How does the Brainboxes.IO API work with IO Lines which are either inputs and outputs?

FAQs

Some of the Brainboxes Ethernet IO Modules have lines which can be either inputs or outputs. (e.g. ED-204, ED-004 and ED-008).

Whether the lines are inputs or outputs is automatically sensed by the Brainboxes hardware depending on how the circuit is wired up to the device.

When using the IO API to read DIO0 (as an input) or set DIO1 (as an output) use the following code:

C#

    using(EDDevice ed = EDDevice.Create("192.168.0.1"))
    {
        // DIO0 is an input
        Console.WriteLine("The value on the line DIO0 is: " + ed.Inputs[0].Value);

        //DIO1 is an output
        Console.WriteLine("Setting Output DIO1 to closed/1/on");
        ed.Outputs[1].Value = 1;
    }

Visual Basic

    Using ed As EDDevice = New ED588(New TCPConnection("192.168.0.158"))
        'Din0 is an input: 1 = high, 0 = low
        Console.WriteLine("Din0 is "& ed.Inputs(0).Value)

        'DIO1 is an output
        Console.WriteLine("Setting Output DIO1 to closed/1/on");
        ed.Outputs(1).Value = 1

    End Using

The API treats the device as if it has 2 separate lines for each DIO line: 1 which is an input and 1 which is an output.

FAQs