How to Program a High Speed Counter

How to Program a High Speed Counter

This tutorial will cover the configurations for using the built-in High Speed Counter for the Maple Modular and Micro PLC’s.

Software Required

Hardware Required

What is a High Speed Counter?

A high speed counter is used for counting the number of pulses received in an assigned high-speed digital input. It can provide high-speed output signals for example: a stepper motor control, alarms or other discrete control functions.

The Maple Modular and Micro both have 2 built-in high speed input channels each.

Wiring and Circuit Design

 Choose a Maple Modular or Maple Micro PLC Choosing a Maple Modular PLC

Software Configuration

  • Right click on Program and select New Program.
  • Choose HSC under Special Configuration.

The HSC Program Window will open.

Start Address

  • Choose a Starting Address. It can be either registers D, L, M, or K.

Channel

There are 2 High Speed Counter Channels built into the Maple Modular and Micro PLC’s. You can configure 2 channels in the HSC Program Window.

Count Mode

You can choose either Linear Counter or Ring Counter.

  1. A Linear Counter:
  • Input Pulses are counted in the range from -2147483648 to 2147483648.
  • The Overflow Error will occur if the value counting up or down exceeds the max or min range.
  1. A Ring Counter
  • Input pulses are counted repeatedly between the minimum ring counted value and the maximum ring-counted value. Overflow DOES not occur.

Input Pulse Type

There are four different types of counter input modes:

Compare Mode

Compare Output can be used.

There are 7 compared output conditions or modes available with combinations of >, =, and <.

In order to use compared output signal, [Enable Compare Output (Y)] MUST be selected in the Channel Configuration window.

Compare Output

You can output an external signal by choosing Y10-Y17 as the compared output signals.

Max. Compare Value and Min. Compare Value

You can either use the Compare Minimum Value ONLY, or both Maximum and Minimum value together.

For Compare Mode in which both the maximum and the minimum values are used, it is NOT a must for the maximum value to be greater than the value set for the minimum value. Given two configured values, the Maple PLCs internally takes the larger of the two values as maximum value and the lesser as minimum value.

Int. Preset Value

When it is necessary to forcefully configure the current count value to a specific value, you must set (turn ON) this Internal Preset Command bit (Bit 1) in your ladder diagram. When this bit is set (turned ON), the Current Count Value will take the written value of the Internal Preset Value.

Ext. Preset Value

When this flag is SET (turned ON), the current count value will be forcefully changed to the designated value through an external signal. The external signal is assigned and fixed to inputs X0004 (Channel 1) and X0006 (Channel 2). The external signal must be received by these input contacts (X04 and X06). The preset setup value must be written to the External Preset Value before the preset signal is entered.

Ring Counter Max

If using the Count Mode “Ring Counter”, the value set in the Ring Counter Max will be taken as the upper limit. The count range is from 0 to the user-defined maximum value (Ring Counter Max Value).

Unit Time (mSec)

The Unit Time must be set in order to use and measure RPM or PPS. If you leave it as 0, the function will not work. 1000ms is the default value.

Pulse per 1 Cycle

In order to measure RPM, this offset value must be configured as something other than zero (0). If zero (0) is configured here, PPS will operate in the measurement mode and an error will be displayed. In other words, the Pulse Per 1 Cycle / Rotation must be set as something other than zero (0) value while the RPM/PPS selection flag is set (turned ON) in order to properly measure the RPM and write the resulting value in the RPM/PPS Measured Value areas. If the RPM/PPS selection flag is reset, the PPS measurement value will be written.

RPM (1)/PPS (0)

For RPM, use the value of 1. For PPS, leave as 0.

According to the flag status of the “RPM/PPS selection”, RPM or PPS measurement values will be stored in this area. For the RPM operation, the “Pulse Per 1 Cycle/Rotation” flag must be something other than zero (0).

Enable Count

 The Enable Count MUST be checked for the High Speed Counter to initiate.

Online Simulation (Linear Counter)

  • If the Enable Count is initiated, the Enable Count Flag will be ON.
  • Press the Monitor button to see live values in your HSC window.
  • Turn on the Pulse Signal. X01 will Pulse according to the PPS.
  • The Down Count Flag will turn ON and you will see the count in the Current Count.
  • Send 24V into X00. X00 and X01 will both pulse and it will start to count up.

Compare Mode Example (Min. Value)

This example will use the Compare Mode ” Current Count > Cmp. Value.

Make sure the “Enable Cmp. Output (Y)” is enabled.

In this case, it will compare to the Min. Value (20).

When online and monitoring, the “Enable Cmp. Output” Status Flag will turn ON.

If the count is greater than (20), then the Compare Output (Y0010) will turn ON.

The “Cmp. Output” Status Flag will turn ON.

Compare Mode Example (Min. and Max. Values)

This example will also use the Compare Mode ” Current Count > Cmp. Value. but will compare to the Min and Max values.

For example we’re using (20) for Min and (50) for Max.

If the count is within the range of 20 and 50, the system will continue to run.

If the count is below 20 or above 50, the compare output (Y10) will turn ON.

Online Simulation (Ring Counter)

Ring Counter Example

For a ring counter, we’ll be using the “Ring Counter Max” and set that to 50.

Set the Max. Compare Value to (40) and Min. Compare Value to (0).

If the count goes above (40), the compare output (Y10) will turn ON.

When the count hits (50), it will reset the count to 0 and a “Carry” will occur.

High Speed Counter I/O Module

IO-SHSC02 High Speed Counter Module

  • If you need to add more than 2 High Speed Counter Channels, you can connect the IO-SHSC02 as an expansion module.
  • This can ONLY be used to connect to the Maple Modular PLC’s.
  • Each HSC Module has 2 Channels, just like the built-in HSC for the Maple Modular and Micro PLC’s. It also has all the same features as the built-in HSC.
  • You WILL need to use a Terminal Block to connect the IO-SHSC02. There are connection and wiring examples in the High Speed Counter Module User Manual below.

Sample Project

The project shown above was designed for the specific hardware mentioned at the beginning of the tutorial and is intended to provide you guidance when programming your unit. If you are using models other than the ones specified in this sample project, similar steps can be duplicated within your own project.

Download MapleLogic Sample Project

Resources & Documentation

Maple PLC/MapleLogic Resources

More
Tutorials
Sample Projects

See our Support Center for a complete list of Quick Start and Installation Guides

Scroll to Top