Abstract:
A programmable limit switch employs high speed special purpose hardware and a general purpose microcontroller to achieve high speed limit switch operation. A state sequencer controls the high speed special purpose hardware in a fixed sequence. The state sequencer latches position data, and recalls position offsets from a memory. A hardware digital adder sums the position and offset with this summed offset position used as an address in output tables for selecting an output status word. The microcontroller operates asynchronously with respect to the state sequencer. The microcontroller initializes and updates the memories. The microcontroller calculates the velocity from repetitive position signals and writes the corresponding window offsets to memory. A selection circuit picks out the status bit of the particular output circuit. Thus unique ON/OFF offsets can be used for each circuit. The outputs are shifted together and latched to the output drivers. By this method the output update time is dependent on the rate of the state sequencer. Using fast logic the update time is greatly reduced over a software only implementation even by very fast microcontrollers.

Description:
TECHNICAL FIELD OF THE INVENTION 
     The technical field of the present invention is that of ON/OFF controllers and particularly such controllers that respond to position signals to control the ON and OFF intervals of a high speed operation. 
     BACKGROUND OF THE INVENTION 
     Position transducers can be applied to control the ON/OFF state of external circuits. Such a system monitors position and sets or resets one or more outputs at predefined positions or &#34;setpoints&#34;. The mechanisms controlled by this system usually have a constant delay from activation to the desired mechanical reaction. An offset can be added to the transducer position in order to activate the output circuit before its actual setpoint has been reached to compensate for this mechanical delay. As the velocity of the mechanical system increases, the time added by such a positional offset decreases. Therefore, a larger positional offset is needed to compensate for the same mechanical delay at higher speeds. In many mechanical systems the delay for mechanism activation is different from the delay for the deactivation of the mechanism. This requires two different positional offsets for delay compensation. When the circuit is OFF an ON offset is used, and when the circuit is in ON an OFF offset is needed. 
     Usually such a system is implemented in software by a microcontroller. The microcontroller reads the transducer position at fixed time intervals and calculates velocity. The microcontroller computes the offsets based on the calculated velocity and adds these offsets to the position. The microcontroller compares this offset position to a table of ON/OFF positions. The table entry specifies the desired output state. The microcontroller can control many circuits from one position reading. 
     This programmable microcontroller technique cannot operate at high speeds or with many simultaneously controlled circuits. As an example, consider a system controlling 16 circuits. Reading a 14 bit resolver at 1 rpm requires about 3.7 milliseconds per position. This allows about 230 microseconds per circuit for the 16 circuits being set for each position reading to do the operations listed above. Reading the same 14 bit resolver at 730 rpm requires 5 microseconds per position and leaves only about 310 nanoseconds per circuit for each of the 16 circuits. Reaching this speed with a general purpose computer is very difficult. Each loop requires an estimated 150 computer instructions. If the computer instructions require an average of 10 clock cycles, then a clock cycle rate of more than 4.8 billion per second is required. No readily available a general purpose computer is capable of achieving this rate. Computer hardware especially designed to be this fast is very expensive. 
     Therefore there is a need for application specific hardware to interface with the microcontroller to jointly implement the required operations at these speeds. 
     SUMMARY OF THE INVENTION 
     The present invention employs high speed special purpose hardware and a general purpose microcontroller to achieve high speed limit switch operation. A state sequencer having a fixed sequence controls the high speed special purpose hardware. The microcontroller operates asynchronously with respect to the state sequencer. The microcontroller initializes and updates memories employed by the high speed special purpose hardware in the control operation. 
     The microcontroller repetitively reads the transducer position through a dual port random access memory, calculates the velocity and writes the corresponding ON and OFF window offsets back to the dual port random access memory. The microcontroller also writes a table of output states based upon set points to a fast static random access memory. These functions are not critical for fast output update since the mechanical velocity changes relatively slowly and the set points are initialization data. 
     The state sequencer begins by latching the output of the position transducer. Then, the state sequencer addresses the ON or OFF offsets for each controlled circuit. A hardware digital adder then sums the position and offset signals. This summed offset position is used as an address in the output tables, selecting an output status word. A selection circuit picks out the status bit of the particular output circuit. Thus unique ON/OFF offsets can be used for each circuit. The outputs are shifted together and latched to the output drivers. By this method the output update time is not limited by the microcontroller speed. The output update time is dependent on the oscillator frequency of the state sequencer. Using fast logic the update time is greatly reduced over software implementation even by very fast microcontrollers. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     These and other objects and aspects of the present invention will become clear from the following description of the invention, in which: 
     FIG. 1 illustrates in block diagram form the programmable limit switch of the present invention; 
     FIG. 2 illustrates the equivalent internal structure of a programmable logic device illustrated in FIG. 1; 
     FIG. 3 illustrates the timing of a closing window operation; and 
     FIG. 4 illustrates the timing of an opening window operation. 
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     FIG. 1 illustrates the fast programmable limit switch of this invention in block diagram form. Microcontroller 1 controls the operation of the fast programmable limit switch. Microcontroller 1 initializes the system and controls processes that are not speed critical. State sequencer 16 operates special purpose hardware that receives the position data, selects and adds the offset and provides output signals to the controlled switches. State sequencer 16 thus controls the speed critical portions of the process. 
     This invention will be described in an example of a controller for a 16 head glue gun machine used for sealing packages. The 16 glue guns operate in a predetermined phase relationship from a single prime mover. Thus a single position transducer produces the data necessary for the ON and OFF control of all 16 glue guns. Those skilled in the art would realize from this example that this invention can be applied to similar control processes. 
     Microcontroller 1 initializes the system. Dual port random access memory 2 and fast static random access memories 9 and 10 require initial data for operation. Dual port random access memory 2 separately stores the ON and OFF position offset values for each of the 16 controlled glue guns. As mentioned above, these offset values are dependant upon speed of operation. Microcontroller 1 also creates an output pattern in one of the fast static random access memories 9 or 10 from a group of user entered setpoints. This output pattern corresponds to the respective ON and OFF states for particular sensed positions. The data stored in dual port random access memory 2 and fast static random access memories 9 or 10 are loaded and updated by microcontroller 1 in a manner further described below. 
     The state sequencer 16 controls the operation of the special purpose hardware of this invention. State sequencer includes a 10 MHz clock driving a counter. This counter addresses a bipolar registered programmable read only memory. Data recalled from this bipolar registered programmable read only memory drive the various state lines of state sequencer 16, which control the various hardware operations. One of the sequencer lines is decoded to reset the counter when the sequence is complete. 
     The sequence begins by activation of the convert line coupled to position transducer 8. This causes position transducer 8 to generate a position signal. The position transducer 8 can be any number of devices such as a resolver, encoder or linear transducer. In this example, the position transducer produces a digital output or has its output converted to digital form. In this example, the position transducer 8 generates a 14 bit output value corresponding to the position of the controlled machine within a repetitive cycle. 
     The ON offset is read from dual port random access memory 2 and supplied to the hardware adder 6. The address is set by a combination of a four bit circuit counter 4, an offset select line from state sequencer 16 and a memory select line from the dual latch 3. Four bit circuit counter 4 holds the circuit number. The offset select line from sequencer 16 selects either the ON or OFF offset for the particular circuit. The memory select line from dual latch 3 arbitrates between two areas of dual port random access memory 2. This permits microcontroller 1 to read from or write to one area of dual port random access memory 2 while state sequencer 16 controls the reading from the other area of dual port random access memory 2. Since microcontroller 1 controls dual latch 3, it can prevent conflicts for access to dual port random access memory 2. Dual port random access memory 2 preferably stores 16 bit words. The ON and OFF offsets are preferably 14 bits like the position signal. The two remaining bits are employed to select And/Or processing at programmable logic device 13 and to Enable/Disable programmable logic device 13. Hardware adder 6 adds the recalled offset to the current position data from position transducer 8. Using four 74F283&#39;s the 14 bit addition takes roughly 40 nanoseconds. 
     This sum is used as the address to the output tables of the fast static random access memories 9 and 10. Upon initialization at least one of fast static random access memories 9 and 10 includes output state data corresponding to sensed position. The sum includes the position signal from position transducer 8 and the corresponding offset. Programmable logic device 7 supplies the sum to the address input of one of fast static memories 9 and 10. A second memory select output from dual latch 3 selects the memory. The selected one of fast static random access memories 9 and 10 then outputs a data word containing the circuit output state. 
     Tri-state select device 11 routes this output data word to demultiplexer 12. The second memory select output of dual latch 3 controls tri-state select device 11 in the same fashion as programmable logic device 7. This memory select output controls programmable logic device 7 and tri-state select device 11 to insure that the data selected by the address from hardware adder 6 is supplied to demultiplexer 12. The data bit for the particular circuit is selected by the demultiplexer 12 using the address provided by circuit counter 4. This data bit is then latched into a flip-flop 21 of programmable logic device 13 as controlled by a latch signal from state sequencer 16. The internal circuits of programmable logic device 13 will be further described below in conjunction with FIG. 2. 
     This cycle is repeated for the same circuit with the OFF offset. State sequencer 16 changes the offset select line from selecting the ON offset to selecting the OFF offset. This provides a different address into dual port random access memory 2. Other portions of the address, which are specified by circuit counter 4 and dual latch 3, are unchanged. Hardware adder 6 adds this OFF offset position recalled from dual port random access memory 2 to the unchanged position signal from position transducer 8. The sum address an output state stored within the selected fast static random access memory 9 or 10. Tri-state select device 11 routes this output data word to demultiplexer 12, which selects the data bit for the particular circuit. 
     FIG. 2 illustrates the equivalent logic circuits included within programmable logic circuit 13. The data bit from the ON offset position stored in flip flop 21 and the data bit from the OFF offset position are logically combined. The And/Or bit from the offset recalled from dual port random access memory 2 selects the output of OR gate 22 or AND gate 23. Invertor 24 causes only one of AND gates 25 or 26 to be open. The output of AND gates 25 and 26 are combined in OR gate 27. The output of OR gate 27 is further combined with the Enable/Disable bit from the offset recalled from dual port random access memory 2 in AND gate 28. If enabled via the Enable/Disable signal, the combined value from the gate selected by the AND/OR signal is output. If disabled via the Enable/Disable signal, data corresponding to the OFF state is output. In either case this data is shifted into a 16 bit shift register within shift and latch circuit 14 as controlled by a shift signal from state sequencer 16. 
     These extra bits of the recalled offset permit greater flexibility in operation. The provision of an AND/OR bit in the recalled offset permits selection of either an AND or an OR window for each circuit. The Enable/Disable bit permits selective disabling of one or more of the controlled circuits, such as when a particular glue gun is not in use. Since these bits are part of the offset data stored in dual port random access memory 2, these features are under control of microcontroller 1. Note that the And/Or bit and the Enable/Disable bit may be stored in the ON offset or the OFF offset or both as selected by the designer. 
     The process of recall and combination of the ON and OFF offset data is repeated for each of the remaining circuits. Circuit counter 4 increments its count in response to a signal from state sequencer 16 on the increment line. This causes the address supplied to dual port random access memory 2 to refer to the next circuit This also causes demultiplexer 12 to select the data bit corresponding to this next circuit. The output data bits are combined in the manner previously described. Programmable logic device 13 selects the output of either OR gate 22 or AND gate 23 for application to shift and latch circuit 14 based upon the And/Or bit of the recalled offset. In response to a shift signal from state sequencer 16, shift and latch circuit 14 shifts the new data bit into the shift register and shifts the prior data bits along one position. This same process repeats for each of the 16 circuits. 
     The apparatus thus calculates the output state of all 16 circuits. The contents of the shift register in shift and latch circuit 14 now correspond to the proper output state for the 16 circuits. In response to a latch signal from state sequencer 16, shift and latch circuit 14 latches this set of states to the output drivers 15. This new data remains valid until completion of the next set of state computations. 
     Several additional steps are required to complete a cycle. State sequencer 16 permits the position signal from position transducer 8 and the output states of shift and latch circuit 14 to be stored in dual port random access memory 2. State sequencer 16 controls tri-state select device 5 to sequentially supply the position signal and the output signal to dual port random access memory 2 for storage. In each case the address where this data is stored is specified by counter 4. State sequencer 16 sends a latch signal to dual latch 3. This permits the memory select outputs of dual latch 3 to change. Regardless of the inputs to dual latch 3 from microcontroller 1, the memory select outputs can only change between update cycles. Thus switching memory areas within dual port random access memory or switching between fast static random access memories 9 and 10 cannot interrupt an update cycle. Finally, state sequencer 16 must reset circuit counter 4. This constitutes one output update cycle. 
     Programmable logic device 13 selects two types of windowing operations depending on the state of the And/Or bit of the recalled offset. Selecting AND gate 26 selects a closing window operation. Selecting OR gate 25 selects an opening window operation. FIGS. 3 and 4 illustrate examples of these windowing operations. These examples show the position of the apparatus sensed by position transducer 8 as divided into thirty six 10 degree segments, for a total of 360 degrees. This should be understood as illustrative only. Any practical device would determine position to much greater precision. 
     FIG. 3 illustrates an example of closing window operation. The desired ON and OFF set positions are shown in FIG. 3a). In this example, the circuit is programmed to turn ON (1&#39;s) at 250 degrees and to turn OFF (0&#39;s) at 300 degrees. In this example, the apparatus velocity is such that the apparatus requires 50 degrees of lead to turn ON and 70 degrees of lead to turn OFF. FIG. 3b) shows the ON offset set adding 50 degrees of positional offset. In FIG. 3b) the output turns ON at 200 degrees and turns OFF at 250 degrees. Similarly, FIG. 3c) shows the OFF offset set adding 70 degrees of positional offset. FIG. 3c) shows the output turning ON at 180 degrees and turning OFF at 230 degrees. 
     In closing window operation programmable logic device 13 selects the output of AND gate 26. FIG. 3d) shows the actual output pattern formed by AND&#39;ing the ON offset signal of FIG. 3b) and the OFF offset signal of FIG. 3c). The circuit turns ON at the leading edge of FIG. 3b) and OFF at the trailing edge of FIG. 3c). Thus the resultant output turns ON at 200 degrees, which is 50  degrees before the desired ON location of 250 degrees, and turns OFF at 230 degrees, which is 70 degrees before the desired OFF location of 300 degrees. Selection of closing window operation at programmable logic device 13 via the And/Or bit is appropriate as long as the ON offset is greater than or equal to the OFF offset. Microcontroller 1 is preferably programmed to automatically select a closing window operation via the And/Or bit of the offset if this is the case. 
     FIG. 4 illustrates an example of opening window operation. The desired ON and OFF set positions are shown in FIG. 4a). These are the same as illustrated in FIG. 4a). In this example, the apparatus velocity is such that the apparatus requires 70 degrees of lead to turn ON and only 50 degrees of lead to turn OFF. FIG. 4b) shows the ON offset output including 70 degrees of positional offset. In FIG. 4b) the output turns ON at 180 degrees and turns OFF at 230 degrees. FIG. 4c) shows the OFF offset including 50 degrees of positional offset, turning ON at 200 degrees and turning OFF at 250 degrees. 
     Selecting OR gate 25 via programmable logic device 13 selects an opening window operation. FIG. 4d) shows the output turning ON at 180 degrees, 70 degrees before the desired ON operation, and turning OFF at 250 degrees, 50 degrees before the desired OFF operation. Selection of opening window operation is appropriate as long as the ON offset is greater than or equal to the OFF offset. Microcontroller 1 is preferably programmed to automatically select an opening window operation via the And/Or bit of the offset if this is the case. 
     The closing and opening windows permit proper operation of the controlled device based upon the relative ON and OFF offsets. The controlled device always turns ON at the beginning of the ON offset and turns OFF at the end of the OFF offset. Rather than determine the two edges, the present invention selects one of OR gate 25 or AND gate 26 depending on the relative lengths of ON offset and the OFF offset. This technique provides greater flexibility than merely loading fast static random access memories 9 and 10 with the resultant output. Providing the window type selection in the offset stored in dual port random access memory 2 permits differing ON and OFF offsets to be specified for each circuit controlled. 
     The microcontroller 1 shown in FIG. 1 is separate from the special purpose high speed hardware. Virtually any microcontroller system could be used to embody microcontroller 1. In this particular example, microcontroller 1 is a 6502. The speed of operation of the microcontroller is not critical, because the special purpose high speed hardware updates the output states based upon position independent of the operation of the microcontroller. 
     As previously described, microcontroller 1 initializes dual port random access memory 2. Microcontroller 1 stores velocity based ON and OFF offsets corresponding to the estimated initial velocity in dual port random access memory 2. This provides state sequencer 16 access to the ON and OFF offsets needed in the control process. 
     Dual port random access memory 2 includes two ports to permit independent access via microcontroller 1 and via state sequencer 16. To facilitate this process, dual random access memory 2 is constructed in two sections. One section, as selected by a memory select output from dual latch 3, is employed for recall of the offsets used in device control under the control of state sequencer 16. The offset recall, which is time critical, is thus always available. Microcontroller 1 has access to the other section of dual port random access memory 2, and may switch sections by changing the data at dual latch 3. This switching of sections of dual port random access memory 2 can take place only at the end of a cycle of state sequencer 16. Note that this process prevents conflicts in accessing dual port random access memory 2. 
     The microcontroller 1 reads the transducer position 8 through the dual port random access memory 2. Microcontroller 1 calculates the velocity based on periodic reads of this position data from position transducer 8 stored in dual port random access memory 2. This permits calculation of velocity based ON and OFF offsets for each of the 16 circuits. As previously described, position data from position transducer 8 is written into one section of dual port random access memory 2. Microcontroller 1 gains access to this position data by periodically switching sections of dual port random access memory 2 via dual latch 3. 
     Microcontroller 1 computes new velocity based ON and OFF offsets upon detection of a change in velocity. These newly calculated ON and OFF offsets are then stored in the section of dual port random access memory 2 not selected by dual latch 3. Once these new offsets are written into dual port random access memory 2, microcontroller 1 writes into dual latch 3 to change the memory section available to the high speed control process. State sequencer 16 permits this change to become effective by sending the latch signal to dual latch 3 at the end of a cycle. 
     Microcontroller 1 also initializes fast static random access memories 9 and 10. Microcontroller 1 creates an output pattern in one of the fast static random access memories 9 or 10 from a group of user entered setpoints. Before initial use of the programmable limit switch, microcontroller 1 writes data into dual latch 3 to permit state sequencer 16 to access the one of the fast static random access memories 9 or 10 storing the desired output pattern. The memory select signal from dual latch 3 causes programmable logic device 7 to direct the output from hardware adder 6 to the selected memory. This memory select signal from dual latch 3 also causes tri-state select device 11 to route the data output from the selected memory to demultiplexer 12. 
     This memory select signal from dual latch 3 permits microcontroller 1 to access the other of the fast static random access memories 9 and 10. Programmable logic device 7 supplies the address from microcontroller 1 to the other memory. Tri-state selection device 11 also couples the data lines of this other memory to the data bus of microcontroller 1. Thus microcontroller 1 has read and write access to this other memory. Upon completion of a new output pattern, microcontroller 1 writes to the latch of dual latch 3 which supplies the memory select signal to programmable logic device 7 and tri-state select device 11. State sequencer 16 permits this change in state to become effective at the end of a cycle through the latch signal supplied to dual latch 3. This new memory select signal reverses the roles of fast static memories 9 and 10.