Login| Sign Up| Help| Contact|

Patent Searching and Data


Title:
METHOD AND APPARATUS DETERMINING POSITION OF A MOVABLE BARRIER
Document Type and Number:
WIPO Patent Application WO/2000/049716
Kind Code:
A1
Abstract:
A movable barrier operator 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.

Inventors:
Smith, Alan Dane (1665 Calle de Carinosa Sahuarita, AZ, 85629, US)
Valente, Christopher M. (161 W. Jackson Elmhurst, IL, 60126, US)
Rathgeber, Martin (1551 W. Thomas Street Chicago, IL, 60622, US)
Siegler, Mark (4421 Deyo Street Brookfield, IL, 60513, US)
Application Number:
PCT/US2000/003971
Publication Date:
August 24, 2000
Filing Date:
February 16, 2000
Export Citation:
Click for automatic bibliography generation   Help
Assignee:
THE CHAMBERLAIN GROUP, INC. (845 Larch Avenue Elmhurst, IL, 60126, US)
Smith, Alan Dane (1665 Calle de Carinosa Sahuarita, AZ, 85629, US)
Valente, Christopher M. (161 W. Jackson Elmhurst, IL, 60126, US)
Rathgeber, Martin (1551 W. Thomas Street Chicago, IL, 60622, US)
Siegler, Mark (4421 Deyo Street Brookfield, IL, 60513, US)
International Classes:
D05C15/24; E05F15/10; G01D5/34; G05B11/00; H01S3/06; H03K3/00; H03K17/94; H03M1/28; D05C15/00; E05F15/10; G01D5/26; G05B11/00; H01S3/06; H03K3/00; H03K17/94; H03M1/22; (IPC1-7): H03K17/94; G01C5/34
Attorney, Agent or Firm:
Samples, Kenneth H. (Fitch, Even Tabin & Flannery Room 1600 120 South LaSalle Chicago, IL, 60603, US)
Download PDF:
Claims:
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 generate 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 1, 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 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 M1 bit code work, the second N bit subcode having the property that every selected subcode of N sequential bits of the M1 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.
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 M1 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 M1 bit code work, the second N bit subcode having the property that every selected subcode of N sequential bits of the M1 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.
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 M1 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 M1 geared teeth being drivingly connected to the motor shaft.
14. 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 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 M1 bit code work, the second N bit subcode having the property that every selected subcode of N sequential bits of the M1 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.
19. A barrier operator position detector, comprising: a circuit for generating a unique nonrepeating binary serial stream and windowing said serial stream to determine the barrier operator's position.
20. A barrier operator position detector according to claim 19, wherein said apparatus for generating a unique nonrepeating binary serial stream comprises: a device encoded to generate a subcode having a unique value; and a controller responsive to said subcode and further capable of generating a subcode representative of a unique position output which is reflective of a position of the barrier in its travel.
21. A barrier operator position detector according to claim 20, wherein said encoded device further comprises: 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; and a second rotary member encoded to generate 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;.
22. A barrier operator position detector according to claim 21, wherein said controller is 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.
23. A barrier operator position detector according to claim 22, 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.
24. A barrier operator position detector according to claim 23, wherein the clock member comprises a one 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.
25. A barrier operator position detector according to claim 24, wherein after five cycles of the clock, the binary serial streams can be decoded by the controller to produce an absolute position indication.
26. A barrier operator position detector according to claim 24, wherein the first rotary member further comprises 32 geared teeth and wherein the second rotary member further comprises 31 geared teeth, the gears being adapted for being drivingly connected to a shaft for rotation.
27. A barrier operator position detector according to claim 23, wherein the clock member comprises two or more light emitters, two or more light receivers and a rotary interrupter mechanism disposed there between for selectively interrupting transmission of light from the light emitters to the light receivers, wherein the timing signal is generated upon interruption of the light transmission.
28. A barrier operator position detector according to claim 27, wherein after one cycle of the clock, the binary serial streams can be decoded by the controller to produce an absolute position indication.
29. A method of detecting a barrier operator's position, comprising: generating a unique nonrepeating binary serial stream; and windowing said serial stream to determine the barrier operator's position.
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-1 bit code word, the second N bit subcode also has the property that every selected subcode of N sequential bits of the M-1 bit code word has a unique value (preferably M-1 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 encoder 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; Fig. 11 is a schematic diagram of the electronics controlling the rolling shutter head unit of Fig. 2; and Fig. 12A-C is a flow chart of the routine used to generate the unique binary stream; 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, opera- tional 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 keypad 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 numbers (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 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 MASK32 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-31 are

masked. The MASK32 mask is shifted one bit right. Then the MASK32 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 MASK32. 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 position and is stored in the POSCNTR. At step 354 the routine ends.

The controller uses the POSCNTR 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 Q1 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 Q1 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 J1 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.

Figs. 12A-C are a flow chart illustrating the algorithm for generating a unique binary stream, or an array of decimal values for any given number to the power of two, (i. e., 32,64,128, etc.). More particularly, this algorithm generates the binary stream that is listed in Table A and can be used to design the 32 bit wheel located between the IR emitter/receiver pair. As Figs. 12A-C indicate, the algorithm for generating the unique non- repeating data stream or binary serial stream, is a very simple one. Although the algorithm depicted in Figs. 12A-C can be used to design any bit wheel that is to the power of two, (e. g., 25, 26, 27, etc.), the example provided assumes a 32 bit wheel is used. The algorithm begins at an initial state, step 400, where the repeat flag is set to zero (REAPEATFLAG=0), the branch flag is set to zero

(BRANCH FLAG=0), the initial value is set to zero (i=0), array A is set equal to the highest value allowed (A (i) =31), and array'B is set to zero (B (i) =0). At step 300, Array A sub-zero is equal to 31 (Array A (0) =31), which is the highest value allowed in a 32 bit system. Array B holds the branching flag for branching routine and will be discussed in further detail at step 442. In short, the branching flag of array B indicates whether a number has been used previously in algorithm A, or if it has not already been used in array A which would mean it is a number that could be used in the future. Moreover, the decimal values listed in column two of Table A could have been listed as their binary equivalent as the algorithm works the same for either decimal values or their binary equivalents.

At step 402, the number in array A is doubled and masked (A (i+1) =2* (A (i) Mask 0011111B). Since our initial value is zero, this step sets A sub-one equal to decimal value thirty (which is the equivalent of sixty-two masked).

Decision step 404 is then entered in which the algorithm asks if the branch flag is equal to one (BRANCH-FLAG=1 ?).

Since this is the initial run of the algorithm (i=0), the branch flag was set to zero in step 400, so the answer to this decision block is no. However had this been any later run (i=l, 2, etc.) the branch flag would not have been set equal to zero in step 400. The branch flag is set in the check branch subroutine (CHECK BRANCH) discussed below. In short, if the branch flag is equal to zero, there is no possibility the current value of array A has been used before (or there is no possibility the current number is recursive). If the branch flag is equal to one, there is a possibility that the number is a repeat of an earlier number. The significance in this determination is that the barrier operator position detector of the invention generates a unique non-repeating binary serial stream.

If the branch flag in step 404 is not equal to one, control shifts to step 406 and the algorithm enters the

check repeat subroutine (CALL CHECK REPEAT). During the check repeat subroutine step 408 (Fig. 12B), a number n is assigned the value of i. This is done because the value of n will change during the subroutine, and we do not want to alter the value of i. A dummy variable is named COMPARE and is set equal to A sub-n plus one (COMPARE=A (n+l). Since i is equal to zero, n is equal to zero and COMPARE equals A sub-one. Control is shifted to step 410 and the algorithm asks if COMPARE is equal to A (n) (COMPARE=A (n)?). Basically this step checks to see if the variable COMPARE is a repeat of any of the previous numbers in the array. If COMPARE is equal to A sub-n, (meaning it is a repeat of an earlier number in the array), control shifts to step 412, where the repeat flag is set equal to one (REPEAT FLAG=1) indicating that this number has already been used. After setting the repeat flag equal to one in step 412, control is shifted to step 414, which shifts control back to main routine step 406. If COMPARE is not equal to A sub-n, (meaning it is not a repeat of the previous number in the array), control is shifted to decision step 416 in which the algorithm asks if n is equal to zero (n=0 ?). If n is not equal to zero, there are other numbers in the array to compare COMPARE to.

Therefore control is shifted to step 418 where n is decremented (dec n) and control is sent back to step 410.

Once back at step 410, the algorithm again asks if COMPARE is equal to a number previously used in the array. This process is continued until COMPARE has been checked against every number in the array. If COMPARE is a repeat of any of the previous numbers used in the array, control shifts from step 410 to step 412. However, if COMPARE is not equal to any number previously used, and n is equal to zero (indicating all the numbers previously used in the array have been checked), control shifts from step 416 to step 420. Step 420 sets the repeat flag equal to 0 (REPEAT FLAG=0), transfers control to return step 414, which transfers control back to step 406 in the main routine.

Once control returns from the check repeat subroutine to step 406, the algorithm checks to see if the repeat flag is equal to one (REPEAT FLAG=1 ?). If the repeat flag is not equal to one, the present even number has not been repeated previously in the array (by default the system starts with an even number). Therefore, control shifts to step 422 in which the algorithm increments the even number to make it odd so that a further check can be made to see if the odd number is repetitive of a number previously used in the array. Specifically, A sub-i plus one is incremented to test the odd number (A (i+l) =A (i+l) +l). After step 422 has created the odd number, control is shifted to step 424 in which the algorithm again calls the check repeat subroutine (CALL CHECK REPEAT). The odd number is run through the same steps 408-414 of the check repeat subroutine as the even number was and control is eventually returned back to decision step 424. Once the subroutine is exited, the algorithm asks if the repeat flag is equal to one (REPEAT FLAG=1 ?). If the repeat flag is equal to one, (meaning the odd number is repetitive of a number previously used in the algorithm), control is shifted to step 426.

Step 426 sets the B array equal to zero, so that the algorithm knows that this is not a possible branch number or flag (meaning the number has already been used, so we do not want to indicate it as a number that can be branched back to for future numbers). Once the branch flag has been set equal to zero, control is shifted to step 428 so the A sub-i plus one can be converted back to the original even number that existed prior to step 422. Specifically, A sub-i plus one is set equal to A sub-i plus one minus one (A (i+1) =A (i+1)-1). Once the original even number is restored, control is transferred to step 430.

If in step 424, the repeat flag is not equal to one, control will be transferred to step 432 instead of step 426.

In step 432, the check repeat subroutine has discovered that the odd number is not repetitive of any of the numbers

already used in the array and therefore could be a number used later on in the array. Step 432 indicates this by setting the B array equal to one (B (i+1) =1). Once this has been done, control is shifted to step 428 which, as mentioned earlier, converts the odd number back into the original even number that existed prior to step 422.

Specifically, A sub-i plus one is set equal to A sub-i plus one minus one (A (i+1) =A (i+1)-1). Once the original number is restored, control is transferred to step 430.

If the branch flag of step 404 is equal to one or step 406 detects that the repeat flag is equal to one, the present even number has been repeated previously in the array. Control is then shifted to step 434 so that array B, branch flag and repeat flag can be set equal to zero. Once this has been done, control shifts to step 436 in which the algorithm increments the even number to make it odd (similar to step 422) so that a further check can be made to see if the odd number, is repetitive of a number previously used in the array. Specifically, A sub-i plus one is set equal A sub-i plus one plus one in order to test the odd number (A (i+l) =A (i+l) +1). After step 436 has created the odd number, control is shifted to step 438 in which the algorithm again calls the check repeat subroutine (CALL CHECK REPEAT). The odd number is run through the same steps 408-414 of the check repeat subroutine as the even number was and control is eventually returned back to decision step 438. Once the subroutine is exited, the algorithm asks if the repeat flag is equal to one (REPEAT FLAG=1 ?). If the repeat flag is equal to one, (meaning the odd number is repetitive of a number previously used in the algorithm), control is shifted to step 440 and the check branch subroutine is entered (CALL CHECK BRANCH).

During the check branch subroutine step 442, a variable x is assigned the value of i (x=i). This is done so that the value of x can be changed without altering the value of i. Once x is established, control switches to decision step

444 in which the algorithm asks if the value of B sub-x is equal to 1 (B (x) =1 ?). If B sub-x does not equal one, control is transferred to 446 and the value of x is decremented (dec x). Once the value of x has been decremented by one, control shifts from step 446 back to step 444 and the algorithm again asks if the value of B sub- x is equal to 1 (B (x) =1 ?). This process is continued until B sub-x is equal to one, (meaning until a number is found that has not been used previously in the array). Once this number has been found, control transfers from step 444 to step 448, i is set equal to x minus one (i=x-1) and the branch flag is set equal to one (BRANCH FLAG=1). After step 448 is completed, control transfers to step 450 and the algorithm returns from the check branch subroutine to step 402 of the main routine. If the repeat flag in step 438 is not determined to be equal to one control is transferred to step 430 so that the value of i can be incremented (Inc i).

The incrementing of i is what causes the system to default to an even number.

After i has been incremented in step 403, control is transferred to step 452 to determine whether i is equal to 31 (i=31). This question is asked in order to find out if we are at the last number in the array. Since we have been discussing a 2 to the 5t''power array, or a 32 bit array, the largest possible value is 31. However, if a 64 bit array was used, step 452 would ask if i is equal to 63, etc. If i is not equal to the last number in the array, control transfers from step 452 to step 402 and the process begins again. If i is equal to the last number in the array, control transfers from step 452 to step 454 and the array is printed.

The position is detected by looking at a five bit window during the revolution of the 32 bit wheel. The five bits window never repeats itself so that an accurate position can be detected. This is a result of the algorithm disclosed on Figs. 12A-C generating an array of decimal

numbers for any given number of teeth on a wheel that is a power of two. The algorithm aids in the design of the wheel that rotates between the IR emitter/receiver pair. Do to the size constraints posed by a tubular motor housing, a smaller wheel is desirable. Therefore a 32 bit array is used. However, in a garage door, a larger array is preferred, so a 64 bit array is used. The only difference being the size of the wheel and the size of the window used, (e. g., for 32 bit array a 5 bit window is needed, for a 64 bit array a 6 bit window is needed, etc.). Use of additional IR emitter/receiver pairs will assist in determining the absolute position more rapidly.

Although the above discussion and related drawings discuss use of the algorithm for generating an array of decimal values for any given number to the power of two, it is believed the same can apply to numbers to the power of one as well.

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. Digital Stream from Data Bit Wheel MASK 31 or MASK 32 VALUE _ Look-up# ............ . : o-x. >.. : :.. k... , ;, ;. : : o ; : : :. : > :'> : : s : : ; : :. : :. : : : ..'," ; : a : : o ; : o- : .. : .. , ; '. : ; » » : :'. : s ; : a.' :. : : : a :. .......... d to a decimal ; : : : : : : : r....,, : : : : : : : :'y. .. . ^.' : : : : : : :....." :. : : :'...... ;, ; ;" ; : .. o- : : p# | ; | S 0 0 | X | i1 1 16 = : : : : : : : : : :. \, a :,. : : : : : : :. :. : : :. : :., : : : : : : : : : : : ." :.'. : : : :. : : : : : : : : : : :. : : : : :. : : :. :. .,.. : : : : : : :. ..... 28 1 : :. :. . ? ;. : : : : : : : : :. : : 5 : : : : :. : : : : :... .. : : : : : : : : : ". :., ; : : : : : :. ; x,. ; ;. : :. : : : : :., 5, . ; : : : : : . :. : : : : : : : : : , iyn. ; y : i : ii'. i>i : 4 : Y : i : : i : :'. ; ysys ; p : :. : : :'. s ; : ; 'y,. ,. p : i : : : : : ' : i : Y. 4'. i : i : : 4Yv : : : L : s'. '. '. '. : : p : :' :-° |0 EE E E | | 26 lo , Pr v us 5 f K . : : : : :. ;, : > : > : : : : > : : s :. : :. : : >.. :. : :. : > : x. : . : ; : : : : .. > : .". : : :. >. : : : ; : x > : > : s,. : :. : :. : ; : : :. : > : :. . : : : : : > : : .. >.. :.... ;. ; .. : : :... ;.. ; ;.. ; ;.....,.... ;.. ;...... ;....... s... : : : : :. : : : > : w » : : : : ;. : : .. xx : t : : s : : : n : .. .. x : : ; :. ; : : : .. : : .. .. .. : : : >.. : » : o : o- :. .. : ax : : : : : : r : : : :. : : > :,.., ....... y . . : : : :. : : . : : :., . : :. ; : :.. : : :. , : : : : :...,.,.. ; : : ; : : : . : : : : : : : : :.. ; : : : : : : : :. ., :. : : : : : k., . : : : : : : :,. : o :",". : : : : : a : : : '. ;. >y ; : :. : : :, , ,. .'.'.' : ; : :.'. :, . : . : : a : : or : : : : : : : : s : a.. : : : : : o : : : : » : ., :' .................................. %.. ................................ . : : :.. i :. .. s ;..,. : : : . » : : o- : r :. ; : : s. « :. : o : : :. :.'., :. : o- : : : : ; : : : : : :. :. ;. : >x :. : ; : : : :. :. : >. : o ; : o->.. : : : :. .. >x :. : » > : : : rr : r : :. : : a> : : x : ,. : : :. : : : a : : : r : : » » : » ».. : o> : r : : :. : s : s : a>r : : :. : : :. : :' :.."w.. >.. : : : : : o :. : : : : : o> : ..'. ; : ;.,. ; : : : : : : : : : : : : k' :. : : : :. : : : : : : : :.,. : : : : :. :. . .... : : : : : : :. .'. :. : : : : : :. .. : : : : : : :.... : : : : : :. ... : :. :'.'. : : :.,.. o- : .. .. : : : :. .. : : :.".. > : : .. o-. . .. :. .. . : : :. ; : .. : o : : : : :.. : : : :. ; :. : .. .. .. .. : : : : : : : :. : : : .. : : :. :. :. : : :. . ; : r : : .. o- : :.".. : . . ........... : : : : : : a : x : : : :., ; : : :."> : : : : : :. : :. . . : r : : :. .,.. , : : :. :. : x : : : : : :. : : : :. ; o- : : : : :. :". : :. : : :. : r : : : » : :.. . : : o : : : : : : : : :. :... :... '. : :. :. : : : : :. : > : : : : : : o : : : : s : :, : : : : : : . ; : x : r : : : : : w' : :. : s : o : : o : : : s : r : » .. : : :. : : t : : ' ; : > : : s : : : s : : o : : .. : :. : o : : : o- : s : . . ; 30 0 .. y.........,. ; : : : : :. : : : : : : : :. :. :. : : :. .., ;..,. : : : : : : : : : : : : ......... : : : : : : : : : : : : : : : : : : >.,, : : : : : : : : : : : :.. ............................. : : : : : : : :. . ; : : :. : : :. : : : : : :. :.., :,., : : : : : : : :. : : : : : : : : : '. :. : : w : : : : :. : :.. ....... : ........ : .. : : : :. ...... k.... ........... ............... s ; .,........ : :. : : n....... ?. : : :. ......... : : x. : ; :.. :... ;. ; : : : : ' :..,. ;. ;. ;. . :.., : : : : : : : : : : :.,,'s, yy, s : : : : : : : : : : : :. : : : : : : : : : : :. : : : s" : : : : : : : : : : : : . o : : :. '.'.'.'.' : .''.' : : .' :'.' y. : : : : : : : : : > : : :.' : k : . : : : : : : : : : :, ; : ; ;. , : ; : : : : : : : : : : : : :.'., : >. ; > : x> : . : . : : .. :. : : : : :. : : : : ; : > :', >. ;.,, ; : : : : : . . f : : : o : a » x> : : : : : :. : : ; : : . < : : : : : : : ^. > : : » r : : : : 27 28 o- :.. . : : :. : : : : :. .. :. > ; : : :. ;. : : : : : : : :.. : >.. > : ; : : : : : .. : : o : x : » .. .. x : > : : : o :. : » :. : : :, .. s : x : sus, 1 0 4 t 25 24 1 27 28 1 23 29 1 15 30 1 31 31 TABLE A EXHIBIT A ; Last Modified Febuary 10, 1999. i This is the Code for the Tubular Motor First Generation product.<BR> <BR> <BR> <BR> <P> ; There is no force sensing.<BR> <P> ; Get rid of RAM TEST and CHECKSUM.

; Get rid of stop mode.

: Take out WDT.

; ************************************************************ *********** <BR> <BR> <BR> iw**<BR> <BR> <BR> <BR> <BR> <BR> , ; Equate Statements ; ; ************************************************************ *********** **** globals on P01M_INIT .equ 00000100B P2M_INIT .equ 01100011B P3M_INIT .equ 00000001B POIS_INIT. equ 00001010B P2SINIT. equ 00000000B P3S_INIT .equ 00000000B P2M_EEOUT .equ 11111011B ; Mask for outputting data to EEPROM P2M_EEIN .equ 00000100B ; Same for input __ _ _ ---- ; GLOBAL REGISTERS ; ------------------------------------------------------------ ------------- ---- ; ************************************************************ *********** **** ; LEARN EE GROUP REGISTERS FOR LOOPS ECT ; ************************************************************ *********** **** LEARNEE_GRP. equ 2 OH P2M_SHADOW . equ LEARNEE_GRP+0 ; Mask for mode of P2 TEMP. equ LEARNEE_GRP+2 ; HTSMPH. equ LEARNEE_GRP+6 ; memory temp MTEMPL .equ LEARNEE_GRP+7 ; memory temp MTEMP .equ LEARNEE_GRP+8 ; memory temp SERIAL .equ LEARNEE_GRP+9 ; serial data to and from nonvol memory ADDRESS. equ LEARNEE_GRP+10 ; address for the serial nonvol memory temp equ r2 ; mcentph. egu r6; memory tentp mten) pl. equ r7: memory temp mtemp .equ r8 ; memory temp serial. equ r9 : serial data to and from nonvol merory <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> address .equ r10 ; address for the serial nonvol memory<BR> ; ************************************************************ **** MAIN_GRP .equ 30H UP_LIMIT_H .equ MAIN_GRP+0 ; ** upper limit high byte UP_LIMIT_L .equ MAIN_GRP+1 ; ** upper limit low byte UP_LIMIT. equ MAINGRP+0 upper limit word DOWN_LIMIT_H .equ MAIN_GRP+2 ; ** lower limit high byte DOWN_LIMIT_L. equ MAIN_GRP+3 ** lower limit low byte DOWN_LIMIT . equ MAIN GRP+2 ; lower limit word POS_CNTR_H. equ MAIN_GRP+4 ; position counter high byte POS_CNTR_L .equ MAIN_GRP+5 ; position counter low byte POS_CNTR .equ MAIN_GRP+ ; position counter POWER_LFC. equ MAIN_GRPt6 power line sampler UP_LFC. equ MAIN_GRP+7 ; Up Line Filter counter DOWN_LFC. equ MAIN_GRP+8 ; Down Line Filter counter POWER_DEBOUNCER . equ MAIN_GRP+9 ; 4ms in a row = power on UPDEBOUNCER. equ MAIN_GRP+10 ; (A) up debouncer DOWN_DEBOUNCER . equ MAIN_GRP+ll ; (B) down debouncer UPANDDOWN. equ MAIN_GRP+12 ; (C) 1 for up 2 for down OFF_LFC. equ MAINGRP+13 ; (D) 30ms = power off LF_TIMER. equ KAINGRP+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 40H MASK_32. equ MAIN_GRP+16 ; (0) 5 bit mask of P33 stream MASK31. equ MAINGRP+17 ; (1) 5 bit mask of P32 stream MASK_32_VALUE .equ MAIN_GRP+18 ; (2) look up value for 32 bit wheel MASR31VALUE. equ MAIN_GRP+19 ; (3) look up value for 31 bit wheel LOOP_5 . equ MAIN_GRP+20 ; (4) loop counter MODULO. equ MAIN_GRP+21 ; (5) gives mod of difference MASK_ADDRESS_H .equ MAIN_GRP+22 ; (6) HB of address of lookup value.

MASK_ADDRESS_L .equ MAIN_GRP+23 ; (7) LB of address of lookup value.

MASK_ADDRESS . equ MAIN_GRP+22 ; (6) address of lookup value.

RPM_HIGH_DB .equ MAIN_GRP+24 ; (8) rpm high. debouncer RPMLOWDB. equ MAIN_GRP+25 ; (9) rpm low debouncer WHEEL_31_DB . equ MAIN_GRP+26 ; (A) wheel 31 high db WHEEL32DB. equ MAIN_GRP+27 ; (B) wheel 31 high db BIT_31_STATE . equ MAIN_GRP+28 ; (C) set to 17 when high BIT_32_STATE . equ MAINGRP+29 ; (D) set to 17 when high DIFFERENCE. equ MAIN_GRP+30 ; (E) MASK_32_VALUE-MASK_31_VALUE CLOCK-CYCLES equ MAIN_GRP+31 ; (F) number of RPM interrupts. mask_32 value, equ r2 ; will contain lookup value. mask_31_value. equ r3 ; will contain lookup value. loop5. equ r4 ; (F) loop counter maskaddressh. equ r6 ; contains HB of address of lookup valu. mask_address_1 .equ r7; contains LB of address of lookup value mask-address equ rr6 ; contains address of lookup value.

MAIN_GRP_3. equ 5OH DELAY_TIMER .equ MAIN_GRP+32 ; (0) timer for relay enable delay STOP_FLAG. equ MAIN_GRP+33 ; (1) tells main loop to stop START_FLAG . equ MAIN_GRP+34 ; (2) flag for inc count flag LIMIT_FLAG .equ MAIN_GRP+35 ; (3) ** 033H for up OCCH for down.

UP_CUSHION_H .equ MAIN_GRP+36 ; (4) 100 positions past up limit UPCUSHIOKL. equ MAIN_GRP+37 ; (5) 100 positions past up limit UT-CUSHION equ MAIN_GRP+36 ; (4) 100 positions past up : DOWNCUSHIONH. equ MAIN_GRP+38 ; (6) 100 positions past down limit DOWN_CUSHION_L .equ MAIN_GRP+39 ; (7) 100 positions past down limit DOMNCUSHION. equ MAIN_GRP+38 ; (6) 100 positions past down limit POS_CNTR_H_TEMP . equ MAIN_GRP+40 ; (8) temporary position value POSCNTRLTEM ?. equ MAIN_GRP+41 ; (9) temporary position value POSCNTRJTEMP. equ MAIN_GRP+40 ; (8) temporary position value MASK_32_TEMP . equ MAIN_GRP-42 ; (A) temporary mask value MASK_31_TEMP. equ MAIN_GRP+43 ; (B) temporary mask value LEARNFLAG. equ MAIN_GRP+44 ; (C) ** learn mode flag FREE_TRAVEL_FLAG equ MAIN_GRP+45 ; (D) ** flag for free movement AllIntOn. equ MAIN_GRP+46 ; (E) sets up interrupts TAPCNTR. equ @ MAIN_GRP+47 ; (F) ; ************************************************************ *** CHECK_GPR .equ 80H eheeksumvalue. equ 03DH check_sum . equ rO romdata. equ rl test_adr_hi . equ r2 test_adr_lo . equ r3 test_adr . equ : ru2 ; ************************************************************ *** STACKEND. equ OAOH ; start of the stack STACKTOP . equ 238 ; end of the stack csh. equ 00010000B ; chip select high for the. 93c46 csl . equ 11101111B chip select low for 93c46 c : ockh. equ 00001000B ; clock high for 93c46 clockl. equ 11110111B ; clock low for 93c46 doh. equ 00000100B data out high for 93c46 dol .equ 11111011B ; data out low for 93c46 psmask. equ C1OOOOOOB mask for the program switch csport. equ P2 ; chip select port dioport. equ P2 ; data i/o port clkport . equ P2 ; clock port psport. eau P2; program switch port MemoryTimer .equ 96 ; WATCHDOG_GROUP . equ OFH PCON. equ rO SMR .equ r11 MOTOR. equ rl5 FILL. macro . byte OFFh .endm FILL10. macro . byte CFFh . byte OFFh . byte OFFS . byte OFFh . byte OFFh . byte OFFh . byte OFFh . byte OFFh . byte OFFh . byte OFFh . endm FILL50. macro . 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 . 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 OFFn . byte OFFh . byte OFF", . byte OFFh . byte OFFh . byte CFFh . byte OFFh . endm TRAP. macro ip start jp start jp start jp start jp start . endm TRAP10. macro TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP . endm .*********************************************************** ************ ; * ; * Interrupt Vector Table ; * ; ************************************************************ *********** * <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> . org OOOOH<BR> <BR> <BR> <BR> <BR> <BR> <BR> . word FALSE_INT ; IROO, P3.2<BR> . word FALSE_INT ; IRQ1, P3.3<BR> <BR> <BR> . word FALSE_INT ; IRQ2, P3.1<BR> . word d FALSE_INT ; IRQ3, P3.0<BR> . word TIMERO_INT ; IRQ4, TO . word FALSE_TNT ; IRQ5, T1 . page . org OOOCH jp START <BR> <BR> <BR> <BR> <BR> <BR> <BR> WHBELTABLE :<BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> . byte 004H . byte C05H . byte 00EH . byte 006H . byte OOFH . byte 012H <BR> <BR> . byte 01AH<BR> <BR> <BR> <BR> <BR> . byte 007H<BR> <BR> <BR> <BR> <BR> . byte OOCH . byte 010H . byte 013H . byte 015H . byte 017H . byte O1BF . byte 008H <BR> <BR> . byte 01EH<BR> <BR> <BR> <BR> <BR> . byte 003H . byte 00DH . byte 011H . byte 019H . byte OOBH . byte 014H . byte 016H . byte 01D . byte 002H . byte 018H . byte OOAH . byte 01CH . byte OOTH . byte 009H . byte OOTH . byte O1FH . org OlOlH <BR> <BR> .*********************************************************** ************<BR> ,<BR> ; REGISTER INITILIZATION ; ************************************************************ *********** * start: START: di; turn off the interrupt for init ld RP, #WATCHDOG_GROUP ld WDTMR, #00000111B ; rc dog lOOms. clr RP WDT ; kick the dog ; clear the register pointer xor P2, #10000000B : toggle pin 3.

;*********************************************************** ************ <BR> <BR> *<BR> ;* PORT INITIALIZATION ; ************************************************************ *********** ld P01M, #P01M_INIT ; set mode pOO-pO3 out p04-p07in ld P3M, &num P3M_INIT set port3 p30-p33 input analog mode p34-p37 outputs ld P2M, #P2M_INIT ; set port 2 mode Id P2KSHADOW, #P2M_INIT ; Set readable register ld P0, #P01S_INIT ; RESET all ports ld P2, #P2S_INIT ; ld P3, #P3S_INIT ; ; ************************************************************ *********** * ; M Test and Reset All RAM = mS * ; ************************************************************ *********** * jp STACK srp #OFOH ; POINT to control register group ld r15, #4 ; r15= pointer (minimum of RAM) write_again : WDT ; kick the dog xor P2, #10000000B ; toggle pin 3.

1d r14, #1 write_againi : ld @rl5, rl4 ; write 1,2,4,8, 10,20,40,80 cp rl4, @r15 ; then compare jp ne, system_error rl rl4 jp nc, writeagainl clr 6rl5 ; write RAM (r5) =0 to memory inc rl5 cp r15, #240 jp ult, write again ; ************************************************************ *********** * ; * Checksum Test ; ************************************************************ *********** * CHECKSUMTEST : srp CHECK_GRP ld test_adr_hi, &num CFH ld test_adr_lo, #0FFH ; maximum address=fffh add_sum : WDT kick the dog xor P2, #10000000B ; 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_adr increment ROM address jp nz, add_sum ; address=0 ? cp check_sum, #check_sum_value jp z, systemok : check final checksum = 00 ? system_error : and P0, #11111011B : turn on the led jp systeterror . byte 256-check_sum_value systenok : WDT kick the dog xor P2, #10000000B ; toggle pin 3. ld STACKED, &num STACKTOP ; start at the top of the stack SETSTACKLOOP : ld BSTACKEND, 01H ; set the value for the stack vector dec STACKED next address cp STACKEND, #STACKEND ; test for the last address jp nz, SETSTACFLOOP ; loop till dc ; ************************************************************ *********** * ; *STACK INITILIZATION ; ************************************************************ *********** * STACK: ; WDT ; KICK THE DOG xor P2, #10000000B ; toggle pin 3. clr 254. ld 255, #238 ; set the start of the stack ;*********************************************************** ************ !<BR> <BR> <BR> t TIMER : * TIMER: ld PRE0, #00010001B ; set the prescaler to 1/4 for 250Khz ld TO, #OFAH set the counter to count 250 to 0 (TO=lms) ld PRE1, #11111111B set the prescaler to 1/63 for 16Khz ld T1, OFFS ; not the counter to count 255 to 0 (Tl=16ms) ld TMR, #00000111B ; turn on the TO timer.

; ************************************************************ *********** <BR> <BR> <BR> ; *PORT INITIALIZATON<BR> <BR> <BR> i ; ************************************************************ *********** * ld P01M, #P01M_INIT set mode p00-p03 out p04-pO7in ld P3K, « P3MINIT set port3 p30-p33 input analog mode ; p34-p37 outputs ld P2M, #P2M_INIT ; set port 2 mode ld P2M_SHADOW, #P2M_INIT ; Set readable register ld PO, #P01S_INIT ; RESET all ports ld P2, #P2S_INIT ; ld P3, #P3S_INIT ; ************************************************************ *********** * ; INITERRUPT INITILIZATION ;*********************************************************** ************ * SETINTERRUPTS: ld IPR, #00101101B ; set the priority to RPM ld IMR, #01010000B ; set IMR for T0 interrupt only ld IRQ, #11000000B ; set the edge clear int ; ************************************************************ *********** * ; SET SMR &PCON ; ************************************************************ *********** * ld RP, &num WATCHDOG-GROUP ld SMR, &num 00011110B ; recovery source = P2 NOR 0: 7 ld PCON, #10010110B ; reset the pcon no comparator output ; STANDARD emi mode clr RP <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> cl ru<BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> *<BR> VARIALBE INITILIZATION ; ************************************************************ *********** * ; WDT ; KICK THE DOG ; xor P2, &num 10000000B ; toggle pin 3. ld POS_CNTR_H, &num 00 ld POS_CNTR_L, #00 ld LF_TIMER, #00 ld OFF_LFC, #00 ld UP_LFC, #00 ld DOWNLFC, #00 ld POWER_LFC, #00 Id MOTOR_FLAG, &num 00 ld DELAY-TIMER, #00 ld STOP-FLAG, #00 ld START_FLAG, #00 ld UP_AND_DOWN, #00 ld POWER_DEBOUNCER, #00 Ld UP_DEBOUNCER, #00 Id DOhV_DEBOUNCER, #00 ld TAP_CNTR, #00 ld MASK_32, #00 ld MMASK_31, #00 ld MASK-32-VALUE, &num 00 ld MASK_31_VALUE, &num 00 ld DIFFERENCE, &num 00 ld CLOCK-CYCLES, #00 ld FREE_TRAVEL_FLAG, #00 ld LIMIT_FLAG, &num 00 ld UP_CUSHION_H, #00 ld UPCUSHIONL, &num 00 ld DOWN_CUSHION_H, #00 ld DOWNCUSHIONL, 00 ld POS_CNTR_H_TEMP &num 00 ld POS_CNTR_L_TEMP, #00 ld MASK_32_TEMP, #00 ld MASK_31_TEMP, #00 ld RPM_HIGH_DB, #11 ld RPM_LOW_DB, #00 ld WHEEL_31_DB, #00 ld WHEEL_32_DB, #00 ld BIT_31_STATE, &num 00 ld BIT_32_STATE, #00 lå LEARN_FLAG, #02 Id UP_LIMIT_H, #02H ld UP_LIMIT_L, #02BH ld DOWN_LIMIT_H, #01H ld DOWN_LIMIT_L, #0DBH ld AllIntOn, 001010000B ; just enable timer at : ; WDT ; KICK THE DOG ; xor P2, &num 100000003 ; toggle pin 3.

; ************************************************************ *********** * ; READ THE MEMORY 2X ei * ei WAIT_BEFORE_READING : call WAIT_40_MS nop ; WDT ; KICK THE DOG ; xor P2, #10000000B ; toggle pin 3.

; ADDRESS 00 UP_LIMIT ; ADDRESS 01 DOWN_LIMIT ; ADDRESS 02 LIMITFLAG ; 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 TIMER0 (HEARTBEAT) INTERRUPT ROUTINE ; Direction for counter is the LSB of the state ; TIMER0-INT: ld IMR, A11IntOn ; turn on all the interrupts tm PO, #00001000B ; are IR's on ? jp nz, CHECK_START_FLAG ; if not, then jump cp MOTORFLAG, #CAAH ; is motor on? jp ne, CHECK_START_FLAG xor PO, &num 000000103 ; toggle pin for motor CHECKSTARTFLAG : ir. DELAYJTIMER ; increment timer. cp START-FLAG, &num 01 ; ready to check inputs ? jp ne, TIMER0_RETURN ; 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 POMERLFC ; else, increment TOTAL_LFC.

TESTMOTOR : cp MOTOR_FLAG, #0AAH ; is motor on? jp eq, TIMER0_RETURN ; if so, jump. tm P2, &num 00000010B ; 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 TESTDOMNLFC : tm P2, #0000001B ; 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 COL5TiR c'r UP_LFC ; clear up counter clr DOWN_LFC ; clear down counter clr POWER_LFC ; clear power counter cp OFF_LFC, &num 22 ; is counter at 22ms? jp eq, CHECKFORPOWER ; if so, then jump. jp TIMER0_RETURN TEST_POWER_LFC : cp POWER_LFC, #03 ; is POWER_LFC more than 03? jp ne, TIMERORETURN ; if so, leave interrupt cp POWER_DEBOUNCER, #22 ; is DB already et 22 ? jp eq, CHECK_UP_LFC ; if so, don't increment inc POlfER_DEBOUNCER ; else, increment POWER DB cp POWER_DEBOUNCER, #03 ; is UP DB at 3? jp r.e, CHECK_UP_LFC ; if not, jump. inc TAP_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_DOWN_LFC ; if not, cp UP_DEBOUNCER, #255 ; is UP DB maxed out. jp eq, SET_UP_AND_DOWN_FLAG ; if so, jump. clr DOWN_DEBOUNCER ; clear debouncers inc UPDEBOUKCER ; increment db cp UP_DEBOUNCER, #22 ; if at 22, then set high. jp ne, SET_UP_AND_DOWN_FLAG ; else, skip. ld UP_DEBOUNCER, #255 ; ld DB with 255. clr TAP_CNTR ; clear TAP_COUNTER jp SET_UP_AND_DOWN_FLAN CHECK_DOWN_LFC : cp DOMNLFC, &num 03 ; is DOWNLFC at 3? jp ult, SET_UP_AND_DOWN_FLAG ; if not, jump. cp DOWN_DEBOUNCER, #255 ; is DOWN DB maxed out. jp eq, SET_UP_AND_DOWN_FLAG ; if so, jump. clr U ? DEBOUNCER ; clear debouncers inc DOMNDEBOUNCER ; increment db cp DOWN_DEBOUNCER, #22 ; if at 22, then set high. jp ne, SET_UP_AND_DOWN_FLAG ; else, skip. ld DOWN_DEBOUNCER, &num 255 ; ld DB with 255. clr TA ? CNTR : clear TAP_COUNTER jp SET_UP_AND_DOWN_FLAG CHECK_FOR_POWER : clr OFF_LFC ; reset off counter clr UP_DEBOUNCER ; clear DB's clr DOWKDEBOUNCER ; cp POWERDEBOUKCER, 03 ; is DB aready zero? jp uge, CLEAR_LINE_DBS ; if so, don't write clr POWER_DEBOUNCER ; clear power debouncer jp TIMERORETURN CLEAR_LINE_DBS : clr POWER_DEBOUNCER ; clear power debouncer ld STOP_FLAG, #01 ; set stop flag. and TMR, #11111101B ; disable timer 0 ; WRITE TO MEMORY -- TAP_CNTR ld ADDRESS, &num 03 ; POINT TO ADDRESS THAT CONTAINS TAP_CNTR ld MTEMPH, TAP_CNTR ; load feirp register with TAPCNTR byte ld MTEMPL, #00 ; load temp register with 00. nop call WRITEMEMORY ; or TMR, #00000010B ; enable timer 0 jp TIMERO_RETURN SETUPANDDOMNFLAG : cp DOWNDEBOUNCER, &num 255 ; is DOWN DB high? jp eq, SET_DOWN_FLAG ; if so, set down flag cp UP_DEBOUNCER, #255 ; is UP DB high ? jp ne, TIMER0_RETURN ; if not, leave interrupt ld UP_AND_DOWN, # ; else, set direction for up jp TIMERORETURN ; leave interrupt.

SET_DOWN_FLAG : ld UP_AND_DOWN, #02 ; else, set direction for down TIMERORETURK : iret ; ------------------------------------------------------------ ------------- THIS IS THE MOTOR RPN FALLING EDGE INTERRUPT ROUTINE ; IT CONVERTS THE-SAMPLED BITS OF P33 AND P32 INTO TWO ; 5-DIT gSSRS AN'D LOOKS UP A VALUE FOR EACH MASK. THE N ; PERFORMS A MATHMATICAL OPERATION ON THESE VALUES TO ; GET AN ABSOLUTE POSITION.

; ------------------------------------------------------------ ------- RPM : ; motor speed cp UP_AND_DOh'N, &num 01 ; are we going in up dir? jp eq, UPDIR ; if so, then jump to UP_DIR routine ; else, check down dir cp UP_AND_DOWN, #02 ; are we going in down dir? jp eg, DOWN_DIR ; if so, then jump to DOWN_DIR ; routine ret ; else, return DOWN_DIR : cp CLOCK-CYCLES, #05 ; has there been 5 clocks? jp eq, LOAD_DOWN_TEMPS inc CLOCK_CYCLES LOAD_DOWN_TEMPS : ld MASK_32_TEMP, MASK_32 ld 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 ld POS_CNTR_H_TEMP, #03H ld POSCNTRLTEMP, *ODFH jp GET_DOWN_POSITION SETDOMNTEMP : ld POS_CN R_H_TEMP, POS_CNTR_H ld POS_CNTR_L_TEMP, POS_CNTR_L decw POSCNTRTEMP GET_DOWN_POSITION : call SHIFT_BITS_RIGHT nop call GET POSITION nop decw POSCNTR ; subtract 4 to get the true decw POSCNTR ; value of the absolute position decw POS_CN^R ; in the down direction. decw POS CNTR cp POS_CNTR_H, #0FFH ; make sure no roll over occurred jp ne, DONNVALIDCHECK ; if so, fix it. ld POS_CNTR_H, &num 03H ; set upper byte correct. add POSCNTRL, OEOH ; adjust roll over value.

DOMNVALIDCHECK : cp CLOCK_CYCLES, #05 ; has there been 5 clocks? jp ne, RPM_RETURN cp POS_CNTR_H, POS_CNTR_H_TEMP jp ne, RESTORE_DOWN_MASKS cp POSCNTRL, POS_CNTR_L_TEMP jp ne, RESTORE_DOWN_MASKS jp RPMRETURN RESTORE_DOWN_MASKS : ld MASK_32, MASK_32 TEMP ld MASK_31, MASK_31_TEMP incw POSCNTRTEMP cp POS_CKTR_H_TEMP, #03H jp ne, RESTORE_DOWN_POS cp POSCNTRLTEMP, #0E0H jp ne, RESTORE_DOWN_POS ld POS_CNTR_H, &num OOH ld POS_CNTR_L, #OOH jp RPM_RETURN RESTORE_DOWN_POS : ld POS_CNTR H, POS_CNTR_H_TEMP ld POS_CNTR_L, POS_CNTR_L_TEMP jp RPRETURN UP_DIR; cp CLOCK_CYCLES, #05 ; has there been 5 clocks ? jp eq, LOAD_UP_TEMPS inc CLOCK-CYCLES LOAD_UP_TEMPS ; ld MASK_32_TEMP, MASK_32 ld MASK_31_TEMP, MASK_31 cp POS_CNTR_H, &num 03 jp ne, SET_UP_TEMP cp POS_CNTR_L, #ODF jp ne, SET_UP_TEMP clr POSCNTRHTEMP clr POS_CNTR_L_TEMP jp GET_UP_POSITION SET_UP_TEMP : ld POS_CNTR_H_TEMP, POS_CNTR_H ld POSCNTRLTEMP, POSCNTRL incw POS_CNTR_TEMP GET_UP_POSITION: call SHIFTBITSLEFT nop call GET_POSITION nop UPVALIDCHECK : cp CLOCK_CYCLES, #05 ; has there been 5 clocks ? jp ne, RPM_RETURN cp POSCNTRH, POSCKTRHTEKP jp ne, RESTORE_UP_MASKS cp POS_CNTR_L, POS_CNTR_L_TEMP jp ne, RESTOREUPMASKS jp RPM_RETURN RPM_RETURN: OUTPUT THE DIFFERENCE-WHICH IS THE ABSOLUTE REVOLUTION ; OUTPUT THE ABSOLUTE POSITION ret RESTORE_UP_MASKS: ld MASK_32, MASK_32_TEMP ld MASK_31, MASK_31_TEMP decw POS_CNTR_TEMP cp POS_CNTR_ 7_TENP, &num OFFH jp ne, RESTORE_UP_POS ld POSCNTRH, #03H ld POS_CNTR_L, #ODFH jp RPM_RETURN RESTOREUPPOS : ld POS_CNTR_H, POS_CNTR_H_TEMP ld POS_CNTR_L, POS_CNTR_L_TEMP jp RPM_RETURN ------------------------------------------------------------ ---------- SHOULD NOT BE HERE ------------------------------------------------------------ ---------- FALSE_INT : and AllIntOn, #11010000b ; turn off all interrupts except TO. iret : ; ************************************************************ *********** * ; THIS ROUTINE SHIFTS MESK_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, #00011110B ; use only the first five digits rl MASK_31 ; shift bits left and MASK_3i, &num 00011110B ; use only the first five digits and BIT_32_STATE, #00000001B ; leave LSB HIGH and d BIT_31_STATE, #0000001B ; leave LSB HIGH or MASK_32, B : T_32_STATE ; set LSB or MASK_31, BIT_31_STATE ; set LSB SBL_RETURN : ret .*********************************************************** ************ <BR> <BR> <BR> ,<BR> * ; THIS ROUTINE SHIFTS MASK_32 AND MASK_31 BITS RIGHT ; AND WRITES THE SAMPLED DATA IN THE LSB OF EACH MASK i- ; ************************************************************ *********** * SHIFT_BITS_RIGHT : rr MASK_32 ; shift bits right and MASK_32, #00001111B ; use only the first five digits rr MASK_31 ; shift bits right and MASK_31, #00001111B ; use only the first five digits and BIT_32_STATE, #00010000B ; 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 SBRRETURN : ret <BR> <BR> <BR> <BR> <BR> <BR> rez<BR> <BR> <BR> <BR> * WRITE WORD TO MEMORY ; ADDRESS IS SET IN REG ADDRESS ; DATA IS IN REG MTEMPH AND MTEMPL ; RETURN ADDRESS IS UNCHANGED ; ************************************************************ *********** * GET_POSITION: nop push RP nop srp #40H nop ld maskaddressh, OHIGH WHEELTABLE 'd mask_address_l, #LOW WHEELTABLE add mask_address_l, MASK_32 adc mask_address_h, #00H ldc mask_32_value, Qmask_address ld mask_address_h, #HIGH WHEEL_TABLE ld mask_address_l, #LOW WHEEL_TABLE add mask_address_', MASS_31 adc mask_address_h, #OOH ldc mask_31_value, @mask_address nop pop RP nop ld DIFFERENCE, MASK 31_VALUE sub DIFFERENCE, MASK32VALUE cp DIFFERENCE, #00 ; is DIFFERENCE negative? jp ge, MULTIPLY_MODULO add DIFFERENCE, #31 MULTIPLYMODULO : ld MODULO, DIFFERENCE ; MODULO is now positive clr POSCNTRH ld POSCNTRL, MODULO ld LOOP_5, #05 push RP MULTIPLYBY32 : srp &num 30H rl pos_cntr_h ; shift bits of POS_CNTR left rl posent2 ; 5 times = X32. adc pos_cntr_h, #00 ; add any y carry to high byte and pos_cntr_l, #11111110B ; kill any reload carry. srp #40H ; djnz loop5, MULTIPLYBY32 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 ;*********************************************************** *********** <BR> <BR> <BR> <BR> *<BR> <BR> ; THIS ROUTINE TURNS ON THE TRIAC ; RELAY OF APPLIED POWER ; ************************************************************ ********** * TURN_ON_MOTOR: cp UP_AND_DOWN, #01 jp eq, SETMOTORFLAG cp UP-AND-DOWN, #02 jp ne, START SET_MOTOR_FLAG : di ld MOTOR-FLAG, #0AAH and PO, &num 11110111B turn on IR's ei WAIT_FOR_FULL_CYCLE: cp POWER_DEBOUNCER, #00 jp eq, CLEAR_DB_AND_JUMP cp RPHHIGHDB, #09 jp ne, WAIT_FOR_FULL_CYCLE ld RPM_HIGH_DB, #11 clr RPMLOMDB clr WHEEL_31_DB clr WHEEL_32_DB clr CLOCK_CYCLES WAIT_5_CLOCKS : WDT xor P2, #10000000B ; toggle pin 3. cp STOP FLAG, #01 jp eq, MOTOR-RETURN cp CLOCKCYCLES, #05 ; position found after 5 clocks jp ult, WAIT_5_CLOCKS ; MOTORRETURK : ret ; ************************************************************ *********** * ; THIS ROUTINE TURNS OFF THE MOTOR OF APPLIED POWER s AND WAITS UNTIL THE POWER IS RELEASED.

; ************************************************************ *********** * TURN_OFF_MOTOR: di or PO, #00001000B ; turn off IR's clr MOTOR_FLAG or PO, #00000010B ; set state high ; WDT ; KICK THE DOG xor P2, #10000000B ; toggle pin 3. cp POWER_DEBOUNCER, #00 ; see if released jp ne, TURNOFFMOTOR ; if not, then keep checking ret ret ; ROUTINE WAITS FOR 40ms TO PASS.

THEN RETURNS.

; ************************************************************ *********** * WAIT_40_MS : clr DELAY TIKER LOOP_TILL_40 : WDT xor P2, #10000000B ; toggle pin 3. cp DELAY_TIMER &num 40 ; wait 40ms before turning on jp ne, LOOP TILL_40 ; interrupts. ret ; ************************************************************ *********** * WRITE WORD TO MEMORY ADDRESS IS SET IN REG ADDRESS DATA IS IN REG MTEMPH AND MTEKPL RETURN ADDRESS IS UNCHANGED ; ************************************************************ *********** * WRITEMEMORY : ; WDT xor P2, #10000000B ; toggle pin 3. push RP ; SAVE THE RP srp &num LE'ARNEE_GRP set the register pointer call STARTB ; output the start bit ld serial, &num OOllOOOOB ; set byte to enable write call SERIALOUT ; output the byte and csport, &num csl ; reset the chip select call START3 ; output the start bit ld serial, &num OIOOOOOOB ; set the byte for write or serial, address ; or in the address call SERIALOUT ; output the byte ld serial, mtemph ; set the first byte to write call SERIALOUT ; output the byte ld serial, mtempl ; set the second byte to write call SERIALOUT ; output the byte call ENDWRITE ; wait for the ready status call STARTB ; output the start bit ld serial, &num OOOOOOOOB ; set byte to disable write call SERIALOUT output the byte and csporc. #csl ; reset the chip select pop RP ; reset the RP ret ; ************************************************************ *********** * ; READ WORD FROM MEMORY ADDRESS IS SET IN REG ADDRESS DATA IS RETURNED IN REG MTEMPH AND MTEMPL ; ADDRESS IS UNCHANGED ; ************************************************************ *********** * READMEMORY: push ; arp #LEARNEE_GRP ; set the register pointer call STARTB ; output the start bit ld serial, #10000000B ; preamble for read or serial, address ; or in the address call SERIALOUT ; output the byte call SERIALIN ; read the first byte ld mtemph, serial save the value in mtemph call SERIALIN ; read teh second byte ld mtempl, aerial f save the value in mtempl and csport. #csl ; reset the chip select pop ; ret STARTB : and csport, &num csl and clkport, #clocki ; start by clearing the bits and dioport, #dol ; and P2M_SHADOW, &num P2M_EEOUT ; set port 2 mode output mode data ld P2M, P2M_SHADOW or csport, &num cash- set the chip select or dioport, #doh set the data out high or clkport, #clockh ; set the clock and clkport, &num clockl ; reset the clock low and dioport, &num do ; ; set the data low ret return ; ************************************************************ *********** * ; END OF CODE WRITE ; ************************************************************ *********** * ENDWRITE: di and csport, &num csl reset the chip select nop delay or csport, #csh ; set the chip select or P2M_SHADOW, #P2M_EEIN ; set port 2 mode input mode data ld P2M, P2M_SHADOW ; clr MemoryTimer ENDWRITELOOP : ei cp MemoryTimer, #12 ; test for 12mS passed jp ugt, MemoryTimeOut ld mtemp, dioport ; read the port and mtemp, #doh mask jp z, ENDWRITELOOP ; if bit is low then loop till we are done MemoryTimeOut : and csport, &num csl ; reset the chip select and P2M_SHADOW, &num P2MLEEOUT ; set port 2 mode forcing output mode Id P2K, P2MSHADOW ; ret ; ************************************************************ *********** * ; SERIAL OUT OUTPUT THE BYTE IN SERIAL ; ************************************************************ *********** * SERIALOUT: and P2M_SHADOW, #P2M_EEOUT ; set port 2 mode output mode data ld P2M, P2M_SHADOW ; ld mtemp, #8H set the count for eight bits SERIALOUTLOOP : ric serial get the bit to output into the carry jp nc, ZEROOUT ; output a zero if no carry ONEOUT: or dioport, gdoh ; set the data out high or clkport, #clockh ; set the clock high and clkport, #clockl : reset the clock low and dioport, &num dol ; reset the data out low djnz mtemp, SERIALOUTLOOP ; loop till done ret ; return ZEROOUT : and dioport, #dol ; reset the data out low or clkport, &num clockh ! set the clock high and clkport, &num clockl ; ! reset the clock low and dioport, #dol ; reset the data out low djnz mtemp, SERIALOUTLOOP ;'loop till done ret ; return ; ************************************************************ *********** * SERIAL IN INPUTS A BYTE TO SERIAL ; ************************************************************ *********** * SERIALIN: or P2M_SHADOW, #P2M_EEIN ; set port 2 mode input mode data ld P2M, P2M_SHADOW t ld mtemp, &num 8H ; set the count for eight bits SERIALINLOOP : or clkport, #clockh t set the clock high ref reset the carry flag push mtemp ; save temp ld mtemp, dioport read the port and mtemp. #doh mask out the bits jp. z, DONTSET set ; set the carry flag DONTSET: pop mtemp reset the temp value rlc serial ; get the bit into the byte and clkport, tclockl ; reset the clock low djnz mtemp, SERIALINLOOP ; loop till done ret ; return