IEC 61131-3 C Tools User Manual


Add to my manuals
501 Pages

advertisement

IEC 61131-3 C Tools User Manual | Manualzz

IEC 61131-3 C Tools Function Specifications

hartCommand0

Read Unique Identifier

Syntax

#include <ctools.h>

BOOLEAN hartCommand0(unsigned module, unsigned address,

HART_DEVICE * const device);

Description

This function reads the unique identifier of a HART device using command 0 with a short-form address. This is a link initialization function.

The function has three parameters: the module-number of the 5904 module (0 to

3); the short-form address of the HART device (0 to 15); and a pointer to a

HART_DEVICE structure. The information read by command 0 is written into the

HART_DEVICE structure when the response is received by the 5904 HART interface module.

The function returns TRUE if the command was sent. The function returns

FALSE if the module number is invalid, or if the device address is invalid.

Notes

The function returns immediately after the command is sent. The calling program needs to wait for the response to be received. Use the hartStatus command to read the status of the command.

The number of attempts and the number of preambles sent are set with the hartSetConfiguration command.

A program needs to initialize the link before executing any other commands.

See Also

hartCommand11, hartStatus, hartSetConfiguration

Document (Version 2.50) 5/12/2011 220 220

IEC 61131-3 C Tools Function Specifications

hartCommand1

Read Primary Variable

Syntax

#include <ctools.h>

BOOLEAN hartCommand1(unsigned module, HART_DEVICE * const device,

HART_VARIABLE * primaryVariable);

Description

This function reads the primary variable of a HART device using command 1.

The function has three parameters: the module-number of the 5904 module (0 to

3); the device to be read; and a pointer to the primary variable. The variable pointed to by primaryVariable is updated when the response is received by the

5904 HART interface module.

The primaryVariable needs to be a static modular or global variable. A primaryVariable should be declared for each HART I/O module in use. A local variable or dynamically allocated variable may not be used because a late command response received after the variable is freed will write data over the freed variable space.

The function returns TRUE if the command was sent. The function returns

FALSE if the module number is invalid.

Notes

The HART_DEVICE structure needs to be initialized using hartCommand0 or hartCommand11.

The function returns immediately after the command is sent. The calling program needs to wait for the response to be received. Use the hartStatus command to read the status of the command.

The number of attempts and the number of preambles sent are set with the hartSetConfiguration command.

The code field of the HART_VARIABLE structure not changed. Command 1 does not return a variable code.

See Also

hartCommand2, hartStatus, hartSetConfiguration

Document (Version 2.50) 5/12/2011 221 221

IEC 61131-3 C Tools Function Specifications

hartCommand2

Read Primary Variable Current and Percent of Range

Syntax

#include <ctools.h>

BOOLEAN hartCommand2(unsigned module, HART_DEVICE * const device,

HART_VARIABLE * pvCurrent, HART_VARIABLE * pvPercent);

Description

This function reads the primary variable (PV), as current and percent of range, of a HART device using command 2.

The function has four parameters: the module-number of the 5904 module (0 to

3); the device to be read; a pointer to the PV current variable; and a pointer to the

PV percent variable. The pvCurrent and pvPercent variables are updated when the response is received by the 5904 HART interface.

The pvCurrent and pvPercent variables needs to be static modular or global variables. A pvCurrent and pvPercent variable should be declared for each

HART I/O module in use. A local variable or dynamically allocated variable may not be used because a late command response received after the variable is freed will write data over the freed variable space

The function returns TRUE if the command was sent. The function returns

FALSE if the module number is invalid.

Notes

The HART_DEVICE structure needs to be initialized using hartCommand0 or hartCommand11.

The function returns immediately after the command is sent. The calling program needs to wait for the response to be received. Use the hartStatus command to read the status of the command.

The number of attempts and the number of preambles sent are set with the hartSetConfiguration command.

The code field of both HART_VARIABLE structures is not changed. The response from the HART device to command 2 does not include variable codes.

The units field of the pvCurrent variable is set to 39 (units = mA). The units field of the pvPercent variable is set to 57 (units = percent). The response from the

HART device to command 2 does not include units.

See Also

hartCommand1, hartStatus, hartSetConfiguration

Document (Version 2.50) 5/12/2011 222 222

IEC 61131-3 C Tools Function Specifications

hartCommand3

Read Primary Variable Current and Dynamic Variables

Syntax

#include <ctools.h>

BOOLEAN hartCommand3(unsigned module, HART_DEVICE * const device,

HART_VARIABLE * variables);

Description

