METHOD AND APPARATUS DETERMINING POSITION OF A MOVABLE BARRIER

Abstract: A movable barrier operator (10) includes an absolute position detector (124) which provides a unique value for each position of the barrier (12) along its path of travel. The absolute position detector (142) employs multiple binary serial streams and one multiple clock stream. After the first five cycles of the clock stream, the binary streams can be decoded by a processor to produce an absolute position. Every clock edge produces a new absolute position along the path of travel.

Description: METHOD AND APPARATUS DETERMINING POSITION OF A MOVABLE BARRIER "~ BACKGROUND OF THE INVENTION 1. Field of the Invention The ' invention relates to operators for movable barriers, such as rolling shutters, retractable awnings, gates, garage doors, overhead doors and the like, and more particularly to operators which can determine the absolute position of the barrier at all times, including after a power outage and subsequent manual relocation of the barrier. 2. Description of Related Art One of the problems which must be addressed in designing and engineering operators for movable barriers is the provision of barrier position detection. Most electronic positioning systems used in barrier operators keep track of the barrier's position by incrementing a position counter during one direction of travel and decrementing the position counter during the opposite direction of travel. This can cause errors if there are missed pulses or extraneous pulses during travel (such as from slippage of the barrier or motor) . Some barrier position detection systems employ a pass point. The pass point corresponds to a fixed location on the barrier, so that whenever the barrier moves past the pass point, the position detector is normalized or calibrated. By normalizing or zeroing out the position detector (or counter) , the effects of missed pulses or slippage are eliminated. Some systems employ multiple pass points which provide further error removal capability. The pass point is a good solution in most situations, such as for garage door operators, which seldom move manually. A more significant problem can occur in motorized awnings or rolling shutters. The rolling shutter assembly is frequently installed in a housing which is built into a wall. If power goes out on a rolling shutter system, the user will frequently move the rolling shutter manually to either open or close it. The power is off, but the gears of the positioning system move without power applied to assure manual override of an electric system for the purpose of power failures. Some users may also decide for convenience to move the shutter manually. When power returns, if the rolling shutter has been manually moved past all pass points, the operator, not encountering the pass point reference, may cause the rolling shutter to continue to move completely into the housing necessitating removal of the shutter from the housing. Removal of the rolling shutter from the housing frequently means removing a portion of an interior wall. There is a need for a movable barrier operator with a position indicating system that provides the absolute position of the barrier, even after power outages or after the barrier has been moved manually. There is a need for a movable barrier operator which can unambiguously determine the position of the barrier after power is applied. There is a need for a movable barrier operator which can unambiguously determine the position of the barrier regardless of direction of travel. SUMMARY OF THE INVENTION A barrier operator position detector includes a first rotary member which is encoded to generate a first N bit subcode selected from N sequential bits of a M bit code word. The first N bit subcode has the property that every selected subcode of N sequential bits of the M bit code word has a unique value. N is greater than 1 and preferably 5. M is greater than N and preferably 32. A second rotary member is encoded to generate a second N bit subcode selected from N sequential bits of a M-l bit code word, the second N bit subcode also has the property that every selected subcode of N sequential bits of the M-l bit code word has a unique value (preferably M-l is 31) . A controller, responsive to the first subcode and the second subcode, generates a 2N bit multibit (or two N-bit subcodes) code. The 2N bit multibit subcode is representative of a unique position output, which can be decoded into a unique position of the barrier along its travel. A movable barrier operator according to the invention includes an absolute position detector which provides a unique value for each position of the barrier along its path of travel. The absolute position detector employs two binary serial streams and one clock stream. After the first five cycles of the clock stream, the binary serial streams can be decoded by a microprocessor or other processor to produce an absolute position indication. Every clock edge produces a new absolute position value along the path of travel . The absolute position detector employs three wheels; two data wheels and a clock wheel driven by a pinon. Each wheel rotates near a wheel state detector which produces digital signals comprising bit streams. Preferably an infrared emitter-sensor pair is used as the wheel state detector. However, any electromechanical system which produces a digital signal comprising bit streams, such as Hall sensors, laser discs, and so on, may be used. For convenience, the absolute position detector of the invention will be described in detail with reference only to the infrared emitter-sensor embodiment. In the preferred embodiment, two of the wheels are data wheels or gears and have teeth distributed around their outer portions. One wheel has 32 teeth, the other wheel has 31 teeth. Each tooth of each data wheel has a corresponding data bit formed in the wheel before the tooth. Each data bit represents a single binary data bit . A space formed below a tooth represents a digital low; a solid area formed below the tooth represents a digital high. The 32 teeth wheel has a 32 bit binary stream formed in it. The stream is uniquely defined so that any consecutive 5 bits in the stream are different from any other consecutive 5 bits in the stream, including the rollover stream. The 31 teeth wheel is similarly defined, .except the 31 teeth wheel has the same bit binary stream as the 32 bit wheel, with one bit missing. Since the 32 teeth wheel and the 31 teeth wheel have different numbers of teeth and are driven by the same pinion, they rotate at different speeds. The pinion is driven externally by a gearing system that is driven by the motor. The motor can rotate clockwise or counterclockwise, so the pinion can also turn in both directions. Since the motor is bi-directional, an attached load comprising a barrier such as a door, awning, shutter or gate can move in either of two opposite directions. Preferably direction of travel information is obtained by storing the commanded direction of travel (i.e., the user commands the door to open by pushing the open button or to close by pushing a close button) . The movable barrier is operated through linear linkage of the load to the motor such as a trolley, or through rotational linkage to the motor, where the load is wound around the entire operator unit, such as in a rolling shutters. Since the two data wheels rotate at different speeds (because of the different number of teeth) , the two binary streams have different repeat rates. This means that a given 5 bit stream from the 32 teeth wheel will not combine with the corresponding 5 bit stream from the 31 teeth wheel until 31 more revolutions of the 32 teeth wheel, or vice versa. In other words, a total of 31 x 32 = 992 unique two word values are possible without a rollover or repeated position concern. 992 unique positions is large enough to provide absolute position along a part of a movable barrier in most situations. An extra data wheel may be added for more positions (i.e., 32 x 31 x 30 = 29,760 positions). This mechanical linkage also means if the unit is moved manually, the 31 bit wheel and the 32 bit wheel will move, storing or representing for later reading by the controller, the position of the awning, door or shutter. The third wheel is a clock wheel and is used to provide a clock signal for the position detecting system to enable, proper sampling of the data wheel bit streams. The clock wheel includes 32 equally spaced openings. The clock wheel provides a digital low pulse signal when the center of a data bit on the 32 teeth wheel lines up with the center of a data bit on the 31 teeth wheel and when these centers are in line with the IR sensors. The clock signal is provided to the microprocessor which uses the clock signal as an interrupt to sample binary data from emitter-receiver pair associated with each data wheel. After the first 5 clock cycles, each data wheel has output a 5 digit binary stream, which when combined, gives 2 five digit binary numbers. This 5 digit binary number pair is decoded by the microprocessor which calculates an absolute position. Thereafter, every clock cycle triggers the sampling of a new binary digit from each wheel, the stored 5 bit binary number pair is updated, and a new absolute position of the barrier is determined. The movable barrier operator according to the invention with absolute position detector (or encoder system) provides many advantages. It provides the absolute position of the barrier for every pulse edge of the clock signal from positioning gears turned by motor's gearing system. Shortly after power is applied to the motor, the clock wheel would have produced 5 pulses. After 5 pulses, the encoder system determines the absolute position of the barrier. The encod-er system can provide direction of travel after six pulses of the clock wheel. The encoder system discriminates false or unwanted pulses to prevent false positioning. An absolute position is always provided shortly after power is applied (after 5 pulses and the first 5 digit binary pair is obtained) , regardless of the stored value of the last position and regardless of where the barrier may have been moved manually. The absolute position detector also provides an opportunity for the system to do a validity check for every newly calculated position (i.e., by checking the absolute position between successive data streams, the direction of travel can be ascertained) . It should also be noted that no presetting of the wheels prior to installation/ operation is required. Additional advantages and features of the invention may be appreciated from a perusal of the specification, including claims in light of the accompanying drawing. BRIEF DESCRIPTION OF THE DRAWINGS Fig. 1 is a perspective view of a garage door operating system in accordance with an embodiment of the invention; Fig. 2 is a perspective view of a rolling shutter operating system in accordance with an alternative embodiment of the invention; Fig. 3 is a perspective view of the tubular motor assembly of Fig. 2; Figs. 4 and 5 are two exploded perspective views of the location of the absolute position detector assembly shown in Fig. 3; Fig. 6 is an enlarged perspective view of the absolute position detector assembly of Fig. 4; Fig. 7 is a graph of the 32 bit data streams produced in each of the 31 bit wheel and 32 bit wheel; Fig. 8 is an example calculation of position using the 31 bit wheel and the 32 bit wheel; Fig. 9 is a flow chart of the routine run by the controller to sample the 5 bit data streams; Fig * 10 is a flow chart of the RPM routine used by the controller to sample the 5 bit data streams; and Fig. 11 is a schematic diagram of the electronics controlling the rolling shutter head unit of Fig. 2. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Referring now to the drawings,- and especially to Fig. 1, a movable barrier operator embodying the present invention is generally shown therein and identified by reference numeral 10. The movable barrier operator 10 is employed for controlling the opening and closing of a conventional overhead garage door 12 of a garage 13. The garage door 12 is mounted on guide rails 14 for movement between the closed position illustrated in Fig. 1 and an open or raised position. The garage 13 includes a ceiling 16 and a wall 18 defining an opening blocked by garage door 12. As shown, guide rails 14 are mounted to wall 18 and ceiling 16 of the garage 13 in a conventional manner. A power drive unit or head, generally indicated at 20, is mounted to the ceiling 16 in a conventional manner. An integrated drive rail 22 extends between the power drive unit 20 and the garage wall 18. As can be seen in Fig. 1, one end of integrated drive rail 22 is mounted to a portion of the garage wall 18 located above the garage door 12. An operator arm 26 is connected at one end to the garage door 12 and at the other end to a trolley 94 mounted for movement back and forth, along the integrated drive rail 22. As will be seen herein, a motor in the power drive unit 20 propels the trolley 94 in a desired manner to raise and lower garage door 12 via the coupling of the trolley 94 and the operator arm 26 to the garage door 12. _A push button control unit 32, which includes an electronic controller and a keypad, is coupled by electrical conductors 34 to the power drive unit 20 and sends signals to the power drive unit, controlling operation of the drive motor therein. Preferably, the power drive unit 20 also includes a conventional radio receiver (not shown) for receiving radio signals from a remote control transmitter 38. An optional auxiliary power drive unit 40 is shown coupled to one end of integrated drive rail 22, being mounted on wall 18, atop door 12. If desired, operational flexibility of the integrated drive rail assembly may allow relocation of the main drive unit to a point adjacent the door. Referring now to Fig. 2, a barrier operator system employing an absolute position detector is employed for controlling the opening and closing of a conventional rolling shutter 112. The rolling shutter is mounted on guide rails 114 for movement between the closed position illustrated in Fig. 2 and an open or raised position. The wall 118 defines an opening blocked or covered by rolling shutter 112. As shown, guide rails 114 are mounted to wall 118 in a conventional manner. A power drive unit or head, generally indicated at 120, is mounted to the top of frame 110 in a conventional manner. Although the head unit is shown as being mounted on the exterior, as noted above, in many applications, the head unit is built into the wall so the user sees only the shutters. In the two views shown in Fig. 2, the head unit 120 is shown mounted on opposite sides of the top of frame 110. As will be seen herein, a motor in head unit 120 propels a sleeve or tube 142 to raise and lower rolling shutter 112 via the coupling of sleeve 142 to rolling shutter 112. Control for head unit 120 may be as described above for garage door operator 20, i.e., using a push button control or a Jceypad mounted at another location on a wall. Additionally, head unit may also include a conventional radio receiver (not shown) for receiving radio signals from a remote control transmitter. If desired, the head unit 120 may be mounted on either side of the frame 110. As shown in Figs. 3, 4 and 5, head unit 120 includes a tubular housing 138 and end section 122 and 134. Within the housing 138 is the motor 130 which includes an output shaft 131 coupled at one end to end section 134 and at the other end to driving gear assembly 132. The output from gear assembly 132 is provided to output ring 140, which is fixedly attached to outer sleeve 142. Rolling shutters are attached to outer sleeve 142, so that when motor 130 runs, outer sleeve 142 rotates, causing rolling shutters to open or close (depending on the direction of rotation of motor 130) . Outer sleeve 142 is also fixedly attached to ring 136 Ring 136 drives absolute position detector assembly 124. Position detector assembly 124 is coupled to control 'board 144. Control board 144 contains the electronics for starting and controlling motor 130 (see Fig. 11) . Capacitor 126 is used to start motor 130 (described below) . A brake 128 is provided to slow motor 130 when the rolling shutters are approaching a limit position. Referring to Figs. 6 and 7, absolute position detector assembly 124 includes a clock wheel 206, which is attached to axle 212 for rotation therewith. Axle 212 rests in supports 210, and freely rotates therein, which are attached to board 140 by legs 240. Clock wheel 206 includes 32 equally spaced openings 230. The clock wheel 206 provides a digital low pulse signal when the center of a data bit on the 32 teeth wheel 202 lines up with the center of a data bit on the 31 teeth wheel 204 and when these centers are in line with the IR sensors -- through an opening 230 (not shown) . The clock signal is provided to the microprocessor which uses the clock signal as an interrupt to sample binary data__from each data wheel. 32 bit wheel 202 is attached to axle 212 for rotation therewith. Each complete rotation of the 32 bit wheel 202 corresponds to one complete rotation of clock wheel 206. 32 bit wheel 202 includes 32 teeth or gears 220, which are driven by pinion 252 (see Fig. 4) which is driven by ring 136. 31 bit wheel 204 includes 31 teeth or gears 222 which are also driven by pinion 252. 31 bit wheel 204 freely spins about axle 202. One turn of the 32 bit wheel 202 corresponds to 32/31 turns of the 31 bit wheel 204. A unique bit stream pattern is formed in each of 32 bit wheel 202 and 31 bit wheel 204. Beneath the teeth 220 are solid areas 226 and spaces 224. A space under a tooth 220 corresponds to a 0; a solid area 226 correspond to a 1. The exact pattern is shown in Fig. 7. The first row of pulses are the 32 pulses generated by the clock wheel 206. One complete revolution of the clock wheel generates 32 low pulses, representing sample time. The 31 bit wheel has solid and spaces areas which correspond to a 31 bit data stream: 1111000001110100010010101100110 as shown in the . second row of Fig. 7. For every one complete revolution of the clock wheel, the 31 bit wheel produces the unique 31 bit data stream plus one rollover bit. The 32 bit wheel 202 generates the data stream: 11111000001110100010010101100110, which is the same pattern as the 31 bit data stream with the addition of an extra 1 at the beginning of the stream. This data stream is constant for every revolution of the clock wheel. In the 32 bit stream, no five consecutive bits are repeated anywhere else in the stream. This is true for the 31 bit data stream. When the unit is powered for movement, five consecutive (or sequential) bits are sampled from each wheel. The decimal value is calculated for each 5 bit number. The lookup table A (attached hereto) is used to convert the 5 bit number to a decimal number. Then a mathematical operation is performed on the two converted numbe_rs (from the 31 bit wheel and the 32 bit wheel) to produce an absolute position. Referring to Fig. 7, if the unit were powered up with the wheels aligned as shown in Fig. 7, the first 5 bit data stream sampled would be: 11110 for the 31 bit wheel and 11111 for the 32 bit wheel. In the next clock cycle, after rotation of 1/32 of the clock wheel a clock pulse is generated, the 31 bit wheel produces 11100 and the 32 bit wheel produces 11110. Continuing for 32 1/32 steps, or 32 5 bit frames, each sequential or consecutive 5 bit data stream produced by each wheel is unique . An example calculation is shown in Fig. 8. A 5 bit data stream is sampled from each of the 31 bit wheel and the 32 bit wheel. In this example, the 31 bit wheel produces the 5 bit data stream: 01000. The 32 bit wheel produces the 5 bit data stream 10101. These numbers convert to 08 (Lookupl) 21 (Lookup2) , respectively, using the lookup table A. 12-20 = -8. If the result is negative, add 31 (Same as modulo 31 arithmetic). Apply the mathematical formula: (Result x 32) + Lookup2 - Absolute position. This gives an absolute position of 756 out of 992 possible positions along the path of travel. The calculation of absolute position is performed in two interrupt routines by the controller. The first interrupt routine samples the clock and data wheels and generates the next bit to be used in the sliding window or sliding 5 bit data stream. When the clock wheel generates a digital low pulse, the controller executes the absolute position routine, shown in Fig. 9. Referring to Fig. 9, at step 300, the routine checks if the IR sensor and detector are operational. If the IR sensor and detector are not operational, the controller leaves the routine at step 318. If the IR sensor and detector are operational, the routine checks if the motor is on at step 302. If not, the routine O 00/49714 - 12 - exits at step 318. If the motor is on, the routine checks at step 304 if the clock pulse is going low, indicating the beginning of a clock pulse. If not, the routine exits at step 318. If the clock pulse is going low, the routine sets the state of the 31 bit wheel (WHEEL_31_STATE) register and the state of the 32 bit wheel state (WHEEL_32_STATE) register low in step 306. These registers store the value of the next detected data bit. At step 308, the routine checks if the 31 bit wheel stream is high. If yes, it sets the 31 bit state register to high in step 310. If not, it continues to block 312 where it checks if the 32 bit wheel stream is high. If yes, it sets the 32 bit wheel state register to high at step 314. If not, it calls the RPM routine, then leaves the routine at step 318. The RPM routine takes the current bit and uses it to create the next 5 bit data stream for use in calculating the absolute position of the shutter. Once the 5 bit streams are computed and stored, the controller computes the absolute position as described above and uses that information to keep track of where the door or shutter is at each clock cycle and as a validity check for direction of movement. It should be noted that if the awning, door or shutter is moved manually, movement of the door or shutter will drive the pinions moving the clock wheel and 31 bit wheel and 32 bit wheel, so door/shutter position is always mechanically recorded in the absolute position detector assembly, ready for reading when the unit is powered on. After the current bit from each wheel is stored in the appropriate register, the RPM routine is called. Referring to Fig. 10, at step 340, the routine checks for the direction of travel. This information is typically provided by the user input when the user selects the up button or down button. As noted above, this information can be verified changed if the absolute position information does not check out between successive clock pulses. If the shutter is moving up the routine branches to step 344. If the shutter is moving down, the routine branches to step 342. Each step 342 and 344 forms the appropriate sliding window (determines the consecutive 5 bits to be used in calculating the shutter position) . In step 344 the routine shifts ' the MASK_31 bits left. The MASK_31 bit mask is a window of all 31 bits the 31 bit wheel. Then the least significant bit of the MASK_31 is logically OR'd with the 31 bit wheel state register. Only the first 5 bits of the MASK_31 mask (which contains the entire 31 bit data stream represented on the 31 bit wheel) are masked. Then the MASK_32 bit mask (which contains the entire 32 bit data stream represented on the 32 bit wheel) is shifted left one bit and the least significant bit of the MASK_32 bit mask is logically OR'd with the value in the 32 bit wheel state register. Only the first 5 bits are masked. This gives two shifted 5 bit data streams, one each from the 31 bit wheel and the 32 bit wheel, which are used to determine the position of the shutter for that clock cycle. In step 342 the routine shifts the MASK_31 bits right. Then the 5th least significant bit of the MASK_31 is logically OR'd with the WHEEL_31_STATE register. Then only the first five least significant bits of the MASK_3l are masked. The MASK_32 mask is shifted one bit right. Then the MASK_32 mask is logically OR'd with the WHEEL_32_STATE register. In step 346 the routine uses a ROM- lookup table (see Table A) to get a conversion for the numbers in MASK_31 and MASK_32. These digital numbers are stored in the variables MASK_31_VALUE and MASK_32_VALUE. In step 348, the difference between MASK_31_VALUE and MASK_32_VALUE is calculated and the remainder from modulo 31 arithmetic calculated. This result is called the DIFFERENCE. In step 350 the DIFFERENCE is multiplied by 32. Then MASK_32_VALUE is added to the product. This number is the absolute O 00/49714 - 14 - position and is stored in the POS_CNTR. At step 354 the routine ends. __The controller uses the POS_CNTR value in controlling the operation of the shutter in its other routines, which are not described. A schematic of the control circuit located on control board 142 is shown in Fig. 11. Controller 500 operates the various software routines which operate the rolling shutter operator 120. Controller 500 may be a Z86733 microprocessor. In this particular embodiment, the rolling shutter is controlled only by a wall-mounted or unit-mounted switch coupled via connector J2. Connector J2 has inputs for up switched hot and down switched hot. In a rolling shutter, the motor moves only when the user presses the power direction switch connected to connector J2 and the Triac Ql is activated by the microcontroller. Pressing the up or down switch applies power to the board via connector J2 and provides various motor phase and direction information to the controller 500. When the controller 500 permits travel, Triac Ql enables the motor's neutral path. The motor winding, which is then powered, will conduct current . However, the control circuit can be modified to include a receiver so that the rolling shutter can be commanded from a remote transmitter (as described above) . Power supply circuit 190 converts AC line power from connector J2 into plus 5 volts to drive the logic circuits and plus 16 volts for a voltage supply to the phototransistors Q4, Q5, Q6. Upon receipt of a rolling shutter movement command signal through J2, the motor is activated. Feedback information from the motor and AC power is provided from Jl and applied to U3:A, U3:B, U3:C and U3:D. The outputs from U3:B and U3:D provide up and down phase information to pins P26 and P25 respectively. The outputs from U3:A and U3:C provide up and down direction to pins P21 and P20, respectively. Crystal CR1 provides an internal clock signal for the microprocessor 500. EEPROM 200 stores the information such as Limit flags, force flags, learn mode flags, etc. The IR signal break from clock wheel 206 drives Q5 which provides an input to signal P31. Wheel 31 drives Q4 which provides an input signal to P30. Wheel 32 drives Q3 which provides an input signal to P33. Table A attached hereto is the lookup table described above . Exhibit A (pages A1-A21) attached hereto include a source listing of a series of routines used to operate a movable barrier operator in accordance with the present invention. As will be appreciated from studying the description and appended drawings, the present invention may be directed to operator systems for movable barriers of many types, such as fences, gates, shutters, awnings, garage doors, overhead doors and the like. While there have been illustrated and described particular embodiments of the invention, it will be appreciated that numerous changes and modifications will occur to those skilled in the art, and it is intended in the appended claims to cover all those changes and modifications which fall within the true spirit and scope of the invention. T & A Last Modified Febuary 20, 1999. This is the Code for the Tubular Motor First Generation product. There is no force sensing. Get rid__of RAM TEST and CHECXSUK. Get rid of stop mode. Take out WDT. **** Equate Statements **** glob ls on P01H_INIT .equ 00000100B P2K_INIT .equ 01100011B P3M_INIT .equ O0OOCO01B P01S_INIT .e-ϊu 00001010B P2S_INIT . equ O0OO000OB P3S_INIT .equ OOC000003 P2M_EE0UT .equ 11111011B Mask for outputting data to EEPROK P2M--.EEIN .equ 00000100B Same for input ; GLOBAL REGISTERS ..*********************** * ****»***************************************«* **** ; LEARN EE GROUP REGISTERS FOR LOOPS ECT .****•****• *** •••*****•**••**•***••••*****«*********•****•******** * « * *** **** LEARNEE_GRP .equ 2OH P2M_SHA OW .egu LEARNΞE_GRP+0 Mask for mode of P2 TEMP •egu LEARNEE_GRP+2 MTEMPH . equ LEARKEE_GRPτ6 memory temp MTEMPL .equ LEARNEE_GRP-7 memory temp MTE P . equ LΞARNEE_GRP+8 memory temp SERIAL .equ LEΛRNEE_GR?+9 serial data to and from nonvol memory ADDRESS . eqύ LEAR EE_GRP+10 ; address for the serial nonvol memory temp .equ r2 mtemph .equ r6 memory temp mteπpl .equ r7 memory temp mterip .eσu r6 memory temp serial .eq-i r9 serial data to and from nonvol memory address .equ no address for the serial nonvol memory .**»*********»***»*.»**♦**.************************************** MAIN_GRP .equ 3 OH U?_LIMIT_H .eqa KAI _GRPτO ** upper limit high byte UP_LIKIT_L • equ MAIN_GR?+1 ** upper limit low byte UF_LIMIT .equ MAΓN_GRP+O upper limit word DOWN_LIMIT_H .equ MA:N_GRP+2 * w lower limit high byte DOWK_LIMIT_L .equ MAIN_GRP+3 ** lower limit low byte DOVJN_LIMIT • equ MAIN_GRP+2 lower limit word POS_CNTR_H .eqύ MAIN_GRP+4 position counter high byte P0S_CNTR_L .equ KAIN_GRP+5 position counter low byte P0S_CNTR • equ MAIN_GRP-r4 position counter POWER_LFC .equ MAIN_GRPτ6 power line sampler U?_LFC .equ MAIN_GR?+7 Up Line Filter counter DO N_LFC .equ MAIN_GRP+B Down Line Filter counter POWER_DEBOUNCER .equ MAIN_GRP+9 4ms in a row « power on UP_DEBOUNCER -equ MAIN_GRP+10 (A) up debouncer D0WN_DEBO * NCER .equ MAIN_GRP+11 (B) down debouncer UP_AKD_DOWN • egu MAIN_GRP+12 (C) 1 for up 2 for down OFF_LFC .equ MAIK_GRP+13 (D) 30ms β power off LF_TIMER .equ MAIN_GRP-t-14 (E) Line Filter Timer MOTOR_FLAG • equ MAIN_GRP+15 (F) AA Hex when motor on pos_cntr_h . equ r4 position counter high byte pos_cntr_l .equ r5 position counter low byte pos_cntr .equ rr4 position counter MAIN_GRP_2 .equ 4OK MASK_32 .equ MAIN. .GRP+16 (0) 5 bit mask of P33 stream MASK_31 .equ MAIN..GRP+17 (1) 5 bit mask of P32 stream MASK_32_VALUE .equ MAIN..GRP+18 (2) look up value for 32 bit wheel MASK_31_VALUE .e u MAIN..GRP+19 (3) look up value for 31 bit wheel LOOP_5 .egu MAIN..GRP+20 (4) loop counter MODULO . equ MAIN, .GRP+21 (5) gives mod of difference MASK_ADDRESS_H . eg 1 ; MAIN..GRP+22 (6) HB of address of lookup value. MASK_ADDRESS_L .ecu MAIN. GRP+23 (7) LB of address of lookup value. MASK ^ ADDRESS .equ MAIN..GRP+22 (6) address of lookup value. RPX_HIGK_DB .equ MAIN, .GRP+2 (6} rpm high debouncer RPM_L0W_DE . equ MAIN. GRP+25 (9) rpm low debouncer WHEEL_31_DB .equ MAIN, .GRP+26 (A) wheel 31 high db WHEEL_32_DB .equ MAIN..GRP+27 (B) wheel 31 high db BIT_31_STATE .eqα MAIN .GRP+28 (C) set to 17 when high BIT_32_STATE .equ MAIN..GRP+29 (D) set to 17 when high DIFFEREKCE .equ MAIN..GRP+30 (E) MASK l _32__VALUE-MASK_31_VALUE CLOCK_CYCLES .equ MAINι._GRP+31 (F) number of RPM interrupts. mask_32_value .eq r2 will contain looku value . mask_3l_value .equ r3 will contain lookup value. loop_5 .equ r4 (F) loop counter mask_address_h .equ r6 contains HB of address of lookup value roas _address_l .equ r7 contains LB of address of lookup value roas _address .equ rr€ contains address of lookup value. MAIN_GR?_3 . equ 50H DELAY_TIMSR .equ MAIN. .GRP+32 (0) timer for relay enable delay STOP_FLAG .eqa MAIN. .GRP-33 (1) tells main loop to stop START_FLAG .equ MAIN._GRP-r34 (2) flag for inc count flag LIMIT_FLAG .equ MAIN..GRPι-35 (3) ** 033H for up CCCH for down. UP_CUSHIOK_H .eqα MAIN._GR?÷36 (4) 100 positions past up limit UP_CUSHION_L .eqj MAIN..GRP+37 (5) 100 positions past up limit UP_CUSHION • equ MAIN_GRP+36 , (4) 100 positions past up limit DOWN__CUSHION_H .equ MAIN_GR?τ36 (6) 100 positions past down limit DO K_CUSHION_L .eqa MAIN_GRP-f39 (7) 100 positions past down limit -D0WK_CUSHI0N .eqj MAIN_GR?τ3S (6) 100 positions past down limit POS.-.CNTR^-.TEM? .equ MAIN_GRP+4C (8) temporary position value POS_CKTR_L_TEM? .equ MAIN_G?.P+4: (9) temporary position value POS_CNTR_TEMP .eqa MAIN_GRP+ 0 (8) temporary position value MASK_32_TEMP .egu MAIN_GRP-42 (A) temporary mask value MASK_31_TEMP .equ MAIN_GRP+43 (B) temporary mask value LEAR _FLAG .egu MAIN_GRP+44 (C) ** learn mode flag FREE_TRAVEL_FLAG .egu MAIN_GRP+45 (D) ** flag for free movement AlllntOn .equ MAIN_GRP+46 (E) sets up interrupts TAP_CNTR .eqa MAIN_GR?τ47 (F) .***********************»***************************.*********** CHECKER? .equ 8OH check_suιr_value .egu 03DH chec-k-_sum .equ rO ro-m_data .equ rl test_adr_hi .equ r2 test_adr_lo .egu r3 test_aά-r .eqa rr2 j********************.****************************************** STACKEND .egu 0A0H ; start; of the stack STACKTOP .eqα 23B ; end of the stack csh .equ 00010000B chip select high for the 93c46 cs .equ 11101111B chip select low for 93c46 clock .equ clock high for 93c46 clockl .equ 11110111B clock low for 93c46 αoh .eqα OOOC&IOCE data out high for 93c46 αoi . egu nm iiE άa-a out low for 93c46 psmask .eqα C1000000E mask for the program switch csport .egu ?2 chip select port dioport .equ P2 data i/o port cl port .equ P2 clock port psport .equ P2 program switch port MemoryTimer .eqa 96 WATCHDOG_GR0UP . equ OFH PCON .equ rO SMR .eqa rll WDTMR .equ rl5 FILL .macro .byte 0?Fh .enαm FILL10 .mac: .byte CFFh .byte OFFh .byte OFF •byte OFFh .byte OFFh • byte OFFh .byte CFFh .byte OFFh .byte OFFh .byte OFFh .endm FILL50 _ .macro .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte CFFh .byte OFFh • byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh •byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh •byte OFFh .byte OFFh •byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh •byte OFFh .byte OFFh .byte OFFh .byte OFFh •byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh .byte OFFh •byte CFFh .byte OFFh . endir. [ "RAP .macro p start DP stare p start _jp start jp start . endm TRAPIO .macro TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP .endm ; * Interrupt Vector Table .org 0000H .word FA SE_INT ;IRQ0, P3.2 .word FALSE_INT ;IRQ1, P3.3 .word FALSE_INT ; IRQ2 , P3.1 .word FALSE_INT ;IRQ3, P3.0 .word TIMEFC_I T ; RQ , TO .word FALSE_INT ;IRQ5, Tl .page .org 000CH jp START WKΞEL_TABLE: .byte 004H .byte C05K •byte 00EK .byte 0G6K .byte 00FH .byte C12K .byte 01AH .byte 007H .byte 00CK .byte 01OH .byte 013H .byte 015K .byte 017K .byte C1BH .byte OOSH .byte OIEH .byte 003H .byte GCDH .byte 011H •byte 019H •byte 00BH .byte 01 H .byte 016H .byte 01DH .byte 002H .byte 018K .byte 00AH .byte 01CH .byte 001H .byte 009H .byte 000H .byte 01FH . rg 0101H .********** * ★************* **********************.*******„********* ****** ; REGISTER INITILIZATION . *** * * ****** * ** ** *** ** *** ** ** *** *** ***** ** * ** * ** *** * **************** * ** * * start: START: di ; turn off the interrupt for init Id RP, # ATCHDOG_GROUP Id DTMR,#00000111B ; re dog 100ms. clr RP ; WDT ; kick the dog ; clear the register pointer xor P2, #100000003 ; toggle pin 3. . ******** . **** » ** * * ** ** .» * » ** « **** * *** **» * ***. **** ** *** * *** * * » * * * , ** *» * , * . * OR INITIALIZATION Id P01M,#P01M_IKIT set mode p00-p03 out p04-p07in Id P3M.#P3M_INIT set port3 p30-p33 input analog mode p3 -p37 outputs Id P2M,#P2M_INIT set port 2 mode Id P2M_SKADOW, #P2M_INIT Set readable register Id P0,#PC1S_INI? RESET all ports Id P2,#P2S_INIT Id P3,#P3S_INIT . ** * ** ** ** **** ** « ** * ** » ** *** ** * * • *** •** * * * •** ** *** ** **** *** * • ******** * * * * ;* Internal RAM Test and Reset All RAM = mS * jp STACK srp #0F0H ; POINT to control register group Id rl5, #4 ; rl5= pointer (minimum of RAM) wrιte_agam . OT kick the dog xor P2, #1CC00000B toggle pin 3. Id - rl4,#l wrιte_againl : 0,80 to memory cp rl5,#240 DP ult,write_again * Checksum Test * CHECKSUMTEST : srp #CHECK_GRP Id test_adr_hi,#CFH Id test_adr_lo. #0FFH ; maximum address=fffh adc sum: VOT ; kick the dog xor P2, #i:C0C0OCE ; toggle pin 3. ldc rom_data,&test_adr ;read ROM code one by one add check_sum,rom_data ;add it to checksum register decw test_aάr ;increment ROM address jp nz,add_suιr. ; address=0 ? cp check_sum, #check_sum_value jp z , systeιr._ok ; check final checksum = 00 ? system_error : and P0 , #11111011B ; turn on the led jp systeιr._error .byte 256-check_sum_value system_ok: DT ,- kick the dog xor P2, #10000000B ; toggle pin 3. Id STACKEND,#STACKT P start at the top of the stack SETSTACKLOOP : Id iSTACKEND, ?f01H ; set the value for the stack vector dec STACKEKD ; next address cp STACKEI ,*STACKEKD ; test for the last address jp nz , SETSTACKLOOP ; loop till done .*********** ************** ********,*.κ**********************»****** **** * ; "STACK INITILIZATION ;* * *»«**-^ ** ** * * ** ****** * • *** • * • * * * •• • * ***•* . ** „,,» • » * »» *** «» * ** .-** * ,, * STAC : WDT ; KICK THE DOG xor P2, #10000000B ; toggle pin 3. clr 254 Id 255, #238 ; set the start of the stack .***************************************************»***,**.,*****,***** * ; -TIMER INITILIZATION j *********************************************************************** TIMER: Id PREO,#00010001B set the prescaler to 1/4 for 250Kh2 Id TO, #0FAH set the counter to count 250 to 0 CT0=lms) Id PRE1,#11111111B set the prescaler to 1/63 for 16Khz Id Tl, #0F?H set the counter to count 255 to 0 (Tl*16ms) Id TMR,#0000C111B turn on the TO timer. .**,***************«*«********* * ******** * **** * ..************************ * ;*PORT INITIALIZATION . ***** **********ww******w************< ****************»************w**** Id P01M, #PC1M_INIT set mode p00-p03 out p04-p07in Id P3M,#P3M_INIT set port3 p30-p33 input analog mode p34-p37 outputs Id P2M,#?2M__INIT set port 2 mode Id P2M_SHADOW, #P2M_INIT Set readable register Id P0,#P01S_INIT ESET all ports Id P2,#P2S_INIT Id P3,#P3S_INIT .****«************************»*******•* * *«***«* * *»******************»** * ; INITERRUPT INITILIZATION »************** *******w****»******************************************* SETINTERRUPTS : Id IPR, #001011013 ; set the priority to RPK Id IMR,#01010000B ; set IMR for TO interrupt only Id IRQ,#11000000B ; set the edge clear int .*•*» * **..****•** * ***•*.,**********,,,,**********,********,-, ***,*******, * ; SET SMR & PCON .****** * » * *« * *****. * ***«» * **********»»»**********.****** » * » ***** » ** » ***- > Id RP, #WATCHDOG_GROUP Id SMR, #000111103 ; recovery source = P2 NOR 0:7 Id PCON, #100101103 ; reset the peon no comparator output ; STANDARD emi mode clr RP ; * * *• * ******* * * * *** * ** * ** *********** * ************ * ; VARIALBE INITILIZATION ; * * * ****** ** * *.» ** *» *** * *** * * **** *** * * * * * ** ** * *»** * * ** ******* * ** * *,***** * WDT ; KICK THE DOG ; xor P2, #10000000B ; toggle pin 3. Id POS_CNTR_H, #00 Id P0S_CNTR_L, #00 Id LF_TIMER, #00 Id OFF_LFC, #00 Id UP_LFC, #00 Id DOWK_LFC, #00 Id POWER_LFC, #00 Id MOTOR_FLAG,#00 Id DELAY TXMER, #00 Id STOP_FLAG, #00 Id S7ART_FL-AG, #C0 Id UP_-AND_DONN- #C0 Id P0 ---R_DE30UNCE , #00 Id UF_DEEOUNCΞR, #00 d DOW _DΞBOUNCEΛ, #00 Id TAP_CNTR. #00 Id MASK_32, #00 Id MA≤K_31, #00 Id MASK_32_VALUE, #00 Id MASK_31_VALUΞ, #00 Id DIFFERENCE, #00 Id COCK_CYCLES , #00 Id FREE_TRAVEL_FLAG, #C0 Id LIMIT_FLAG, #00 Id UP_CUSHION_H, #00 Id UP_CUSHION_L, #00 Id DO K_CUSHION_H, #00 Id DOWN-_CUSHION_L, #00 Id POS_a.TR_H-.TEMP, #00 Id POS_CNTR__TEMP, #00 Id MASK_32_TΞKP- #00 d MASK_31_T---MP, #00 Id RPM_HIGK_DB, #11 Id RPM_LO_DB, #00 Id WHEEL_31_DB, #00 Id WHEEL_32_DB, #00 Id BIT_ 1_STATE, #00 ld BIT_32_STATE , #00 Id LEAR2C_FLAG, #02 Id UP_LIMIT_H, #02K Id " UP_LIMIT_L, #02BH Id DOWN_LIMIT_H, #01K Id DOWK_LIMIT_L, #0DBH Id AlllntOn, #01010000B just enable timer at first ; WDT ; KICK THE DOG ; xor P2, #100000003 ; toggle pin 3. .A***** * ******* * *********** * * * ** * ******************* ******„*** ** ** ****** * ; READ THE MEMORY 2X .********** ** ***************************** • ***********,*************,,*** ei AIT_BEFORE_READING : call WAIT_40_MS nop WDT ; KICK THE DOG ; xor ?2, #10000000E ; toggle pin 3. ADDRESS 00 UP_LIMIT ADDRESS 01 DOWN_LIMIT ADDRESS 02 LIMIT_FLAG ADDRESS 03 TAP_CNTR ADDRESS 04 LEARN_FLAG ADDRESS 05 FREE_TRAVEL_FLAG WDT ; KICK THE DOG xor P2, #10000000B ; toggle pin 3. THIS IS THE TIMERO (HEARTBEAT) INTERRUPT ROUTINE Direction for counter is the LSB of the state TIMERC_IKT : Id IMR, AlllntOn turn on all the interrupts t P0, #C00C1C00E are IR's on? : ' p nz, CKECK_START_FLAG if not, then jump cp MOTOR_FLAG, #CAAH is motor on? DP ne, CHECK_START_FLAG xor P0, #000000103 toggle pin for motor CHECK_START_FLAG : i c DELAY_TIME?. increment timer. cp START_FLAG, #01 ready to check inputs? jp ne, TIMERC_RETUR-U if not, leave. tm P2, #00100000B is POWER (P25) high? jp— z, INC_OFF_LFC if not, don't sample up/dn pins, clr OFF_LFC inc POWFJ LFC else, increment TOTAL_LFC. TEST MOTOR: cp MOTORS-LAG, #0AAK is motor on? jp eq, TIMER0_RETURM if so, jump. tm P2 , #0000001CB is up (P21) input high? jp z , TEST_DOWN_LFC if not, don't inc UP_LFC. inc UP_LFC else, increment DOWN_LFC. jp TEST_POWER_LFC TEST_DOWN_LFC : tm P2, #00000001B is down (P20) input high? jp z, TEST_POWER_LFC ; if not, don't inc UP_LFC. inc DOWN_LFC increment DOWN_LFC jp TEST_POWER_LFC INC_OFF_LFC : inc OFF_LFC increment OFF COUNTER clr UP_LFC clear up counter clr DOWN_LFC clear down counter clr POV,ΕR_LFC clear power counter cp OFF_LFC, #22 is counter at 22ms? DP eg, CHECK_FOR_POWER if so, then ump. DP TIMERC_RETURN TEST_POWER_LFC : cp POWER_LFC, #03 is POWER ^ LFC more than 03? jp ne, TIME _RETURN if so, leave interrupt cp POWER DEBOUNCER, # 2 is DB already at 22? jp eg, CHECK_UP_LFC if so, don't increment inc POWER_DEBOUNCER else, increment POWER DB cp POWER W DEBOUNCER, #03 is UP DB at 3? jp ne, CHECK_U?_LFC if not, jump. inc TA?_CNTR else, increment TA?_COUNTER jp CHECK_UP_LFC and jump. CHECK_UP_LFC: cp UP_LFC, #03 is UP LFC at 3? • jp ult, CHECK_DOW_LFC if not, jump. cp UP_DEBOUNCER, #255 is UP DB maxed out. jp eq, SET_UP_AND_DOWN_FLAG ; if so, jump. clr D0WN_DE30UNCER ; clear debouncers inc UP_DEBOUNCER ; increment db cp U?_DEBOUNCER, #22 ; if at 22, then set high. jp ne, SET_UP_AlTO_DOW._FI-AG , else, skip. Id U?_DE30UNCER, #255 ; Id DB with 255. clr TAP_CNTR ; clear TAP COUNTER CKEC-K_.DOWN_L?C : out . cp DOWK_DEBOUNCER, #22 if at 22, then set high. jp ne, SET_U?_AND_DOWN_FLAG ; else, skip. Id D0WN_DE30UKCER, #255 ; Id DB with 255. clr TA?_CNTR clear TAP_COUNTER jp SET_UP_AKD--.DOWN_FLAG CKECK_FOR_POKE : clr OFF LFC reset off counter clr U?_DΞBOUKCER clear DB's Clr DOWK_DEBOUNCER cp POWER_DEBOUNCER, #03 is DB aready zero? jp uge, CLEAR_LINE_DBS if so, don't write clr POWER_DEBOUNCER clear power debouncer jp TIMER0_RETURN CLEAR ^ LINE.DBS : clr P0WER_DE30UNCER clear power debouncer Id STOP_FLAG, #01 set stop flag, and TMR,#11111101B disable timer 0 ; WRITE TO MEMORY — TAP_CNTR Id ADDRESS, #03 POINT TO ADDRESS THAT CONTAINS TAP_CNTR Id MTEMPK, TAP_CN7?. load temp register with TAP_CNTR byte Id MTEMP1, #CC load temp register with 00. nop call WRITEMEMORY or TMR,#OOOC0010B enable timer 0 DP TIMER0_RETURN SET_UP_AND_DOWN_FLAG: cp DOWN_DEBOU CΞR, #255 is DOWN DB high? jp eq, SET_DOWK_FLAG if so, set down flag cp UP_DEBOUNCER, #255 is UP DB high? jp ne, TI ERO.RETURN if not, leave interrupt Id UP_AND_DOWK, #01 else, set direction for up D TIMER0_RETURK leave interrupt. SE_DOWN_FLAG : Id UP_ΛND_DOWN, #02 else, set direction for down TIMERO RETURN : iret TKIS IS THE MOTOR RPM FALLING EDGE INTERRUPT ROUTINE IT CONVERTS THE SAMPLED BITS OF P33 AND P32 INTO TWO 5-BIT MASKS AND LOOKS UP A VALUE FOR EACH MASK. THEN PERFORMS A MATKMATICAL OPERATION ON THESE VALUES TO GET AN ABSOLUTE POSITION. RPM: ; motor speed UP_AND_DOKN, #01 are we going in up dir? DP eq, UP_DIR if so, then jump to UP_DIR routine else, check down dir cp U?_AND_DOWN, #02 are we going in down dir? DP eq, DOWN_DIR if so, then jump to DOWN_DIR routine ret else, return DOWN_DI : cp CLOCK_CYCLES, #05 ; has there been 5 clocks? jp eq, LOAD_DOWN_TEMPS inc CLOCK_CYCLES LOAD_DOWN_TEMF≤ : Id MASK_32_TEMP, MASK_32 Id MASK_31_TEMP, MASK_31 cp POS_CNTR_H, #00 jp ne, SET_DOWN_TEMP cp POS_CNTR_L, #00 jp ne, SET_DOWN_TEMP Id POS_CNTR_H_TΞKP, #03K Id POS_CNTR_L_TEKP, #0DFH jp GET_DOVK_POSITION SET_DOWN_TEMP : Id POS_CNTR_H_TEMP, POS_CNTR_H Id POS_CNTR_L_TEKP, P0S_CNTR_L decw POS_CKTR_TEK? GET_DOWN_POSITIO : call SKIF _BITS_RIGHT nop call GET_POSITION nop decw POS_CNTR ; !subtract 4 to get the true decw POS_CNTR ; ivalue of the absolute position decw POS_CNR ; ;in the down direction. decw POS.CNTR cp P0S_CNTR_H, #0FFH make sure no roll over occurred P ne, DOWN_VALID_CHECK if so, fix it. Id POS_CNTR_H, #03H set upper byte correct . add POS_CNTR_L, #0E0K adjust roll over value. DOV-N_VALID_CHECK: cp CLOCK_CYCLΞS, #05 ; has there been 5 clocks? jp ne, RPM_RETURN cp POS_CKTR_H, POS_CNTR_H_TEMP jp ne, RESTORE_DOWN_MASKS cp POS_CNTR_L, POS_CNTR ^ L_TEMP jp ne, RESTOR£_DOWK_MASKS jp RPM_RETURN RESTORΞ_DOWN_MASKS: Id MASK_32, MASK_32_TEM? Id MASK_31, KASK_31_TEMP incw POS.C TR TE P cp POS_CNTR_K_TEMP, #03H jp ne, RESTORE_DOWN_POS cp POS_CNTR--.L_T-.-MP, #0E0H jp ne, RESTORΞ_DOWN_POS Id POS_CNTR_H, #00H Id ?OS_CNTR_L, #00H jp RPΪ-L.RETURN RESTORS_DOWN_POS: Id POS_CNTR_H, POS_CNTR_H_TEMP Id POS_CNTR_L, PO≤_CNTR_L_TEMP jp RPM_RETURN UP_DIR: cp CLOCK_CYCLES, #05 ; has there been 5 clocks? jp eg, LOAD_UP_TEMPS inc CLOCK ^ CYCLES LOAD_UP_TΞMPS : Id MASK_32_TEMP, MASK_32 Id MASK_31_TEM?, MASK_31 cp POS_CNTR_H, #03 DP ne, SET_UP_TEM? cp POS_CNTR-_L, #0DF jp ne, SET_UP_TE P clr POS_CNTR-_H_TEMP clr POS_CNTR_L_TEMP jp GET_UP_POSITION SET_UP_TEM?: Id POS_CNTR_H_TEMP, POS_CNTR_H Id POS_CNTR_L_TEK?, POS_CNTR_L incw POS_CNTR_TEMP GET_UP_POSITION: call SKIFT_BI?S_LEF7 nop call GET_POSITION nop UP_VALID_CHΞCK: cp CLOCK_CYCLES , # 05 ; has there been 5 clocks ? jp ne , RPM_RETURN cp POS_CNTR_K, POS_CKTR_K_TEKP jp ne , RESTORΞ_UP_MASKS cp POS_CNTR_L, POS_CNTR_L_TEM? jp — e , RESTORE_U?_MASKS DP RPK-.RETURN RPM_RETURN: OUTPUT THE DIFFERENCE - WHICH IS THE ABSOLUTE REVOLUTION OUTPUT THE ABSOLUTE POSITION ret RESTORΞ_UP_MASKS : Id MASK_32, MASK_32_TEM? Id MASK_31, MASK_31_TEMP decw POS_CNTR_TEMP cp POS_CKTR_H_TEMP, #0FFH jp ne, RESTORE_UP_POS Id POS_CNTR_H, #03H Id POS_CNTR_L, #0DFK jp RPM ^ RETURN RESTORE_UP_POS : Id POS_CNTR_H, POS_CNTR_H_TEM? Id POS_CNTR_L, PO≤_CNTR_L_TEKP jp R?K_RETUR SHOULD NOT BE HERE FALSE_INT: and AlllntOn, #11010000B ; turn off all interrupts except TO. iret .* * ****»*»****** * ************* * ********* * ************ * ****************** * ,- THIS ROUTINE SHIFTS MASK_32 AND MASK ^ 31 BITS LEFT ; AND WRITES THE SAMPLED DATA IN THE LSB OF EACH MASK .* * ************ *** ********* ** »******************************** * ********* SHIFT_BITS_LEFT: rl MASK_32 ; shift bits left and MASK_32, #00C11110B ; use only the first five digits rl MASK_31 shift bits left and MASK_31, #00011il0B use only the first five digits and BIT_32_STATE, #C0;CCC01B leave LSB HIGH and BIT_31_STATE, #00000001B leave LSB HIGH or MASK_32, EIT_32_STATE set LSB or MASK_31, 3IT_31_STATE set LSB SB .RETURN : ret ********************* ************************************************** THIS ROUTINE SHIFTS MASK_32 AND MASK_31 BITS RIGHT AND WRITES THE SAMPLED DATA IN THE LSB OF EACH MASK ********************************lTW*W**W**********<************ιr********ι SHIFT_BITS_RIGH : rr MASK_3 shift bits right and MASK_32, #00001111B use only the first five digits rr MASK_31 shift bits right and MASK_31, #00OCllllB use only the first five digits and BIT_32_STATE, #000100003 leave MSB HIGH and BIT_31_STATE, #00010000B leave MSB HIGH or MASK_32, BIT_32_STATE set MSB or MASK_31, BIT_31_STATE set MSB SBRJRΞTURN: ret • ************w***+ww***»** ************ ********************************** WRITE WORD TO MEMORY ADDRESS IS SET IN REG ADDRESS DATA IS IN REG MTEMPK AND MTEMPL RETURN ADDRESS IS UNCHANGED GET_POSITION: nop push RP nop srp #4OH nop Id mask_address_h, #HIGH WHEEL_TABLE Id mask-_address_l, #LOW WKEEL_TABLE add mask_address_l , KASK_32 adc mask_address_h, #00K ldc mask_32_value, imask_address Id mas _address_h, #HIGH WHEE1 TABLE ld maεk_address_l , #LOW WHΞEL TABLE add mask_address_l , MASK_31 adc mask_.address_h, #00H dc mask_31_value, θmask_address nop pop " RP nop Id DIFFERENCE, MASK_31_VALUE sub DIFFERENCE, MASK_32_VALUE cp DIFFERENCE, #00 is DIFFERENCE negative? DP ge, MULTIPY_MODULO add DIFFERENCE, #31 MULTIPLY_MODULO: Id MODULO, DIFFERENCE MODULO is now positive clr POS_CNTR_H Id POS_CNTR_L, MODULO Id LOOP_5, #05 push RP MULTIPLY_BY_32: srp #3OH rl pos_cntr_h shift bits of POS_CNTR left rl pos_cntr_l 5 times = X32. adc pos_cntr_h, #00 add any carry to high byte and pos_cntr_l, #11111110B kill any reload carry. srp #4OK cjnz loop_5, MULTIPLY_BY_32 pop RP add POS_CNTR_L, MASK_32_VALUE else, add mask 32 value adc POS_CNTR_H, #00 add any carry to high byte ret . * .- ** »*** ** . * » ** ..* *** * ** ». * . ** , ** « * ... ** * ** .,» **** **,* ** . * »* * * * » ****** * THIS ROUTINE TURNS ON THE TRIAC ; RELAY OF APPLIED POWER . *** * * *« * -» ** *« * « *** »* * « * * * «****** ** »* * «»»** * *****. * ***** * *,**»**,».**,» * TURN_ON_MOTO : cp U?_AND_DOWN, #01 jp eq, SET_MOTOR_FLAG cp UP_AND_DOWN, #02 jp ne, START SET_KOTOR FLAG : Id MOTOR_FLAG, #0AAH and P0, #11110111B turn on IR's ei WAI?_FOR_FULL_CYCLΞ: cp P0WER_DE30UNCER, #00 jp eq, CLEAR_DB_AND_JUMP cp RPK_KIGK_DB, #09 jp ne, WAIT_FOR_FULL_CYCLE Id RPM_HIGK_DE, #11 clr RPM_LOW_DB clr WHEEL_31_DB clr WHEEL_32_D3 clp- CLOCK_CYCLES WAIT_5_CLOCKS : ; WDT xor P2, #100000003 toggle pin 3. cp STOP_FLAG, #01 DP eg, MOTOR_RETURN cp CLOCK_CYCLE≤ , #05 ; position found after 5 clocks P ult, WAIT_5_CLOCKS MOTOR ^ RETURK: ret .******»***»**********.****«**********.»********.*** » *****..*****.**„** ♦ * ; THIS ROUTINE TURNS OFF THE MOTOR OF APPLIED POWER ; AND WAITS UNTIL THE POWER IS RELEASED. TURN_OFF_MOTOR: di or P0, #C0001000B ; turn off IR's clr MOTOR_FLAG or PO, #00000010B •et state high WDT KICK THE DOG xor P2, #10000000B toggle pin 3. cp P0WΞR_DEBOUNCER, #GC see if released P ne, TURN_OFF_MOTOR if not, then keep checking ret ROUTINE WAITS FOR 40m≤ TO PASS. THEN RETURNS. WAIT_40_MS: clr DELAY ΓIKER LOOP_TILL_40: WDT xor P2, #10000000B toggle pin 3. cp DELAY riMΞR, #40 wait 40ms before turning on DP ne, LOOP_TILL_40 interrupts . ret • ********************************************************************** ; WRITE WORD TO MEMORY ADDRESS IS SET IN REG ADDRESS DATA IS IN REG MTEMPH AND KTEMP RETURN ADDR UES-5S-3 ISb U--Nf.C-.'Ht---AANNGl-iE---DL. ** ** ******** ** * ******* * ** ** ******************************************** WRITEMEMORY: WDT xor P2, #1CC00000B toggle pin 3. push RP SAVE THE RP srp # EARNΞE_GRP ; set the register pointer call STARTB ; output the start bit Id serial, #00110000B set byte to enable write call SERIALOUT output the byte and csport,#csl reset the chip select call START3 ; output the start bit Id serial, #0100C000B set the byte for write or serial, address ; or in the address call SERIALOUT output the byte Id serial,mtemph ; set the first byte to write call SERIALOUT output the byte Id serial,mterr.pl ; set the second byte to write call SERIALOUT output the byte call EKDWRITΞ wait for the ready status call STARTB ; output the start bit Id serial, #000000003 set byte to disable write call SERIALOUT output the byte and csport, #csl reset the chip select pop RP reset the RP ret ,**************************************************************** * *****« EAD WORD FROM MEMORY ADDRESS IS SET IN REG ADDRESS DATA IS RETURNED IN REG MTEMPH AND MTEMPL ADDRESS IS UNCHANGED ****»** * ******** * * * ******************* * ********************* * * * *- READMEMORY: push RP srp #LEARNEE_GRP set the register pointer call STARTB output the start bit Id serial, #1000C00CB preamble for read or serial , address or in the address call SERIALOUT output the byte call SERIALIN read the first byte Id mtemph, serial save the value in mtemph call SERIALIN read teh second byte Id mtβrnpl, aerial save the value in mtempl and csport, #csl reset the chip select pop RP ret STARTB: and csport, #csl and clkport,#clockl start by clearing the bits and dioport, #dol and P2M_SHADW,#P2M_EEOUT set port 2 mode output mode data Id P2M, P2M_SHAD0W or csport , #csh set the chip select or dioport, #doh set the data out high or ~~ clkport,#clockh set the clock and clkport, #clocki reset the clock low and dioport, #dol set the data low ret return j ******************************************************** *************** * • END OF CODE WRITE ;*»* * *** * »»****** * **************»»**************************»*•********** ENDWRITE; di and csport, #csl reset the chip select nop delay or csport, #csh set the chip select or P2M_SHAD0W, #P2M_EEIN set port 2 mode input mode data Id P2M, P2M_SHADOW clr Me oryTimer ENDWRITELOO?: ei cp MemoryTimer, #12 ; test for 12mS passed JP ugt ,MemoryTiir-eOut Id mte , dioport ; read the port and mtemp, #doh ; mask jp z ,ENDWRITELOOP ; if bit is low then loop till we are done MemoryTimeOut : and csport, #csl reset the chip select and P2N_SHAD0V,#?2N ^ EE0UT set port 2 mode forcing output oαe Id P2K, P2M_SKADOW ret .************************«******************************** **** #» w*-rw SERIAL OUT OUTPUT THE EYTE IN SERIAL SERIALOU : and P2M_SHADOW, #P2 _EEOUT set port 2 mode output mode data Id P2M, P2M_SHADOW Id mtemp, #8H set the count for eight bits SΞRIALOUTLOOP : rlc serial ; get the bit to output into the carry jp nc, ZEROOU1 ; output a zero if no carry ONEOUT: or dioport, #doh set the data out high or clkport, #clockh set the clock high -and clkport,#clockl reset the clock low •and dioport , #dol reset the data out low djnz mtemp, SERIALOUTLOO? loop till done ret return ZEROOUT: and dioport, #dol reset the data out low or clkport, #clockh set the clock high and clkport, #clockl reset the clock low and dioport, #dol reset the data out low djnz mtemp, SERIALOUTLOO? loop till done ret return , *********************************************************** ************ SERIAL IN INPUTS A BYTE TO SERIAL SERIALIN: or P2M_SHADOW, #P2-M_EEIN set port 2 mode input mode data Id P2M. P2M_SHADOW Id mtemp, #8H set the count for eight bits SERIALINLOOP: or clkport, #clockh set the clock high rcf reset the carry flag push mtemp save temp Id mtemp, dioport read the port and mtemp, #doh mask out the bits jp z,D0NTSET scf set the carry flag DONTSET: pop mtemp reset the tes-ip value rlc serial get the bit into the byte and clkport, #ciockl reset the clock low djnz mtemp, SERIALINLOOP loop till done ret return

