IoDigitalValue
This parameter is used to set the output values represented by the digital Pins available on a device, as a bit mask value. Unlike
IoDigitalSet and
IoDigitalClear, this operation applies to all Pins, i.e., each available Pin
is set to one of the two possible states.
The bit mask allows setting the value of 32 Pins, though, at the time of writing this documentation only PCAN-Chip USB based devices, with a firmware version
equal to or greater than 3.3.0, support the configuration of a maximum of 5 digital Pins. For this reason,
all other (not used) bits are automatically discarded from the bit mask value.
No error is generated by setting a bit for a nonexistent Pin.
It is available since PCAN-Basic version 4.3.0.
This parameter is read/write. It can be configured and retrieved.
This parameter has a resolution of a double-word (range [0...MaxValue]).
It is a bit mask, in which every bit represents the value for a digital output Pin. Bit0, the least significant bit, corresponds
to the value of Pin0; Bit1 corresponds to the value of Pin1, and so on until Pin31.
Bit value | Description |
|---|
0
|
The digital pin value is “low”.
|
1
|
The digital pin value is “high”.
|
The default value for each Pin (and for the whole mask) is 0, meaning that the values of all digital output Pins are set to “low”.
Get: The PCAN Channel must be initialized before using this parameter.
Set: The PCAN Channel must be initialized before using this parameter.
The following code shows how to set the value of all digital outputs of a USB Channel:
PcanChannel channelUsed = PcanChannel.Usb01;
if (Api.Initialize(channelUsed, Bitrate.Pcan500) == PcanStatus.OK)
{
uint pinMask = 0x11;
if (Api.SetValue(channelUsed, PcanParameter.IoDigitalValue, pinMask) == PcanStatus.OK)
{
Console.WriteLine($"Pin0 and Pin4 of {channelUsed} were successfully set to 'high'.");
Console.WriteLine($"Pin1, Pin2, and Pin3 of {channelUsed} were successfully set to 'low'. ");
}
else
Console.WriteLine($"Error configuring digital Pin states for {channelUsed}.");
Api.Uninitialize(channelUsed);
}
Dim channelUsed As PcanChannel = PcanChannel.Usb01
If Api.Initialize(channelUsed, Bitrate.Pcan500) = PcanStatus.OK Then
Dim pinMask As UInteger = &H11
If Api.SetValue(channelUsed, PcanParameter.IoDigitalValue, pinMask) = PcanStatus.OK Then
Console.WriteLine($"Pin0 and Pin4 of {channelUsed} were successfully set to 'high'.")
Console.WriteLine($"Pin1, Pin2, and Pin3 of {channelUsed} were successfully set to 'low'. ")
Else
Console.WriteLine($"Error configuring digital Pin states for {channelUsed}.")
End If
Api.Uninitialize(channelUsed)
End If
PcanChannel channelUsed = PcanChannel::Usb01;
if (Api::Initialize(channelUsed, Bitrate::Pcan500) == PcanStatus::OK)
{
UInt32 pinMask = 0x11;
if (Api::SetValue(channelUsed, PcanParameter::IoDigitalValue, pinMask) == PcanStatus::OK)
{
Console::WriteLine("Pin0 and Pin4 of {0} were successfully set to 'high'.", channelUsed);
Console::WriteLine("Pin1, Pin2, and Pin3 of {0} were successfully set to 'low'. ", channelUsed);
}
else
Console::WriteLine("Error configuring digital Pin states for {0}.", channelUsed);
Api::Uninitialize(channelUsed);
}