Hello friend's,
i need to read an encoder that is already connected in I0.0 and I0.1 of Cpu 224.
The old software is lost and now i need to rewrite all, but i don't know how to read the high speed counter into simatic 200 family.
I need to read this encoder for measure a lenght of material.
Anyone can help me ? Do you have a little example to send me ?
Thank you
[?]: How to read an encoder into CPU224
-
- Posts: 265
- Joined: Sat May 27, 2006 6:46 am
- Location: Europe
-
- Posts: 44
- Joined: Tue Jun 26, 2007 12:41 pm
- Location: Egypt
Re: [?]: How to read an encoder into CPU224
[img]High-Speed Counter CountersPLC_ITA wrote:Hello friend's,
i need to read an encoder that is already connected in I0.0 and I0.1 of Cpu 224.
The old software is lost and now i need to rewrite all, but i don't know how to read the high speed counter into simatic 200 family.
I need to read this encoder for measure a lenght of material.
Anyone can help me ? Do you have a little example to send me ?
Thank you
Inputs/Outputs Operands Data Types
N Constant (0,1,2,3,4, or 5) WORD
Memory Ranges Errors Instruction Support for S7-200 CPUs SIMATIC/International Mnemonics
Data Ranges ENO Instruction Size in CPU Memory Addressing Memory
The High-Speed Counter (HSC) instruction, configures and controls the high-speed counter, based on the state of the HSC special memory bits. The parameter N specifies the high-speed counter number.The high-speed counters can be configured for up to twelve different modes of operation.Each counter has dedicated inputs for clocks, direction control, reset, and start, where these functions are supported. For the two-phase counters, both clocks may run at their maximum rates. In quadrature modes, you can select one times (1x) or four times (4x) the maximum counting rates. All counters run at maximum rates without interfering with one another.Notes:
CPU 221 and CPU 222 support 4 High-Speed Counters (HSC0, HSC3, HSC4, and HSC5)CPU 221 and CPU 222 do not support HSC1 and HSC2.CPU 224, CPU224XP, and CPU 226 support 6 High-Speed Counters (HSC0 to HSC5)You use one High-Speed Counter Definition instruction for each high-speed counter.Tip 4 and Tip 29 of the Application Tips on the Documentation CD provide programs that use high-speed counters.Error Conditions that Set ENO = 0:
0001 HSC before HDEF
0005 Simultaneous HSC / PLS
Program Example
LAD FBD
STL
NETWORK 1 // Main Program
// On the first scan call SBR_0
LD SM0.1
CALL SBR_0
NETWORK 1 // Start of Subroutine 0
// Configure HSC1
LD SM0.1 // On the first scan
MOVB 16#F8 SMB47 // Configure HSC1:
// - Enable the counter
// - Write a new current value
// - Write a new preset value
// - Set the initial direction to count up
// - Select the start and reset inputs to be active high
// - Select 4x mode
HDEF 1 11 // HSC1 configured for quadrature mode
// with reset and start inputs
MOVD +0 SMD48 // Clear the current value of HSC1
MOVD +50 SMD52 // Set the HSC1 preset value to 50
ATCH INT_0 13 // HSC1 current value = preset value (EVENT 13)
// attached to interrupt routine INT_0
ENI // Global interrupt enable
HSC 1 // Program HSC1
NETWORK 1 // Start of Interrupt 0
LD SM0.0
MOVD +0 SMD48 // Clear the current value of HSC1
MOVB 16#C0 SMB47 // Select to write only a new current and
// leave HSC1 enabled
HSC 1 // Program HSC1
See Also:
Understanding the High-Speed Counter Instructions
HSC Wizard
HDEF Instruction
[/img]