FB_BACnet_MultiStateValue_ADS
The following function block is used for linking a BACnet object of the local BACnet server. The function block for the corresponding BACnet object is linked with the aid of process data.
The process data can be created manually in the BACnet object, linked manually, or they can be generated automatically via PLC automapping. The comments required for PLC automapping ( (* ~ (BACnet... | ??? | ??? ) *) ) are already included in the declaration of the function block.
Use
The function block "FB_BACnet_MultiStateValue_ADS" can be used for read and asynchronous write access to a BACnet object of type MultiStateValue (MV). To this end the BACnet object was created under a local BACnet server.
VAR_INPUT
bEnablePV : BOOL;
nPV : UDINT; (* number for priority x, when input bEnablePV is TRUE *)
bManual : BOOL; (* FALSE --> TRUE: write present_value immediately,
FALSE: only write present_value on-change,
TRUE: write present_value on-change and when device turns operational *)
ePriority : E_BACNETPRIORITY := BACNETPRIORITY_12;
bEnablePV: enables the value of input "nPV". As soon as the input is set to TRUE there is a write access with the value from "nPV" to the commandable property Present_Value with priority from "ePriority" (default: 12, if the input "ePriority" is not connected).
If the input is set to FALSE, a write access with the value NULL is made to the commandable property Present_Value with priority from "ePriority" (NULL write).
nPV: value to be written to the Priority_Array of the commandable property Present_Value when "bEnablePV" is set to TRUE. The priority is determined with the input "ePriority" (default: 12, if the input "ePriority" is not connected). Writing is enabled by setting the input "bEnablePV" to TRUE. Writing to the object is executed via ADS when the value changes.
Since the writing of the property Present_Value is performed acyclically and only when the value changes, it is potentially possible that the property Present_Value with the same priority is also overwritten by other BACnet devices. In this case (i.e. same priority) the last write access always "wins". |
bManual: the following evaluations are distinguished for the input:
- FALSE: write on value change
- Edge change FALSE --> TRUE: triggers the writing of the property Present_Value directly.
- TRUE: write on value change and when the associated BACnet server changes to the "Operational" state (see FB_BACnet_Device).
ePriority: specification of the priority for write access to the property Present_Value (default: 12, see also E_BACNETPRIORITY).
VAR_OUTPUT
bReady : BOOL;
bPvDone : BOOL; (* present_value written over ADS *)
nPresentValue : UDINT;
bOverridden : BOOL;
bOutOfService : BOOL;
bFault : BOOL;
bInAlarm : BOOL;
nNbrOfStates : UDINT;
bError : BOOL;
nErrorId : UINT;
nAdsErrorId : UDINT;
bReady: Notification of general readiness. If this output is set, the other status outputs are valid (PresentValue, Overridden ...). If the output is FALSE, the corresponding function block "FB_BACnet_Device" does not report "Operational", or the block instance was not linked correctly in the System Manager.
bPvDone: Positive edge when write access to property Present_Value was successfull.
nPresentValue: Current value of the BACnet object (see also BACnet specification DIN EN ISO 16484-5 for BACnet object MultiStateValue and property Present_value).
bOverridden, bOutOfService, bFault, bInAlarm: See BACnet specification DIN EN ISO 16484-5 for BACnet object MultiStateValue and property Status_Flags.
nNbrOfStates: Reports the available number of values, which the Present_Value of the MultiStateValue object can assume (1...nNbrOfStates). If "nNbrOfStates" is 0, then there is no valid "state" which the object can assume (Present_Value is 0).
bError: An error is pending.
nErrorId: Error number
0 = no error
2 = incorrect process data mapping detected (check mapping in the System Manager; if necessary compile complete PLC project and reload)
3 = the corresponding BACnet server is not ready (bOperational = FALSE at instance of the FB_BACnet_Device)
4 = the object type of the BACnet object dosn't match the function block type (the object type will determined over the process data. --> check the process data mapping in the System Manager!)
The error numbers can be queried as block constants via the FB instance (FB_BACnet_???.nERR_xxx).
nAdsErrorId: ADS error code.
VAR_IN_OUT
Device : FB_BACnet_Device;
Device: Specification of the instance of the local corresponding BACnet server block. For each BACnet adapter one BACnet server is possible. See FB_BACnet_Adapter and FB_BACnet_Device for further information.