This function reads dynamic variables and primary variable current from a HART device using command 3.

The function has three parameters: the module number of the 5904 module (0 to

3); the device to be read; and a pointer to an array of five HART_VARIABLE structures.

The variables array needs to be static modular or global variables. An array of variables should be declared for each HART I/O module in use. A local variable or dynamically allocated variable may not be used because a late command response received after the variable is freed will write data over the freed variable space.

The variables array is updated when the response is received by the 5904 interface as follows.

Variable Contains

variables[0] primary variable current variables[1] primary variable variables[2] secondary variable variables[3] tertiary variable variables[4] fourth variable

The function returns TRUE if the command was sent. The function returns

FALSE if the module number is invalid.

Notes

The HART_DEVICE structure needs to be initialized using hartCommand0 or hartCommand11.

The function returns immediately after the command is sent. The calling program needs to wait for the response to be received. Use the hartStatus command to read the status of the command.

The number of attempts and the number of preambles sent are set with the hartSetConfiguration command.

Not all devices return primary, secondary, tertiary and fourth variables. If the device does not support a variable, zero is written into the value and units code for that variable.

Document (Version 2.50) 5/12/2011 223 223

IEC 61131-3 C Tools Function Specifications

The code field of both HART_VARIABLE structures is not changed. The response from the HART device to command 3 does not include variable codes.

The units field of variable[0] is set to 39 (units = mA). The response from the

HART device to command 3 does not include units.

See Also

hartCommand33, hartStatus, hartSetConfiguration

Document (Version 2.50) 5/12/2011 224 224

IEC 61131-3 C Tools Function Specifications

hartCommand11

Read Unique Identifier Associated with Tag

Syntax

#include <ctools.h>

BOOLEAN hartCommand11(unsigned module, char * deviceTag,

HART_DEVICE * device);

Description

This function reads the unique identifier of a HART device using command 11.

This is a link initialization function.

The function has three parameters: the module number of the 5904 module (0 to

3); a pointer to a null terminated string containing the tag of the HART device; and a pointer to a HART_DEVICE structure. The information read by command

11 is written into the HART_DEVICE structure when the response is received by the 5904 interface.

The function returns TRUE if the command was sent. The function returns

FALSE if the module number is invalid.

Notes

The function returns immediately after the command is sent. The calling program needs to wait for the response to be received. Use the hartStatus command to read the status of the command.

The number of attempts and the number of preambles sent are set with the hartSetConfiguration command.

A program needs to initialize the link before executing any other commands.

See Also

hartCommand0, hartStatus, hartSetConfiguration

Document (Version 2.50) 5/12/2011 225 225

IEC 61131-3 C Tools Function Specifications

hartCommand33

Read Transmitter Variables

Syntax

#include <ctools.h>

BOOLEAN hartCommand33(unsigned module, HART_DEVICE * const device, unsigned variableCode[4], HART_VARIABLE * variables);

Description

This function reads selected variables from a HART device using command 33.

The function has four parameters: the module number of the 5904 module (0 to

3); the device to be read; an array of codes; and a pointer to an array of four

HART_VARIABLE structures.

The variables array needs to be static modular or global variables. An array of variables should be declared for each HART I/O module in use. A local variable or dynamically allocated variable may not be used because a late command response received after the variable is freed will write data over the freed variable space.

The variableCode array specifies which variables are to be read from the transmitter. Consult the documentation for the transmitter for valid values.

The variables array is updated when the response is received by the 5904 interface as follows.

Variable Contains

variables[0] transmitter variable, code and units specified by variableCode[0] variables[1] transmitter variable, code and units specified by variableCode[1] variables[2] transmitter variable, code and units specified by variableCode[2] variables[3] transmitter variable, code and units specified by variableCode[3]

The function returns TRUE if the command was sent. The function returns

FALSE if the module number is invalid.

Notes

The HART_DEVICE structure needs to be initialized using hartCommand0 or hartCommand11.

The pointer variables needs to point to an array with at least four elements.

Document (Version 2.50) 5/12/2011 226 226

IEC 61131-3 C Tools Function Specifications

The function returns immediately after the command is sent. The calling program needs to wait for the response to be received. Use the hartStatus command to read the status of the command.

The number of attempts and the number of preambles sent are set with the hartSetConfiguration command.

The function requests four variables and expects four variables in the response.

See Also

hartCommand3, hartStatus, hartSetConfiguration

Document (Version 2.50) 5/12/2011 227 227

advertisement

Was this manual useful for you? Yes No
Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Related manuals

advertisement

Table of contents