Click or drag to resize

I/O system domain

Overview

A robot system uses input and output signals to control processes. Signals can be of digital, analog or group signal type. Such I/O signals are accessible using the SDK.

Signal changes in the robot system are often significant, and there are many scenarios where end-users of the system need notification of signal changes.

Accessing signals

Accessing signals is done through the Controller object and its propertyIOSystem, which represents the I/O signal space in the robot controller.

To access a signal you need the system name of the signal. The object that is returned from the IOSystem.GetSignal method is of type Signal.

C#
Signal signal1 = aController.IOSystem.GetSignal("signal name");
VB
Dim Signal1 As Signal = AController.IOSystem.GetSignal("signal name")

The returned Signal object has to be typecast to digital, analog or group signal. The following example shows a how a signal of type DigitalSignal is created:

C#
DigitalSignal diSig = (DigitalSignal) signal1;
VB
Dim DISig As DigitalSignal = DirectCast(Signal1, DigitalSignal)

The following example shows a how an AnalogSignal is created:

C#
AnalogSignal aiSig = (AnalogSignal) signal1;
VB
Dim AISig As AnalogSignal = DirectCast(Signal1, AnalogSignal)

The following example shows a how a GroupSignal is created:

C#
GroupSignal giSig = (GroupSignal) signal1;
VB
Dim GISig As GroupSignal = DirectCast(Signal1, GroupSignal)
Note Note

Remember to call the Dispose method of the signal when it should no longer be used.

Getting signals using SignalFilter

Instead of getting one signal at a time you can use a filter and get a signal collection. Some of the SignalFilter flags are mutually exclusive, for example SignalFilter.Analog and SignalFilter.Digital. Others are inclusive, for example SignalFilter.Digital and SignalFilter.Input. You can combine the filter flags using the “|” character in C# and the Or operator in VB:

C#
IOFilterTypes aSigFilter = IOFilterTypes.Digital | IOFilterTypes.Input;
SignalCollection signals = controller.IOSystem.GetSignals(aSigFilter);
VB
Dim aSigFilter As IOFilterTypes = IOFilterTypes.Digital Or IOFilterTypes.Input
Dim signals As SignalCollection = controller.IOSystem.GetSignals(aSigFilter)

This piece of code iterates the signal collection and adds all signals to a ListView control. The list has three columns displaying signal name, type and value:

C#
foreach(Signal signal in signals)
{
item = new ListViewItem(signal.Name);
item.SubItems.Add(signal.Type.ToString());
item.SubItems.Add(signal.Value.ToString());
this.listView1.Items.Add(item);
}
VB
For Each signal As Signal In Signals
Item = New ListViewItem(signal.Name)
Item.SubItems.Add(signal.Type.ToString())
Item.SubItems.Add(signal.Value.ToString())
Me.ListView1.Items.Add(Item)
Next

If the signal objects are no longer needed they should be disposed of:

C#
foreach(Signal signal in signals)
{
signal.Dispose();
}
VB
For Each signal As Signal In Signals
signal.Dispose()
Next
Reading I/O signal values

These examples show how to read a digital and an analog signal.

Digital signal

This piece of code reads the digital signal DO1 and checks a checkbox if the signal value is 1 (ON):

C#
Signal sig = aController.IOSystem.GetSignal("DO1");
DigitalSignal digitalSig = (DigitalSignal)sig;
int val = digitalSig.Get();
if (val == 1)
{
this.checkBox1.Checked = true;
}
VB
Dim sig As Signal = aController.IOSystem.GetSignal("DO1")
Dim digitalSig As DigitalSignal = DirectCast(sig, DigitalSignal)
Dim val As Integer = digitalSig.Get
If val = 1 Then
Me.CheckBox1.Checked = True
EndIf
Analog signal

This piece of code reads the value of the analog signal AO1 and displays it in a textbox:

C#
Signal sig = aController.IOSystem.GetSignal("AO1");
AnalogSignal analogSig = (AnalogSignal)sig;
float analogSigVal = analogSig.Value;
this.textBox1.Text = analogSigVal.ToString();
VB
Dim sig As Signal = aController.IOSystem.GetSignal("AO1")
Dim analogSig As AnalogSignal = DirectCast(sig, AnalogSignal)
Dim analogSigVal As Single = analogSig.Value
Me.textBox1.Text = analogSigVal.ToString()
Writing I/O signal values

