Welcome

Hello and welcome to all of you
Please leave comments if you like the post and be the follower for this Blog.

Sunday, September 19, 2010

Getting Started with High Speed Counters in Siemens Step 7.... continue

Defining Counter Modes and Inputs

Use the High-Speed Counter Definition instruction to define the counter modes and inputs. This shows the inputs used for the clock, direction control, reset, and start functions associated with the high-speed counters. The same input cannot be used for two different functions, but any input not being used by the present mode of its high-speed counter can be used for another purpose. For example, if HSC0 is being used in mode 1, which uses I0.0 and I0.2, I0.1 can be used for edge interrupts or for HSC3.

Four counters have three control bits that are used to configure the active state of the reset and start inputs and to select 1x or 4x counting modes (quadrature counters only). These bits are located in the control byte for the respective counter and are only used when the HDEF instruction is executed.





Setting the Control Byte
After you define the counter and the counter mode, you can program the dynamic parameters of the counter. Each high-speed counter has a control byte that allows the following actions:
- Enabling or disabling the counter
- Controlling the direction (modes 0, 1, and 2 only), or the initial counting direction for all other modes
- Loading the current value
- Loading the preset value

Setting Current Values and Preset Values
Each high-speed counter has a 32-bit current value and a 32-bit preset value. Both the current and the preset values are signed integer values. To load a new current or preset value into the high-speed counter, you must set up the control byte and the special memory bytes that hold the current and/or preset values, and also execute the HSC instruction to cause the new values to be transferred to the high-speed counter. Table 6-29 lists the special memory bytes used to hold the new current and preset values. In addition to the control bytes and the new preset and current holding bytes, the current value of
each high-speed counter can only be read using the data type HC (High-Speed Counter Current) followed by the number (0, 1, 2, 3, 4, or 5) of the counter. The current
value is directly accessible for read operations, but can only be written with the HSC instruction.

Addressing the High-Speed Counters (HC)

To access the count value for the high-speed counter, specify the address of the high-speed counter, using the memory type (HC) and the counter number (such as HC0). The current value of the high-speed counter is a read-only value that can be addressed only as a double word (32 bits).

No comments:

Post a Comment