Let’s start with the basics, in our program we will have one circuit object per each physical circuit installed, which can be a shutter, a lighting circuit, any circuit type. When we interact with our program, we can read and write that circuit information, values such as circuit status, type, output value, all information about that circuit.

All circuit objects are stored inside an array, if you don’t know what is an array or basic types of programming, this document is a must read:

http://playground.arduino.cc/ArduinoNotebookTraduccion/Datatypes

The array circuits store all of our installation circuits, let’s go with a practical example, imagine that we setup 2 circuits, one standard lighting and one standard irrigation, so our array circuits will have 2 circuits.
To enable standard irrigation, the first one in array we do this:

circuits[0].Value=1;

 

 

As you can see the index points to the circuit number, beginning from 0, if we want to enable the second circuit we just have to write this code:

 

circuits[1].Value=1;

 

 

Basically we can say that the array is a collection of objects (which can be of any type, in this case they are circuit), so when we want to see or modify a circuit status in our installation we have to point to the correct index in our circuits array, the order of the circuits is represented in control applications.

 

The circuit object:

The circuit object has all information about a circuit, is structured, let’s analyze more important properties:

struct Circuit {byte Type;boolean Out1_Value;boolean Out2_Value;byte Device_Number;byte Value;byte CopyRef; byte OldValue;};

 

Value:

The most important property of circuit object, shows or modifies the circuit state, for digital circuits it only has two values, 0 OFF and >0 ON, let’s go with some examples (replace c by the circuit number):

In a Shutter circuit, value is the degree of openness in a range from 0 to 100. So if we want to set the Shutter in the middle we have to write the following sentence.

circuits[c].Value=50;

 

To switch on a digital circuit:

circuits[c].Value=1;

 

To switch off a digital circuit:

circuits[c].Value=0;

 

To start a timed irrigation for 12 minutes:

circuits[c].Value=12;

 

Type:

Provide the type of circuit. Until today We have the following types available That can be extended by the user to fill it’s needs:

Ado_Digital: (digital lighting). Lighting with values ON / OFF.

Ado_3Etapas: (lighting 3 steps). Lighting control in 3 steps, 33%, 66%, 100%.

RGB: (RGB). led RGB leds control.

Dimmer: (Dimmer).

Enchufe: (plug). Standard wired plug.

Riego: (irrigation). Digital irrigation, it can be programmable, but it´s states can be ON/OFF

Riego_Temporizado: (timed irrigation). In this case it state the value property it’s the time that the circuit will be on.

Persiana: (Shutter) Controls a shutter

Toldo: (awning) Controls an awning.

ConsignaTemp: It’s a temperature setpoint to function as a thermostat, it is associated with a temperature sensor.

Frio: (cold) control zone cold for air conditioning, it is associated with a temperature sensor.

Calor: (hot) control zone hot for air conditioning for heating, it is associated with a temperature sensor.

Radiante: (heating floor) control zone hot for air conditioning for heating, it is associated with a temperature sensor.

Puerta: (door) control automatic door.

Valvula: (valve) control fluids.

Ventilador x1 : (fanx1) 1 speed fan.

Ventilador x2 : (fanx2) 2 speed fan.

Ventilador x3: (fanx3) 3 speed fan.

Piloto: (pilot) circuit with a generic icon in the app, can be used for what ever you want.

Temporizador: (Timer). Minute timer.

Let´s see a practical example, imagine you want to raise all installation shutters, we can use the following code:

for (int c=0;c<Number_Circuit;c++){//Con el bucle recorremos todo el array
// The loop roams all the array.
// The property value of shutters it's the degree of openness thereof.
if (circuits[c].Type==Persiana){circuits[c].Value=100;}

 

Out1_Value:

output value, it’s the one sent to the relay to activate or deactivate, generally it is read only, unless we configure our own circuit types.

So to know the relay’s output value associated with our first installation circuit, we would write the following code:

if (circuits[0].Out1_Value==false){

//This part of the condition indicates it is OFF
}

else{

// This part of the condition indicates it is ON

 

Out2_Value:

Second output value. Most circuits don’t use it, only some like “Ado_3Etapas”. It’s operation is the same as the previous one.

Device_Number:

is the device number, this is a read only property, for example, If we have three shutters in our installation, the first one would have 0 value for this property, the second 1 and the third 2.

Written by Pablo Abella.

Alias Pableras.