In the following example, new values for the I/O signals that were retrieved in the previous example are written to the controller.

Note Note

In manual mode a signal value can be modified only if the Access Level of the signal is ALL . If not, the controller has to be in auto mode.

Digital signal

This piece of code changes the value of a digital signal in the controller when you check/uncheck a checkbox:

C#
private void checkBox1_Click(object sender, EventArgs e)
{
if (this.checkBox1.Checked)
{
digitalSig.Set();
}
else
{
digitalSig.Reset();
}
}
VB
Private Sub checkBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles checkBox1.Click
If Me.checkBox1.Checked Then
digitalSig.[Set]()
Else
digitalSig.Reset()
End If
End Sub

Note Note
You can also set the value using the Value property.

Analog signal

This piece of code writes the value entered in a text box to the analog signal AO1. The value is converted from string to a float before it is written to the controller:

C#
float analogSigVal = Convert.ToSingle(this.textBox1.Text);
analogSig.Value = analogSigVal;
VB
Dim analogSigVal As Single = Convert.ToSingle(Me.textBox1.Text)
analogSig.Value = analogSigVal
Listening to signal changes

Once a Signal object is available it is possible to add a subscription to its Changed event, which is triggered at a signal change such as changed value, changed simulated status or changed signal quality.

C#
this.aiSig.Changed +=new SignalChangeHandler(aiSig_Changed);
VB
 Friend WithEvents aiSig As AnalogSignal
...
 AddHandler aiSig.Changed, AddressOf aiSig_Changed
...
 Private Sub aiSig_Changed(sender As Object, e As SignalChangeEventArgs) Handles aiSig.Changed
 End Sub
Note Note
The event handler skeleton is auto generated using the Tab key twice after “+=” in the preceding statement:
private void aiSig_Changed(object sender, SignalChangeEventArgs e)
{ }
Start and stop subscriptions

It is recommended that you activate and deactivate subscriptions to the Changed event if these are not necessary throughout the lifetime of the application:

C#
this.aiSig.Changed += new SignalChangeHandler(aiSig_Changed);
this.aiSig.Changed -= new SignalChangeHandler(aiSig_Changed);
VB
AddHandler aiSig.Changed, AddressOf aiSig_Changed
RemoveHandler aiSig.Changed, AddressOf aiSig_Changed
Avoiding threading conflicts

The controller events use their own threads, which are different from the application GUI thread. This can cause problems if you want to display signal changes in the application GUI.

If an update of the user interface is not necessary, you do not need to take any special action, but can execute the event handler on the event thread. If, however, you need to show to the user that the signal has changed you should use the Invoke method. It forces execution to the window control thread and thus provides a solution to potential threading conflicts.

C#
this.Invoke(new ABB.Robotics.Controllers.IOSystemDomain. SignalChangedEventHandler(this.UpdateUI), new Object[] {sender, e});
VB
Me.Invoke(New ABB.Robotics.Controllers.IOSystemDomain. SignalChangedEventHandler(AddressOf UpdateUI), New Object() {sender, e})

For more information, see Controller events and threads.

Finding out the new value

The SignalChangedEventArgs object has a NewSignalState property, which has information about signal value, signal quality and whether the signal is simulated or not:

C#
private void UpdateUI(object sender, SignalChangedEventArgs e)
{
SignalState state = e.NewSignalState;
....
float val = state.Value
this.textBox1.Text = val.ToString()
}
VB
Private Sub UpdateUI(ByVal Sender As Object, ByVal e As SignalChangedEventArgs)
Dim State As SignalState = e.NewSignalState
Dim val As Single
Val = State.Value
Me.TextBox1.Text = Val.ToString()
....
End Sub
Note Note

Do not count on receiving an initial event when setting up the subscription. To get initial information about the value of a signal, you should read it using the Value property.

Note Note

Make sure the subscription is removed before you dispose of the signal.