HSCE2 card can be nightmare to figure out because manual is so poor.
Person who wrote it should be punished (ok i will leave this to you...).
First you need to install card, create initialization routine as described in manual
1746-um002_-en-p.pdfAll the initialization routine does is transfer series of parameters to card.
Parameters are packs of 8 words. Word_0 of each parameter block contains parameter_ID (lower byte),
counter number etc. Words 1-7 are data. The actual work is figuring out what numbers to use
for parameter block setup. Depending on how many counters are to be setup and what is used (ranges etc.)
one will have more or less to configure.
Logic is as follows:
In your main program (LAD2) add rungs
CODE
SOR XIC S:1/15 BST MOV 0 N19:0 NXB OTU B3:5/13 NXB OTU B3:3/0 BND EOR
SOR XIO S:1/15 XIO B3:3/0 XIO B3:5/13 JSR 3 EOR
LAD3 file in this case should contain following logic
CODE
SOR LES N19:0 N19:1 XIO O:1.0/15 XIO I:1.0/15 BST COP #N18:[N19:0] #O:1.0 8 NXB OTL O:1.0/15 BND EOR SOR XIC O:1.0/15 XIC I:1.0/15 BST OTU O:1.0/15 NXB MEQ I:1.0 6000h 0 ADD N19:0 10 N19:0 BND EOR SOR EQU N19:0 N19:1 XIO O:1.0/15 XIO I:1.0/15 BST COP #N18:[N19:0] #O:1.0 8 NXB OTL B3:3/0 BND EOR SOR BST XIC I:1.0/13 NXB XIC I:1.0/14 BND XIC I:1.0/15 OTL B3:5/13 EOR
and you will need files N18 and N19
First one contains parameters for the HSC2 and second one holds just
two numbers ("current parameter" and "number of parameters to load").
As you can see two words are wasted since they use only 8 out of 10 words
per parameter set block.
Order of paramters doesn't really matter as long as you wait with enabling
of counters until end (this should be last block of data). Smart thing to do is
plan and organize....
For example make first parameter block disable counters, then do all other blocks
and in the end enable counters again. This way you don't have to reset or reboot plc
to load new parameter set. Just edit parameters in N18 file and retrigger very first rung
(add branch with another OSR bit around S:1/15).
Anyway, the basic parameters (N18:0..N18:69) would be something like this
(well this should be pretty darn close if not spot on for what you asked).
CODE
1, 101, 8, 0,0,0,0,0,0,0 ; Setup 2 counters blah blah blah
302, 1c,0,1c,0,0,0,0,0,0 ; Configure Gates
4, DFC3,FDA1,20C4,25E,0,0,0,0,0; Setup range for counter 0 (-8388607...8388606)
104, 0,0,4,5F,0,0,0,0,0 ; Setup range for counter 1 (0...4095)
8, FC18,0,3e7,3e7,0,0,0,0,0 ; Setup rate for counter 0 (-1000000...999999)
108, FC18,0,3e7,3e7,0,0,0,0,0 ; Setup rate for counter 1 (-1000000...999999)
80,8001,8001,0,0,FF00,0FFF,0,0,0; Enable both counters
All of these values are HEX. Put value 60 (60 decimal or 3C hex) into N19:1 and you are almost done.
Both counter are configured for X4 (gates setup) so you would get
4x2048=8192 and 4x1024=4096 pulses per revolution.
First counter uses full range. Second one is using only 4096 pulses (0...4095)
because it's single turn (you didn't mention any gearbox).
After this you will need to calculate positions:
CODE
SOR CPT F8:0 ( I:1.2 * 1000.0 ) + I:1.3 EOR
SOR CPT F8:1 ( I:1.8 * 1000.0 ) + I:1.9 EOR
Scaling values should be simple enough.