(***************************************************************) (* *) (* ANGLE CLOCK SYSTEM *) (* *) (* *) (* *) (* DCPM -- DEGREE CLOCK DRIVER AND PERIOD MEASUREMENT *) (* *) (* *) (* *) (* Written 10- 7-91 by Mike Pauwels *) (* Revised 1-31-92 *) (* *) (* *) (* ACTION: 1. MEASURE PERIOD OF A TOOTH SIGNAL AND ADVANCE *) (* TCR2 TO THE NEXT MODULUS NUMBER. *) (* 2. INCREMENT TCR2 WITH FINE TOOTH COUNTS AT A RATE *) (* PROPORTIONAL TO THE PREVIOUS PERIOD. *) (* 3. REQUEST A CPU INTERRUPT WHEN PERIOD EXCEEDS *) (* A SELECTED MULTIPLE OF THE PREVIOUS PERIOD. *) (* 4. ACCEPT SYNCHRONIZATION FROM LINK OR HSR. *) (* *) (* *) (* *) (***************************************************************) FUNCTION DESCRIPTION DCPM measures the period of an input signal, and drives TCR2 at an integral multiple of that frequency. DCPM can be used to detect the speed of a rotating machine by triggering from a toothed wheel, counting each tooth as a selected angle increment, and injecting additional count pulses between the teeth by extrapolating a sub-multiple of the period from the previous tooth signals. The injected counts can be used to trigger other channel events at proportional positions between actual position signals. For example, using a wheel with teeth at ten degree increments, DCPM would advance the count of the teeth by incrementing TCR2 to the next modulus ten count at each tooth, and incrementing by one each tenth of a period following to provide a one-degree count to trigger other functions. During steady-state operation, DCPM can be programmed to increment TCR2 at equal intervals between the incoming teeth. If the period decreases suddenly during acceleration, it is possible that a tooth will be detected before all of the inserted counts have been completed. DCPM will correct the count to the next modulus number, and events set to trigger off the missing counts will be initiated by the greater-than feature of the channel comparators. In the event of sudden increase of the tooth period during deceleration, the number of inserted counts is limited to one less than the modulus number, so that the last interval will represent the increase in the period, but no extra intervals will be reflected in TCR2. DCPM continues to track the number of intervals between teeth, and compares this count to a limit parameter. If the number of intervals exceeds this parameter, an interrupt is requested. This feature provides a stall indication when the tooth signal stops. The period is written coherently to a 24-bit parameter. The resolution is in terms of TCR1. Note that the period value is not valid until the second tooth is detected. The maximum and minimum periods of the input signal are limited by timing considerations in the TPU and the range of values processed. The maximum period (minimum speed) value is determined by: Period_max = TCR1_resolution (microsec) * 65536 * 4 Rotational_speed = 60,000,000 / (Period_max * Teeth_per_rev) For a TCR1 resolution of .238 microseconds per count, the maximum period is 62,500 microseconds per tooth. Given a 36 tooth wheel, this period corresponds to a rotational speed of 26.7 RPM. The minimum period of the input signal is a system decision, determined by the desired loading of the TPU. When an input transition occurs indicating a real tooth detection, the function executes a service routine to measure the period, update the TCR2, and setup for a match event for the first fine tooth. This routine requires approximately 9 microseconds to execute including 10 system clocks for service request response time. At each degree clock period, a service request is generated. The TPU requires a minimum of 10 clock cycles to respond to request, and the service routine executes in another 18 cycles. Thus each degree count requires 1.67 microseconds (at 16.77MHz.) The total time to execute the extrapolation phase and the count phases for a machine with 36 teeth rotating at 8000 RPM and 9 degree counts per tooth would be 24 microseconds. Since the time for the machine to travel 10 degrees at 8000 RPM would be: 60 Sec/Min / 36 Teeth/Rev * 8000 Rev/Min = 208 microsec. The TPU load would be 208 microsec/ 24 microsec = 8.66%. The count of the teeth is maintained in the TCR2 counter, and other channels can be made to trigger off the degree position. An optional feature of DCPM provides for the count to progress from 0 to the maximum degree count then in one step to $8000, and again by steps to $8000 plus the maximum count. This feature allows DCPM to be compatible with certain periodicly triggered functions. The function requires a synchronization request from either the host of from another channel. Until this request is received, TCR2 will idle at a negative number, and a host interrupt will be requested at each tooth. Synchronization is not accepted until after the first tooth is received. Synchronization by a Link from another channel results in a sync flag being set. It is assumed that the other channel has directly updated the degree parameter, and the TCR2 count proceeds with the newly synchronized count at the detection of the next tooth edge. If synchronization is requested from the host, a buffer parameter is used to assure coherent writes to the angle parameter. (* *) (*DATA STRUCTURE *) (* *) (* NOTE: MUST BE USED ON CH 14 or 15. *) (* *) (* PARM NAME BY DESCRIPTION *) (* *) (* 0 CONFIG CPU Selects Rising/Falling Tooth edge *) (* 0 REF_TIME TPU Temporary TCR1 value *) (* *) (* 1H TOOTH TPU Tooth Count *) (* 1L DEGREE TPU Degree Count between Teeth *) (* 1H LINK_TOOTH TPU Force Value for TOOTH with Link *) (* *) (* 2H MODULUS CPU TCR2 Counts per tooth *) (* 2L STALL_COUNT CPU DEGREE Count for Interrupt *) (* *) (* 3H NUMBER_TEETH CPU Teeth per cycle *) (* 3L RATIO CPU Period Multiplier *) (* Note: Degree Period = PERIOD * RATIO / 1024 *) (* *) (* 4L PERIOD_MSB TPU Tooth period MS byte *) (* *) (* 5 PERIOD_LSW TPU Least significant word *) (* *) (* 6 INTERPOLATE TPU Time Between Degrees *) (* *) (* 7H PHASE TPU Phase of TCR2 *) (* 7L WRITE_TOOTH CPU Force Value for TOOTH and TCR2 *) (* *) (*SEQ0 TWO_PHASE Indicates two-phase sequence *) (* *) (*HSR11 INIT Initialize *) (* *) (*HSR10 SET Write TOOTH and Start Fill *) (* *) (*LINK LINK_SET Write TOOTH and Start Fill *) (* *) (*No LINK Generated *) (* *) (*IRQ Interrupt on every Tooth until Syncronization and on STALL *) (* *) (* *)