HSCDEF ch, fn_num, value
Purpose Enable and set up parameters for the High Speed Counters channel ch. These counters operate independently of the ladder logic scan time and can capture high speed input pulses generated by position encoders.

ch = channel number (1-8)
fn_num = Custom Function # to trigger when value is reached.
value = trigger when HSC reach this (32-bit) integer value.

If the PLC supports quadrature encoder inputs, then the HSC counter variable HSCPV[ch] will increment/decrement according to direction of rotation. When value is reached, the specified custom function activates immediately.

Important : All High Speed Counters are disabled automatically when the PLC is reset unless they are enabled by the HSCDEF statement. However, if more than one HSCDEF for the same channel ch is executed, only the last executed HSCDEF statement will take effect. Hence you should put the next HSCDEF statement within the CusFn triggered by the first HSCDEF. By chaining the HSCDEF statement from one CusFn to another, you can control the motion of the machine using the HSC value to execute a series of CusFn one by one. Within these CusFn you can program what to do to control the motion. E.g. changing the speed, putting on the brake, change direction of motion, etc. You can use the SETBIT, CLRBIT for digital ON/OFF control and setDAC, setPWM for proportional control.

Examples HSCPV[1] = 0
HSCDEF 1,19,-3310003
. . . .
SETLCD 1,1,STR$(HSCPV[1],6)
Comments: Enable High-Speed Counter #1 and make it activate function #19 when the counter reaches -33,100,003. Present value of HSC#1 was cleared to 0 before activating it. Note that i-TRiLOGI Version 4.1 does not perform simulation of the High Speed counter operation since there is no High Speed Counter inputs on the simulator screen.
See Also HSCOFF

backbutton.gif (507 bytes)  Basic to TBASIC Reference Manual