Pulse Counter Functions

This section describes the Pulse Counter module functions. They are used to control Pulse Counter interface and modify its settings.

Actual control of the device is performed by use of commands and responses. Each function utilizes respective commands and responses. You can send such commands directly if necessary.

Rating: 
Голосов пока нет

DlnPlsCntGetPortCount() Function

The DlnPlsCntGetPortCount() function retrieves the number of pulse counter ports available in your DLN-series adapter.

Syntax
C/C++
DLN_RESULT DlnPlsCntGetPortCount(
  HDLN handle, 
  uint8_t *count
);
Parameters
handle

A handle to the DLN-series adapter.

count

A pointer to an unsigned 8-bit integer that receives the number of available Pulse counter ports.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the number of available pulse counter ports.

Remarks

The DlnPlsCntGetPortCount() function is defined in the dln_pls_cnt.h file.

DlnPlsCntEnable() Function

The DlnPlsCntEnable() function configures a port as Pulse counter.

Syntax
C/C++
DLN_RESULT DlnPlsCntEnable(
  HDLN handle, 
  uint8_t port, 
  uint16_t *conflict
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the port.

conflict

A pointer to an unsigned 16-bit integer that receives the conflicted pin information.

A conflict arises if any pin of the port is already assigned to another module of the DLN adapter and cannot be used for the Pulse counter module. To fix this, check which module uses the pin (call the DlnGetPinCfg()function), disconnect the pin from that module and call the DlnPlsCntEnable() function once again. In case there still are conflicted pins, the number of the next one will be returned.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured the port as Pulse counter.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnPlsCntGetPortCount() function to find the maximum possible port number.

DLN_RES_PIN_IN_USE (0xA5)

The port cannot be activated as Pulse counter because one or more pins of the port are assigned to another module. The conflict parameter contains the number of a conflicting pin.

DLN_RES_NO_FREE_TIMER (0xD0)

Remarks

The DlnPlsCntEnable() function is defined in the dln_pls_cnt.h file.

DlnPlsCntDisable() Function

The DlnPlsCntDisable() function releases a port from Pulse counter.

Syntax
C/C++
DLN_RESULT DlnPlsCntDisable(
  HDLN handle, 
  uint8_t port
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the port.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully released the port from Pulse counter.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnPlsCntGetPortCount() function to find the maximum possible port number.

Remarks

The DlnPlsCntDisable() function is defined in the dln_pls_cnt.h file.

DlnPlsCntIsEnabled() Function

The DlnPlsCntIsEnabled() function informs whether a port is currently configured as Pulse counter.

Syntax
C/C++
DLN_RESULT DlnPlsCntIsEnabled(
  HDLN handle, 
  uint8_t port, 
  uint8_t *enabled
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the port.

enabled

A pointer to an unsigned 8-bit integer that receives the current port configuration.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved information about the Pulse counter port.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnPlsCntGetPortCount() function to find the maximum possible port number.

Remarks

The DlnPlsCntIsEnabled() function is defined in the dln_pls_cnt.h file.

DlnPlsCntSetMode() Function

The DlnPlsCntSetMode() function is used to set mode and limit parameters of specified Pulse Counter port.

Syntax
C/C++
DLN_RESULT DlnPlsCntSetMode(
  HDLN handle, 
  uint8_t port,
  uint8_t mode, 
  uint32_t limit
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the port to retrieve information about.

mode

Defines the mode parameter of the Pulse Counter port.

Pulse Counter Module Modes
Mode IdMode TitleMode Description

0

Free Run Mode

Pulses are counted continuously. You can suspend, resume or reset the counter and get the number of pulses at any time.

1

Time Based Mode

Pulses are counted during the user-defined time period. When the predefined time period (limit) is exceeded, the counting starts again from 0. The pulse counter can send a match event to PC if activated. The event contains the number of pulses detected during this period.

2

Pulse Based Mode

Pulses are counted until the number of pulses reaches the user-defined value (limit). Then the counting starts again from 0. The counter can send an event to PC if activated. The event contains time elapsed from the moment you started the counter.

limit

Defines the limit parameter of the Pulse Counter port.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured the Pulse counter port.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnPlsCntGetPortCount() function to find the maximum possible port number.

DLN_RES_OVERFLOW (0xB5)

DLN_RES_BUSY (0xB6)

The function cannot configure the Pulse counter port while it is busy.

DLN_RES_INVALID_MODE (0xC7)

The mode value is not valid.

Remarks

The DlnPlsCntSetMode() function is defined in the dln_pls_cnt.h file.

DlnPlsCntGetMode() Function

The DlnPlsCntGetMode() function is used to get mode and limit parameters of the specified Pulse Counter port.

Syntax
C/C++
DLN_RESULT DlnPlsCntGetMode(
  HDLN handle, 
  uint8_t port, 
  uint8_t *mode, 
  uint32_t *limit
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the port.

mode

A pointer to an unsigned 8-bit integer that receives the current mode parameter of the Pulse Counter port.

limit

A pointer to an unsigned 32-bit integer that receives the current limit parameter of the Pulse Counter port.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the Pulse counter port configuration.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnPlsCntGetPortCount() function to find the maximum possible port number.

Remarks

The DlnPlsCntGetMode() function is defined in the dln_pls_cnt.h file.

DlnPlsCntGetResolution() Function

The DlnPlsCntGetResolution() function retrieves the current Pulse Counter Module resolution.

Syntax
C/C++
DLN_RESULT DlnPlsCntGetResolution(
  HDLN handle, 
  uint8_t port, 
  uint8_t *resolution
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the port to be configured.

resolution

A pointer to an unsigned 8-bit integer that receives the resolution value.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the Pulse counter module resolution.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnPlsCntGetPortCount() function to find the maximum possible port number.

Remarks

The DlnPlsCntGetResolution() function is defined in the dln_pls_cnt.h file.

DlnPlsCntGetValue() Function

The DlnPlsCntGetValue() function retrieves the current timer and counter values of the specified Pulse Counter port.

Syntax
C/C++
DLN_RESULT DlnPlsCntGetValue(
  HDLN handle, 
  uint8_t port, 
  uint32_t *timerValue, 
  uint32_t *counterValue
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the port.

timerValue

A pointer to an unsigned 32-bit integer that receives the timer value.

counterValue

A pointer to an unsigned 32-bit integer that receives the counter value.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the timer and counter values.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnPlsCntGetPortCount() function to find the maximum possible port number.

Remarks

The DlnPlsCntGetValue() function is defined in the dln_pls_cnt.h file.

DlnPlsCntReset() Function

The DlnPlsCntReset() function resets the timer and/or counter on the Pulse Counter port.

Syntax
C/C++
DLN_RESULT DlnPlsCntReset(
  HDLN handle, 
  uint8_t port, 
  uint8_t resetTimer, 
  uint8_t resetCounter
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the port.

resetTimer

Defines whether the timer needs to be reset. To reset the timer, specify any value greater than 0 to this parameter.

resetCounter

Defines whether counter need to be reset. To reset the counter, specify any value greater than 0 to this parameter.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully reset the timer and/or counter values.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnPlsCntGetPortCount() function to find the maximum possible port number.

Remarks

The DlnPlsCntReset() function is defined in the dln_pls_cnt.h file.

DlnPlsCntResume() Function

The DlnPlsCntResume() function resumes the pulse counter operation state on the Pulse Counter port.

Syntax
C/C++
DLN_RESULT DlnPlsCntResume(
  HDLN handle, 
  uint8_t port
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the port.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully resumed the pulse counter operation state.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnPlsCntGetPortCount() function to find the maximum possible port number.

Remarks

The DlnPlsCntResume() function is defined in the dln_pls_cnt.h file.

DlnPlsCntSuspend() Function

The DlnPlsCntSuspend() function suspends pulse counter operation state on the Pulse Counter port.

Syntax
C/C++
DLN_RESULT DlnPlsCntSuspend(
  HDLN handle, 
  uint8_t port
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the port.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully suspended the pulse counter operation state.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnPlsCntGetPortCount() function to find the maximum possible port number.

Remarks

The DlnPlsCntSuspend() function is defined in the dln_pls_cnt.h file.

DlnPlsCntIsSuspended() Function

The DlnPlsCntIsSuspended() function informs whether a port is currently suspended.

Syntax
C/C++
DLN_RESULT DlnPlsCntIsSuspended(
  HDLN handle, 
  uint8_t port, 
  uint8_t *suspended
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the port.

suspended

A pointer to an unsigned 8-bit integer that receives the current port configuration.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the current port configuration.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnPlsCntGetPortCount() function to find the maximum possible port number.

Remarks

The DlnPlsCntIsSuspended() function is defined in the dln_pls_cnt.h file.

DlnPlsCntSetEventCfg() Function

The DlnPlsCntSetEventCfg() function defines the event configuration for the specified Pulse Counter port.

Syntax
C/C++
DLN_RESULT DlnPlsCntSetEventCfg(
  HDLN handle, 
  uint8_t port, 
  uint8_t eventType, 
  uint32_t repeatInterval
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the port.

eventType

Defines the event type parameter. There are 4 possible event types.

  • DLN_PLS_CNT_EVENT_NONE - 0

  • DLN_PLS_CNT_EVENT_OVERFLOW - 1

  • DLN_PLS_CNT_EVENT_MATCH - 2

  • DLN_PLS_CNT_EVENT_REPEAT - 4

repeatInterval

Defines the repeat interval parameter.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured events for the specified port.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnPlsCntGetPortCount() function to find the maximum possible port number.

DLN_RES_INVALID_EVENT_TYPE (0xA9)

The specified event type is not valid.

DLN_RES_INVALID_EVENT_PERIOD (0xAC)

The specified event period is not valid.

Remarks

The DlnPlsCntSetEventCfg() function is defined in the dln_pls_cnt.h file.

DlnPlsCntGetEventCfg() Function

The DlnPlsCntGetEventCfg() function is used to get event configuration of the specified Pulse Counter port.

Syntax
C/C++
DLN_RESULT DlnPlsCntGetEventCfg(
  HDLN handle, 
  uint8_t port, 
  uint8_t *eventType, 
  uint32_t *repeatInterval
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the port to get configuration.

eventType

A pointer to an unsigned 8-bit integer. Defines the current event type parameter.

repeatInterval

A pointer to an unsigned 32-bit integer. Defines the current repeat interval parameter

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the current event configuration.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnPlsCntGetPortCount() function to find the maximum possible port number.

Remarks

The DlnPlsCntGetEventCfg() function is defined in the dln_pls_cnt.h file.