Chapter 4
NI-DNET Programming Techniques
4-10
ni.com
By consulting the specifications for the Control Supervisor object and the
AC/DC Drive object, you can determine that the DeviceNet data type for
Run Fwd and Fault Reset is
BOOL
(boolean), and the DeviceNet data type
for Speed Reference is
INT
(16-bit signed integer).
Accessing I/O Members in LabVIEW
Many fundamental differences exist between the encoding of a DeviceNet
data type and its equivalent data type in LabVIEW. For example, for a
32-bit integer, the DeviceNet
DINT
data type uses Intel byte ordering
(lowest byte first), and the equivalent LabVIEW
I32
data type uses
Motorola byte ordering (highest byte first).
To make it easier for you to avoid these data type issues in your
LabVIEW application, NI-DNET provides two functions to convert
between LabVIEW data types and DeviceNet data types:
ncConvertForDnetWrite
and
ncConvertFromDnetRead
. These
functions are used to access individual members of an I/O assembly using
normal LabVIEW controls and indicators.
The following steps show an example of how you can use
ncConvertForDnetWrite
to access the Basic Speed Control Output
Assembly described in the previous section:
1.
Use the NI-DNET palette to place
ncConvertForDnetWrite
into
your diagram.
2.
Right-click on the
DnetData in
terminal and select
Create
Constant
, then initialize the first 4 bytes of the array to zero.
3.
Right-click on the
DnetType
terminal and select
Create Constant
,
then select
BOOL
from the enumeration.
Table 4-1.
Attribute Mapping for Basic Speed Control Output Assembly
Member
Name
Class
Name
Class ID
Instance ID
Attribute
Name
Attribute ID
Run Fwd
Control
Supervisor
29 hex
1
Run1
3
Fault
Reset
Control
Supervisor
29 hex
1
FaultRst
12
Speed
Reference
AC/DC
Drive
2A hex
1
SpeedRef
8