Claims: O 00/49714 _ _ _ -38- What is claimed is: __ 1. A barrier operator position detector, comprising: a first rotary member encoded to generate a first five bit subcode selected from five sequential bits of a 32 bit code word, the first five bit subcode having the property that every selected subcode of five sequential bits of the 32 bit code word has a unique value; a second rotary member encoded to geneiate a second five bit subcode selected from five sequential bits of a 31 bit code work, the second five bit subcode having the property that every selected subcode of five sequential bits of the 31 bit code work has a unique value; and a controller, responsive to the first subcode and the second subcode, for generating a ten bit multibit subcode, wherein the ten bit multibit subcode is representative of a unique position output, the position output being reflective of a position of the barrier in its travel. 2. A barrier operator position detector according to claim l, further comprising a clock member for generating a timing signal, wherein the controller, responsive to the timing signal, samples the first subcode and the second subcode . 3. A barrier operator position detector according to claim 2, wherein the clock member comprises a light emitter, a light receiver and a rotary interrupter mechanism disposed there between for selectively interrupting transmission of light from the light emitter to the light receiver, wherein the timing signal is generated upon interruption of the light transmission. 4. A barrier operator position detector according to claim 2, wherein the first rotary member further comprises 32 geared teeth and wherein the second rotary member further Λ ----,.. « .„ Λ O 00/49714 -39- comprises 31 geared teeth, the gears being adapted for being drivingly connected to a shaft for rotation. 5. A barrier operator position detector, comprising: a first rotary member encoded to generate a first N bit subcode selected from N sequential bits of a M bit code word, the first N bit subcode having the property that every selected subcode of N sequential bits of the M bit code word has a unique value, where N is greater than 1 and M is greater than N; a second rotary member encoded to generate a second N bit subcode selected from N sequential bits of a M-l bit code work, the second N bit subcode having the property that every selected subcode of N sequential bits of the M-l bit code work has a unique value; and a controller, responsive to the first subcode and the second subcode, for generating a 2N bit multibit code, wherein the 2N bit multibit subcode is representative of a unique position output, the position output being reflective of a position of the barrier in its travel. 6. A barrier operator position detector according to claim 5, further comprising a clock member for generating a timing signal, wherein the controller, ^ responsive to the timing signal, samples the first subcode and the second subcode . 7. A barrier operator position detector according to claim 6, wherein the clock member comprises a light emitter, a light receiver and a rotary interrupter mechanism disposed there between for selectively interrupting transmission of light from the light emitter to the light receiver, wherein the timing signal is generated upon interruption of the light transmission. O 00/49714 -40- 8. A barrier operator position detector according to claim 6, wherein the first rotary member further comprises M geared teeth and wherein the second rotary member further comprises M-l geared teeth, the gears being adapted for being drivingly connected to a shaft for rotation. 9. A movable barrier operator, comprising: a motor; a transmission connected to the motor to be driven thereby and to the movable barrier to be moved; a barrier operator position detector, comprising: a first rotary member encoded to generate a first N bit subcode selected from N sequential bits of a M bit code word, the first N bit subcode having the property that every selected subcode of N sequential bits of the M bit code word has a unique value, where N is greater than 1 and M is greater than N; and a second rotary member encoded to generate a second N bit subcode selected from N sequential bits of a M-l bit code work, the second N bit subcode having the property that every selected subcode of N sequential bits of the M-l bit code work has a unique value; and a controller, responsive to the first subcode and the second subcode, for generating a 2N bit multibit code, wherein the 2N bit multibit subcode is representative of a unique position output, the position output being reflective of a position of the barrier in its travel. 10. A movable barrier operator according to claim 9, wherein the position detector further comprises a clock member for generating a timing signal, wherein the controller, responsive to the timing signal, samples the first subcode and the second subcode. 00/49714 -41- 11. A movable barrier operator according to claim 10, wherein the clock member comprises a light emitter, a light receiver and a rotary interrupter mechanism disposed there between for selectively interrupting transmission of light from the light emitter to the light receiver, wherein the timing signal is generated upon interruption of the light transmission . 12. A movable barrier operator according to claim 9, wherein the first rotary member further comprises M geared teeth and wherein the second rotary member further comprises M-l geared teeth, the gears being adapted for being drivingly connected to a shaft for rotation. 13. A movable barrier operator according to claim 12, wherein the motor includes an output shaft, the M and M-l geared teeth being drivingly connected to the motor shaft. 1 . A movable barrier operator according to claim 13 , further comprising a common pinion driven by the motor shaft and engaging each gear of the first and second rotary members . 15. A movable barrier operator according to claim 9, further comprising an input device for commanding movement of the barrier in one of two directions and wherein the controller, responsive to the input device, stores direction of travel of the barrier. 16. A barrier operator position detector, comprising: a first rotary member, responsive to movement of the barrier, encoded to generate a first N bit subcode selected from N sequential bits of a M bit code word, the first N bit subcode having the property that every selected subcode of N O 00/49714 _ 42 - sequential bits of the M bit code word has a unique value, where N is greater than 1 and M is greater than N; __ a second rotary member, responsive to movement of the barrier, encoded to generate a second N bit subcode selected from N sequential bits of a M-l bit code work, the second N bit subcode having the property that every selected subcode of N sequential bits of the M-l bit code work has a unique value; and a controller, responsive to the first subcode and the second subcode, for generating a 2N bit multibit code, wherein the 2N bit multibit subcode is representative of a unique position output, the position output being reflective of a position of the barrier in its travel. 17. The barrier operator position detector of claim 16, wherein the first and second rotary members are responsive to a shaft rotation of the barrier. 18. The barrier operator position detector of claim 16, further comprising a clock member, responsive to movement of the barrier, for generating a timing signal, wherein the controller, responsive to the timing signal, samples the first subcode and the second subcode.

Inventors: RATHGEBER MARTIN, SIEGLER MARK, SMITH ALAN DANE, VALENTE CHRISTOPHER M, RATHGEBER, MARTIN, SIEGLER, MARK, SMITH, ALAN, DANE, VALENTE, CHRISTOPHER, M.
Applicants: CHAMBERLAIN GROUP INC, THE CHAMBERLAIN GROUP, INC.
Application year: 2000
Main classification: H03K13
IPC codes: D05C15, E05F15, G01D5, G05B11, H01S3, H03K3, H03K17, H03M1