METHOD FOR CONTROLLING TASK PROCESS AND DEVICE THEREOF

Abstract: A task processing control device has: a plurality of input means (804, 1051); task processing means (807, 808) corresponding to said plurality of input means; selecting means (Table 1) for selecting a task to be executed in accordance with outputs from said plu­ rality of input means; and controlling means having task selection controlling means (804, 1053) for supplying the outputs from said plurality of input means to said selecting means at a predetermined pro­ cessing cycle, disabling means (809, CS) for disabling said plu­ rality of input means, said task processing means, said task se­ lecting means and said task selection controlling means for a disabling time when the task selected by said task selecting means is finished at a task end time and no further output is re­ ceived from said plurality of input means, and enabling means (INT, CS) for enabling said plurality of input means, said task processing means, said task selecting means and said task se­ lection controlling means in a next predetermined processing cycle.

Description: The present invention relates to a method for controlling task process and a device thereof and, more particularly, to a method for controlling task process and a device thereof used in, for example, a public telephone set which performs speech processing for telephone communication and other processing such as coin discrimination processing. In recent public telephone sets, processing such as speech processing for sending a dial signal and coin discrimination processing are performed by using a stored program type processor, i.e., a microprocessor. There are different types of processing or operations to be performed in this public telephone set. One is an irregular request such as coin discrimination accompanied by coin detection upon insertion of a coin, and the other is a regular, long-term request such as rate calculation accompanied by reception of a rate signal. In order to set the conventional public telephone in the different request modes, there are two types of conventional processing control systems: (a) one system wherein an irregular request such as coin discrimination requires quick response, so that a special circuit or computer is used to respond only to an irregular request, and (b) the other system wherein a clock frequency or processing cycle is determined on the basis of the response speed for the irregular request, so that both irregular and regular requests can be responded to and predetermined operations can be performed by a single computer. However, according to system (a), at least two computers must be used and the circuit arrangement becomes complicated. On the other hand, system (b) is operated such that the rate calculation program runs even without the rate calculation request, so that the computer is always operated, resulting in time loss and high power consumption. As a result, system (b) is not suitable for an office power supply type public telephone set since the power consumption thereof is limited. The document EP-A-12102 describes task processing control apparatus in the form of a public telephone set including the combination of processing means for detecting faults at points to be examined in accordance with the outputs from a plurality of sensors which detect clogging of the coin passageway as specified. Memory means stores a program for supplying an output signal to the processing means to cause the processing means to detect faulty points, and there is means operated by operation of the telephone hook switch to control the start of operation of the processing means and the memory means. The document thus in essence describes means and a program for self-diagnosis of faults in the public telephone set. It is, therefore, a principal object of the present invention to provide a method for controlling task process and a device thereof having low power consumption and a simple configuration for performing necessary operations. It is another object of the present invention to provide a method for controlling task process and a device thereof suitably used in a public telephone set. According to the present invention there is provided task processing control apparatus comprising: (a) generation means for cyclically generating base signals, each base signal having a period longer than the period of time required for processing a single task; (b) detection means for detecting received processing demands in response to each of said base signals; (c) memory means for storing, in predetermined memory locations, a plurality of task processing programs, each of said task processing programs being associated with a respective one of said processing demands; (d) selection means for selecting a single processing demand during each base signal, each said task processing demand having a predetermined order of execution priority and said selection means selecting demands to be executed in said predetermined order of execution priority from among those processing demands, if any, detected by said detection means; (e) address designation means, for designating in said memory means the location of the task processing program associated with said selected single processing demand; (f) task execution means for executing the task processing program in said memory location designated by said address designation means; and (g) idling mode control means for disabling said detection means, said selection means, said address designation means and said task execution means in response to the completion of the execution of said designated task processing program and in response to said selection means not selecting a task processing demand for execution. According to the present invention there is also provided a method for controlling task processes according to Claim 14. Embodiments of the present invention will now be described, by way of example, with reference to the accompanying drawings, in which: Figure 1 is a block diagram showing the overall configuration of a public telephone set to which is applied a task process control apparatus according to an embodiment of the present invention; Figs. 2 and 3 are respectively flow charts for explaining the main routine of the public telephone set shown in Fig. 1; Figs. 4A, 4B and 4C show waveforms of signals for explaining operations in the basic period and in a period which is an integer multiple of the basic period; Figs. 5 and 6 are respectively flow charts for explaining the timer operation of the public telephone set shown in Fig. 1; Fig. 7 is a memory map showing the timer control block in the public telephone set shown in Fig. 1; Fig. 8 is a flow chart for explaining input sensing in the public telephone set shown in Fig. 1; Fig. 9 is a flow chart for explaining a task ready flag set operation of the input sensing operation shown in Fig. 8; Fig. 10 is a flow chart for explaining a ready task check operation in the public telephone set shown in Fig. 1; Figs. 11 and 12 are respectively memory maps of task control blocks in the public telephone set; Fig. 13 is a flow chart for explaining a task start operation; and Fig. 14 is a block diagram of an operation determination circuit for the public telephone set. Fig. 1 is a block diagram showing the overall configuration of a public telephone set to which a task process device according to the present invention is applied. Referring to Fig. 1, the public telephone set comprises a telephone circuit device 10, a control device 20 for receiving a rate signal from a telephone office through the telephone circuit device 10 and for controlling coin collection or the like, and a coin processing device 30 for discriminating inserted coins in accordance with an instruction generated from the control device 20 and collecting the coins in a collection device (not shown) and for returning the coins to a return device (not shown). The telephone circuit device 10 is connected to the telephone office through office-line terminals L1 and L2. A bell circuit 100 for generating a bell sound when a ringing signal is received through a hook switch contact HS1, a rate signal receiving circuit 101 for detecting a rate signal, a diode bridge circuit 102, a power source circuit 103, a dial pulse sending circuit 104 and a speech circuit 105 are connected between the office-line terminals L1 and L2. When the hook switch contact HS1 is switched to the side opposite to that which the contact HS1 currently contacts upon operation of the hook switch, a DC loop including the speech circuit 105 is formed with respect to the office-line terminals L1 and L2. The diode bridge circuit 102 normally supplies a DC voltage of a predetermined polarity to the power source circuit 103 and the dial pulse sending circuit 104 irrespective of the polarity of the DC voltage applied from the office across the office-line terminals L1 and L2. The power source circuit 103 supplies a current received from the office through the diode bridge circuit 102 to a capacitor which is then charged, thereby providing an operating power source voltage to a central processing unit (CPU) to be described later. In this case, the power source circuit 103 is connected to the office-line terminal L1 through a resistor R having a high resistance. After the on-hook operation is performed, the power source circuit 103 generates a back-up power source voltage BUP to charge the capacitor and hence to protect the memory content of a random access memory (RAM). The dial pulse sending circuit 104 receives a dial pulse signal Di and sends it onto an office line. In this embodiment, the dial pulse signal Di is generated by a CDU 200 upon entry of a key input signal at a keyboard (not shown). The dial pulse signal Di is supplied to the dial pulse sending circuit 104 through an I/O interface circuit 203. In this case, a dial shunt signal Ds is supplied to the dial pulse sending circuit 104 to short-circuit the speech circuit 105 through the interface circuit 203 while the dial pulse signal Di is sent from the interface circuit 203 to the dial pulse sending circuit 104. As a result, pulse noise caused by the dial pulse signal Di will not be heard by a caller or calling party. A forced interruption signal is supplied to the dial pulse sending circuit 104 through the I/O interface circuit 203 when the inserted coins have been used up, thereby forcibly disconnecting the telephone circuit. The control device 20 comprises the CPU 200, a random access memory (RAM) 201 for storing processed data, a read-only memory (ROM) 202 for storing parameter data and permanent programs for coin and speech processing, the I/O interface circuit 203 and an I/O interface circuit 204. These interface circuits 203 and 204 exchange signals with various sensors or the like. The control device 20 further comprises a display 205 for displaying the value of inserted coins and various types of malfunction, a posture sensor 206 for detecting that the main unit of the telephone set is inclined by a predetermined angle or more, and a hook switch contact HS2 which is opened/closed upon on- and off-hook operations. The posture sensor 206 is arranged to prevent misuse of the telephone set. When the main unit of the telephone set is inclined by the predetermined angle or more, the forced interruption signal is generated to disconnect the telephone circuit. When a charge voltage of the capacitor in the power source circuit 103 upon the off-hook operation exceeds a predetermined value, the speech and coin processing programs run in the control device 20. When coin insertion and dialing are performed after the programs have been run, the dial pulse signal Di and the dial shunt signal Ds are generated. On the other hand, when the rate signal detection signal is received by the control device 20 from the rate signal receiving circuit 101 during telephone communication, a drive signal is supplied to a collecting magnet 308 (to be described later). In another case, when the number of collected coins becomes zero or the main unit of the telephone set is abnormally inclined, the forced interruption signal is generated. The coin processing device 30 comprises an optical sensor circuit 301 such as a coin insertion sensor (not shown), a material discriminating circuit 302 including a material detection coil (not shown), a thickness discriminating circuit 303 including a thickness detection coil (not shown), a diameter discriminating circuit 304 including a diameter detection coil (not shown), an A/D converter (ADC) 305 for selectively converting to a digital signal analog output signals from the discriminating circuits 302 to 304, an accumulating magnet 306 for operating an accumulating lever for accumulating authentic coins and a coin selector mechanism, a reset magnet 307, and the collecting magnet 308 for driving a lever for collecting coins in response to the rate signal. The operation of the public telephone set having the configuration described above will now be described in detail. In coin processing, all input signals are received by the CPU 200 at a processing cycle of 4 ms, and the signal statuses are discriminated. If an operation is requested to be performed, a task ready flag representing this request is set. When only one task ready flag is set, the operation corresponding to this task ready flag is performed during a remaining period of the processing cycle of 4 ms. However, when a plurality of task ready flags are set, the highest priority operation among the coin detection, display operation, and so on is performed during the remaining period. The next lower priority operation is performed in the next 4-ms processing cycle if a higher priority operation is not requested in this next 4-ms processing cycle, and so on. Therefore, during each 4-ms processing cycle, only a single operation such as coin detection is performed. When all these single operations are completed, the CPU 200 is set in the idling mode until an interruption (INT) is requested by the internal reference timer in the CPU 200. The respective operations are divided into first and second groups in accordance with their priorities. The operations belonging to the first group are performed one in every 4-ms processing cycle in the order from the higher priority operation to the lower one. The operations belonging to the second group are performed one in every 32-ms processing cycle (eight times the 4-ms processing cycle) from the higher priority operation to the lower one when any operation of the first group is not requested at the, time of the corresponding 32-ms processing cycle. In this embodiment, the operations are divided into the first group which is subjected to short-period (4 ms) execution and the second group which is subjected to long-period (32 ms) execution. In addition, the priority sequence is also given in each of the first and second groups in units of operations. When necessary operations of the first and second groups are completed in accordance with the priority sequence, the CPU 200 disables to supply chip selection signals to RAM 201, ROM 202, I/O interface circuits 203 and 204, and holds its disabling state. Thereafter the CPU 200 is set in the idling mode, that is in a sleeping state until a next 4-ms processing cycle is started. Normally, chip selection signals are supplied from the CPU 200 to necessary elements in accordance with the content of the program to be executed. With this construction, since the I/O interface circuits, the ROM and the RAM are not accessed during the idling state, low power consumption is established. It should be noted that the CPU 200 having the idling state may comprise Model HD6301V available from HITACHI. The basic operation of the CPU 200 will now be described with reference to Figs. 4A, 4B and 4C. As shown in Fig. 4A, the basic operation of the CPU 200 is performed in a cycle of 4 ms. During the first 1-ms time period of the 4-ms processing cycle, the CPU 200 receives all input signals and detects the contents or states of these signals. When operations are requested to be performed, the highest priority operation among them is performed during the remaining time period (i.e., 3 ms) of the cycle. Hatched periods A and B respectively correspond to the remaining time periods of the respective cycles. In this case, lower priority operations are also requested, they are performed in the subsequent 4-ms processing cycles unless the higher priority operation is requested in the corresponding processing cycles. On the other hand, when no operations are requested as a result of CPU detection, the CPU 200 is set in the idling mode. Therefore, the CPU, excluding a minimum period (e.g., oscillation system for 4-ms processing cycle), together with the ROM and the I/O interface circuits are kept in the disabling state. As a result, useless power consumption can be prevented. Figs. 4B and 4C are respectively detailed charts showing 1-ms periods of the input operations of the 4-ms cycles, respectively. In fine, about 3 ms (check operation and task processing operation) are subjected to large power consumption in the 4 ms processing cycle, so that the remaining 1 ms can be used for power supply recovery. The operations performed by the CPU 200 are summarized in Table 1 and have the following priority order or sequence. Since the operation sequence described above is employed in this embodiment, the RAM 201 has task ready flags corresponding to the respective operations whose data are stored in corresponding memory areas therein. When the task ready flags are selectively set at logic "1", the corresponding operations are performed. When the operations are completed, the corresponding task ready flags are reset at logic "0". The RAM 201 also has soft timer registers for controlling the ON time of the accumulating magnet 306 or the like. The respective operations shown in Table 1 will be described in detail with reference to the flow charts in Figs. 2 and 3, Figs. 5 and 6, and Figs. 8 to 10. It should be noted that the telephone circuit device 10 and the coin processing device 30 are not directly concerned with the scope of the present invention, and a detailed description thereof will be omitted. Fig. 2 is a general flow chart for explaining the operation of the CPU 200. When the charge voltage of the capacitor built into the power source circuit 103 reaches a predetermined voltage (+V) upon the off-hook operation, the general flow is started. In step 800, the CPU 200 initializes buffer registers in the I/O interface circuits 203 and 204 and various data registers arranged in the RAM 201. The CPU 200 starts a self diagnosis program and checks in step 801 whether or not the coin sensor and the like are abnormally operated, and whether or not the collecting section (not shown) is full. The contents of self diagnosis program are described in European Patent Publication No. 0012102A1. When the CPU 200 detects that normal communication can be performed, the flow advances to step 802. However, when an abnormality is detected in the coin sensor or the collecting section is full, the corresponding flag is set first and the flow then advances to step 802. In self diagnosis step 801, when the CPU detects an abnormality, an abnormality display is performed at the display 205 in accordance with the content of the flag in the display operation in step 880 (Fig. 3). In step 802, the CPU 200 sets a first reference timer to have a processing cycle of 4 ms as the operation cycle of the first group and causes the first reference timer to start. The first reference timer is arranged in the CPU 200. Thereafter, the CPU 200 checks in step 803 whether or not any operating soft timers among the plurality of soft timers arranged to count the ON time of the accumulation magnet 306 or the like are present. If any operating soft timer is present, the count of this soft timer is incremented. Finally, the CPU 200 checks whether or not the count of the soft timer has reached a predetermined value. When "time over is detected, the CPU 200 deactivates the accumulating magnet 306. In this case, steps 802 to 809 are performed in every 4-ms cycle set by the first reference timer. For example, the ON time of the accumulating magnet 306 becomes several hundred microseconds. For this reason, a first frequency-division timer which repeats counting every 32-ms processing cycle (eight times the 4-ms processing cycle) and a second frequency-division timer which repeats counting every 896-ms processing cycle (28 times the 32-ms processing cycle) are provided. The timer having the period of several hundred microseconds is counted by the first frequency-division timer. When a timer has a period longer than one second, the second frequency-division timer is used. The frequency-division timers are arranged as soft timers in a memory area of the RAM 201. The time counting function of each soft timer is not only used to count the ON time of the accumulating magnet 306 but is also used as a timer for supplying, to the corresponding register, read address signals for the program (e.g., accumulation detection) to be performed with predetermined start and end times. Thus, the soft timers are used to count the ON times of the accumulating magnet 306 and the reset magnet 307. In other words, the time counting functions of the respective soft timers are selectively defined by the operations shown in Table 1. After definition of the time counting functions, the count in the timer operation is updated. In this case, the definition of the time counting function is determined by the operation content to be performed with the specified end (time up) time. In input sensing, the CPU 200 detects all signals supplied thereto in step 804. These signals are output signals generated from the rate signal receiving circuit 101, the posture sensor 206, the hook switch contact HS₄, the sensor circuit 301, and output signals from a test switch (not shown) of the coin processing function and a dial button (not shown) of a keyboard. The CPU 200 is operated based on the detection results and checks in ready task checking step 805 whether or not any single operations such as coin detection are to be performed. If the CPU 200 detects that a single operation is requested, the corresponding task flag is set in the task flag register. The CPU 200 then checks in step 806 in accordance with the priority order shown in Table 1 whether or not the task ready flags corresponding to the respective single operations are set. If NO in step 806, the flow advances to step 809, and the CPU 200 is set in the idling mode. However, when any one of task ready flags corresponding to the respective operations shown in Table 1 are set, the start address of the highest priority operation corresponding to the "set" task ready flag is set in the program counter in the task start operation. The address set in the program counter is used as the start address of the single operation program in task execution in step 808. In other words, steps 810 to 900 in Fig. 3 are performed. When the single operation or operations are completed, the CPU 200 is set in the idling mode in step 809, so that most of the functions of elements (e.g., the I/O interface circuits 203 and 204, the ROM 202, the RAM 201 and the CPU 200 excluding the 4-ms oscillation system) are set in the disabling state. When a new interrupt that indicates a new processing cycle of 4 ms is generated from the first reference timer, the flow returns to step 802. Thereafter, the same operation as described above is repeated. In this case, the task ready flag of each executed single operation is reset when the corresponding start address is set in the program counter. For this reason, the second highest priority operation is performed in the next operation cycle. The task ready flags for the operations of the second group are subjected to set/reset detection when the CPU 200 detects that the timer period (i.e., 32 ms) of the second reference timer in the ready task check operation in step 805 has elapsed and that none of the task ready flags of the operations of the first group is set. The CPU 200 starts the second reference timer (which defines the 32-ms cycle of the single operations of the second group) in the ready task check operation in step 805 when the operation requests of the first group are not present or completed immediately after the off-hook operation. Thereafter, every time step 805 is performed, the count of the second reference timer is updated. When the timer time has elapsed, the timer is restarted when the operation requests for the first group are not present. For this reason, the single operations belonging to the second group can be performed when the cycle of 32 ms has elapsed since the operation requests for the first group becomes zero after the off-hook operation. Thereafter, when the operation requests for the first group are not present, the operations of the second group are performed for every 32-ms cycle. All operations concerning speech processing and coin processing are divided into single operations which are then performed at every 4- or 32-ms cycles in accordance with their priority orders. When the operation is completed, the CPU 200 is set in the idling mode. Therefore, when coin detection belongs to the first group having a higher priority, quick response can be provided at low power consumption. As is apparent from the above description and Fig. 4A, the basic operation of the CPU 200 is performed such that input operation is performed for the first 1-ms period of each of the 4-ms processing cycle. When the CPU 200 detects that a single operation is to be performed, the operation is performed in the following 3-ms period of the 4-ms processing cycle. The first 1-ms period of the 4-ms processing cycle is shown enlarged in Fig. 4B. The 4-ms cycle is set in the first reference timer in step 802, and the first reference timer starts counting of clock pulses. The timer set operation is followed by the input sensing step 804 in Fig. 2. In practice, the decrement operation (step 1000 in Fig. 5) of a first frequency divider timer (to be described later) is performed immediately after the timer set operation, although not shown in Fig. 4B. However, this decrement operation is not the main operation of the timer, and a detailed description thereof will be omitted. The CPU 200 receives all signals generated from the rate signal receiving circuit 101, the posture sensor 206, the hook switch contact HS2, and the coin processing device 30. The reception of all signals corresponds to time period D in Fig. 4B. The ready task check operation is performed after this input operation and is illustrated as time period E in Fig. 4B. This operation corresponds to step 805 in Fig. 2. In this step, the CPU checks whether or not single operations such as coin detection are requested. If single operations are requested, the corresponding task flags are set in the task flag memory. The task operation of a highest priority in accordance with a predetermined priority order and having a set flag is performed after the 1-ms period of the 4-ms processing cycle has elapsed. This operation corresponds to steps 807 and 808 in Fig. 2 and continues for substantially 2 ms. The single operations are performed for every 32-ms cycle in accordance with the outputs from the first reference timer and first and second frequency divider timers, as shown in Fig. 4C. This 1-ms period include all operations performed in that of the 4-ms cycle. In addition, the 1-ms period in Fig. 4C also includes time period F for timer operation. The operations of the second group are performed for every 32-ms processing cycle when the task flags of the operations of the first group are not set. The timer operation associated with the task operation of the second group is performed in a time period after the time period C for the timer set operation. The timer operation for ending operation of the elements executed in the task processing is performed in this time period F, and a detailed description will be made with reference to Fig. 5. The decrement operation of the first frequency divider timer which is already started, and the initialization of the first frequency divider timer are performed. For example, "08" is set in the first frequency-division timer of the down counter, so that the first frequency-division counter starts counting the number of the 4-ms cycle at a 32-ms cycle which is eight times the 4-ms cycle. An output from the first frequency-division timer is frequency-divided to cause the second frequency-division counter to count the number of the 32-ms cycle at a 896-ms cycle which is 28 times the 32-ms processing cycle. The counts of the first frequency-division timer FAT and second frequency division timer SAT are shown above the waveform in Fig. 4A. This operation is performed in step 803 in Fig. 2. The input sense operation and the ready task check operation are performed after the timer operation. When the 1-ms period has elapsed, the task operation is performed during the remaining period of the 4-ms cycle. The operations of the first group are shown in steps 810 to 850 in Fig. 3, respectively. Coin detection (step 810) among these operations has the highest priority than those of other operations when the coin insertion is detected by the optical sensor circuit 301 and the coin detection task ready flag is set. In coin detection, the coin discrimination timer is started to prevent erroneous accumulation when the coins are continuously inserted. At the same time, the operating power source voltage is applied to the thickness discriminating circuit 303 for discriminating the thickness of the coin and the diameter discriminating circuit 304 for discriminating the diameter of the coin, only while the coin discrimination timer is operated. In this case, the power ON/OFF operation of the circuits 303 and 304 is performed through the I/O interface circuit 204. Coin data input operation step 820 is performed when the coin data input operation task ready flag is set by the coin discrimination timer to represent the coin data input operation request. In this coin data input operation, the material, diameter and thickness data of the coin are supplied to the CPU 200 through the A/D converter 305 and the I/O interface circuit 204. The input data are respectively compared with the preset data, so that the authenticity and type of the inserted coin are discriminated. As a result, when the inserted coin is authentic, the accumulating magnet 306 is driven to guide this authentic coin along the accumulation path. However, when the inserted coin is detected to be a false coin, the accumulating magnet 306 will not be driven. The false coin is returned to the coin return port. The accumulation detection in step 830 is performed when the coin reaching the accumulation path is detected by the accumulation sensor and the corresponding task ready flag is set. In this accumulation detection, a denomination of the inserted coin is determined in accordance with the data representing type of the inserted coin, and the denomination data is stored in a memory area of the accumulation amount memory in accordance with the priority order of accumulation. At the same time, a remaining amount of coins already stored in the collecting device (not shown) and the accumulated amount stored in the accumulation memory are added, so that an amount indicating the remaining time of speech is calculated. In addition, the accumulating magnet 306 is deenergized. When a predetermined time has elapsed, the reset magnet 307 is energized for a predetermined time, thereby switching to the return side the accumulation lever (not shown) which has been moved in the accumulation side by energization of the accumulating magnet 306. In accumulation detection, the task ready flag is set to display the amount which indicates the remaining time of speech. Thereafter, when the display operation for the second group is permitted, the amount indicating the remaining time of speech is displayed in number on the display 205. Collection detection in step 840 is performed when the collecting magnet 308 is driven upon reception of the rate signal to move a collection lever (not shown) to the collection side, thereby causing a collection sensor to detect through the collection lever the coin which reaches the collection path, and when the corresponding task ready flag is set in accordance with the detection result. In this collection detection, the collected amount is subtracted from the amount stored in the accumulation memory, and an amount indicating the remaining time of speech can be calculated in the same manner as in accumulation detection. The collecting magnet 308 is deenergized, so that the collection lever held in the collection side upon energization of the collecting magnet 308 is returned to the non-collection side. The dial control operation in step 850 is performed when dial button operation is performed after the off-hook operation is performed and then at least one authentic coin is accumulated in the accumulation path, and when the corresponding task ready flag indicating the dial control request is set upon detection of rising (or falling) edge of the dial signal which is caused by dial button operation. In this dial control operation, the dial signal Di and the dial shunt signal Ds are supplied to the dial pulse sending circuit 104 through the I/O interface circuit 203. The respective operations belonging to the second group are shown in steps 860 to 900 in Fig. 3. The rate calculation operation in step 860 is performed when the task ready flag which indicates the rate calculation request is set upon detection of the leading edge of the rate signal. In this rate calculation operation, a task ready flag which indicates the collection decision request of the next step 870 is set. The collection decision operation is performed when a new operation cycle (i.e., 32 ms) of the second group is set. When the amount indicates a sufficient remaining time of speech, the rate calculation amount is subtracted from the amount indicating the sufficient remaining time. However, when the remaining amount is smaller than the rate calculation amount, the collecting magnet 308 is energized to collect the coins stored in the accumulation path. One accumulated coin is collected in the collection device. For this purpose, the collecting magnet 308 is energized to guide the coin in the collection path, and the collection sensor performs collection detection step 840. The display operation in step 880 is performed to display an amount which indicates a remaining time of speech when another coin is accumulated in the accumulation path or is collected in the collection device and the corresponding task ready flag is set. On the other hand, when the collection device is filled with coins or the coin insertion sensor is abnormally operated, the display operation is performed under the condition that the corresponding task ready flag is set. The amount which indicates the remaining time of speech or the abnormal state is displayed at the display 205 in accordance with the contents of the respective task ready flags. The display operation task ready flag is set every time a display output is required for the self diagnosis, the accumulation detection or collection detection. The hook operation in step 890 is performed when the leading edge of the output signal from the hook switch contact HS2 upon off- or on-hook operation or a reverse flow (caused by inclination of the main unit of the public telephone set) of the coin detected by the reverse flow sensor, and the hook operation task ready flag is set in accordance with the detection of the leading edge of the output signal or the reverse flow detection. In the hook operation, when the task ready flag is set upon the on- or off-hook operation, the corresponding operation is performed. However, when the task ready flag is set upon the reverse flow detection, the forced interruption signal is supplied to the dial pulse sending circuit 104, thereby forcibly interrupting communication. The test mode operation in step 900 is performed when a test switch (not shown) is operated at the time of maintenance operation, and the test mode operation task ready flag is set. In the test mode operation, all functions are tested. Figs. 5 and 6 are flow charts for explaining the timer operation in step 803 in Fig. 2. In step 1000, the CPU 200 decreases the count (timer time of 32 ms) of the first frequency-division timer by one unit (4 ms). The CPU 200 then checks in step 1001 whether or not the count of the first frequency-division timer becomes zero. If YES in step 1001, the CPU 200 sets the first frequency-division timer with the 32-ms processing cycle in step 1002, so that this timer is restarted. However, if NO in step 1001, the subroutine returns to the main routine in Fig. 2, and the input sense operation is performed. When the first frequency-division timer is restarted under the control of the CPU 200, the CPU 200 checks in step 1003 the statuses of the plurality of soft timers for receiving the output from the first frequency-division timer. When the CPU 200 detects any soft timer in use, the timer time of this soft timer is decreased by one unit (32 ms). In addition, when the CPU 200 detects any soft timer which is set in the "time over" state (i.e., the count thereof is zero), the corresponding operation is performed. As shown in Fig. 7, the soft timer is constituted by a memory area of the RAM 201 and comprises a flag memory area M1 for storing time count data flags, a memory area M2 for storing timer count data (timer time data) which represents a time period from the start time to the current time, and memory areas M3 and M4 of upper and lower addresses of the program stored in the ROM 202 and to be executed in the "time over" state. A plurality of soft timers constitute a first timer block which receives the output generated from the first frequency-division timer. As the detailed flow of the timer operation is shown in Fig. 6, in step 1010, the CPU 200 sets the start address of the first timer block and reads out the flag data from the memory area M1 of the first soft timer. The CPU 200 checks in step 1011 whether or not the first soft timer is being used. If NO in step 1011, the flow jumps to step 1017 wherein the start address of the second soft timer is set. The flow returns to step 1011 through the decision step 1018, and the flag data is read out from the memory area M1 of the second soft timer. The CPU 200 then checks in step 1011 whether or not the second soft timer is being used. If YES in step 1011, the flow advances to step 1012 wherein the count of the second soft timer is decreased by one unit (32 ms). The CPU 200 checks in step 1013 whether or not the preset timer time has elapsed. When the count of the memory area M2 of the second soft timer is set to be "0" (i.e., when the second soft timer is set in the "time over" state), the flag is reset in step 1014. In step 1015, the start addresses of the program to be performed in the "time over" state of the corresponding timer are read out from the memory areas M3 and M4 of the second soft timer. The readout address data are set in a program counter. In step 1016, this program is performed. Thereafter, in step 1017, the CPU 200 sets the start address of the third soft timer. The flow returns to step 1011 through the decision step 1018. However, when the count of the second soft timer does not become zero, the flow jumps from step 1013 to step 1017. The start address of the third soft timer is set, and the flow returns to step 1011 through the decision step 1018. The CPU 200 repeats the operation described above. When the operations of the soft timers using the output generated from the first frequency-division timer are completed, the flow advances to step 1004 of Fig. 5 through the decision step 1018. In step 1004, the CPU 200 decreases the timer time (896 ms = 32 ms x 28) of the second frequency-division timer by one unit (32 ms). The CPU 200 then checks in step 1005 whether or not the count of the second frequency-division timer becomes zero. When the CPU 200 detects that the count of the second frequency-division timer is zero, the CPU 200 sets the second frequency-division timer with the 896-ms processing cycle in step 1006, so that this timer is restarted. However, if the CPU 200 detects that the count of the second frequency-division timer is not zero, the subroutine returns to the main routine in Fig. 2, and the input sense operation is performed. When the CPU 200 restarts the second frequency-division timer, in step 1007, the same operation (step 1003) as described above with reference to the plurality of soft timers using the output generated from the second frequency-division timer is performed, and the subroutine returns to the main routine in Fig. 2. Figs. 8 and 9 show a detailed flow of the input sense operation in step 804 of Fig. 2. In step 1050, the CPU 200 enables a read signal to read all input signals supplied thereto. In step 1051, the CPU 200 detects the states of all input signals. In step 1052, the CPU 200 disables the read signal. In step 1053, the task ready flags which represent single operation requests such as coin detection request are set in accordance with the signal state detection under the control of the CPU 200. Fig. 9 shows a detailed flow of step 1053. When the CPU 200 detects the edge (leading edge or trailing edge) of the output signal generated from the coin insertion sensor in accordance with the input singal state detection, the CPU 200 determines that the coin has been already inserted, so that the task ready flag (TRF) for coin detection is set in Step 1061. On the other hand, when the CPU 200 detects the edge of the output signal generated from the reverse flow sensor in step 1062, the CPU 200 determines that a reverse flow has occurred and the task ready flag for the hook operation is set in step 1063. When the CPU 200 detects the edge of the output signal generated from the accumulation sensor in step 1064, the CPU 200 determines that the coin has reached the accumulation path and the task ready flag for the accumulation detection is set in step 1065. When the CPU 200 detects the edge of the output signal generated from the collection sensor in step 1066, the CPU 200 determines that the accumulated coin has reached the collection device, so that the task ready flag for the collection detection is set in step 1067. When the CPU 200 detects the edge of the output signal generated from the hook switch contact HS2 in step 1068, the CPU 200 determines that the on- or off-hook operation has been performed, so that the task ready flag for the hook operation is set in step 1069. When the CPU 200 detects the edge of the output signal generated from the dial button in step 1070, the CPU 200 determines that dialing has been already performed, so that the task ready flag for the dial control operation is set in step 1071. Similarly, when the CPU 200 detects the edge of the output signal generated from the test switch in step 1072, the CPU 200 determines that the maintenance operation has been performed, so that the task ready flag for the test mode operation is set in step 1073. When the CPU 200 detects the edge of the rate signal in step 1074, the CPU 200 determines that the rate signal has been received, so that the task ready flag for the rate calculation operation is set in step 1075. When the CPU 200 detects that the coin discrimination timer is being operated by referring to its flag in step 1076, the CPU 200 sets the task ready flag for the coin data input operation in step 1077 so as to start the discrimination of the inserted coin. In this manner, the CPU 200 sets the task ready flags for the respective single operations in accordance with the statuses of all input signals, and the corresponding subroutines are ended and the flow returns to the main routine in Fig. 2. When the CPU 200 detects the edge of the output signal generated from the posture sensor 206, the task ready flag for the hook operation is set. Fig. 10 shows a detailed flow of the ready task check operation in step 805 of Fig. 2. The CPU 200 sets value "05" in an index B in step 1080. The value "05" represents the number of single operations of the first group. The statuses of the respective single operations of the first group, the start address data of a task control block having the start address data of the respective single operations are temporarily stored in the X register. The start address data of the task control blocks are sent onto the address bus. More particularly, the task control block for controlling the respective single operations of the first group comprises five memory areas M1 to M5 for each single operation such as coin detection, as shown in the memory map of Fig. 11. The memory areas store the task ready flags for the respective single operations, current status flags (e.g., flags for indicating the operation statuses of the single operations), and the address data (from the start address to the third address in the order named) of single-operation programs stored in the ROM 202. In order to detect which one of the single operations of the first group is requested, the CPU 200 supplies the start address data of the task control block onto the address bus in step 1081. In step 1082, the flag data of coin detection is fetched from the start address of the task control memory area M1 to the accumulator (ACC) in the CPU 200. Thereafter, the CPU 200 checks in step 1083 in accordance with the content of the accumulator whether or not the coin detection task ready flag (TRF) is set. If YES in step 1083, the flow returns to the main routine of Fig. 2 through steps 1088 and 1089, and coin detection is performed. However, when the task ready flag for coin detection is not set, the flow advances from step 1083 to step 1084. In step 1084, value "3" (decimal notation) is added to the address data stored in the X register. A sum is sent as the address data of the task control block onto the address bus. Thereafter, in step 1085, the content of the index B is decremented by one. After the CPU 200 discriminates that the updated value is not zero in step 1086, the flow returns to step 1082. In step 1082, the coin data input operation flag, data is fetched from the start memory area of the task control memory area M2 to the accumulator in the CPU 200. In the same manner as described above, the CPU 200 checks in accordance with the content of the accumulator whether or not the coin data input operation task ready flag is set. When the CPU 200 determines that this flag is set, the flow returns to the main flow of Fig. 2, and coin data input operation is performed. In this manner, the CPU 200 checks the logic states of the task ready flags. When the CPU 200 detects the task ready flag of logic "1", the subroutine is ended and the flow returns to the main routine shown in Fig. 2 wherein the corresponding single operation is performed. However, when the CPU 200 cannot detect any task ready flag of logic "1" before the contents of the index B become zero (i.e., when no request for the single operations of the first group is detected), the flow advances to step 1087 through step 1086. In step 1087, the CPU 200 checks whether or not the timer time (FAT) of the second reference timer (processing cycle of 32 ms) for defining the operation cycle of the single operations of the second group has elapsed (i.e., whether or not the count of the second reference timer becomes zero). If YES in step 1087 (i.e., if FAT = 0), the CPU 200 sets the second reference timer with the 32-ms processing cycle in step 1090. In step 1091, value "05" which represents the number of single operations of the second group is set in the index B. Thereafter, in the same manner as in the case wherein the presence/absence of the request for the single operation of the first group is detected in steps 1082 to 1086, the presence/absence of the request for the single operation of the second group is detected. As shown in a memory map of Fig. 12, each task control block for controlling the single operations of the second group consists of five memory areas M1 to M5 of each single operation such as rate calculation. The memory areas store the task ready flags for the respective single operations, current status flags (e.g., flags for indicating the operation statuses of the single operations), and the address data (from the start address to the third address in the order named) of single-operation programs stored in the ROM 202. In the same manner as the detection of the presence/absence of the request of the single operation of the first group, the CPU 200 causes the X register to temporarily store the start address data of the task control block of the second group in step 1092. The start address data of the task control block is supplied onto the address bus. The CPU 200 detects the presence/absence of the request of the single operation of the second group in steps 1082 to 1086. As a result, when the CPU 200 detects the request for any one of the single operations of the second group, the flow jumps from step 1083 to step 1088. The flow then returns to the main routine of Fig. 2 through steps 1088 and 1089, and the corresponding single operation is performed. The addresses are assigned to the task control blocks of the first and second groups in accordance with the priority operations. Therefore, the presence/absence of the requests for the single operations of the first and second groups is detected from the higher priority order to the lower priority order. The presence/absence of the requests for the single operations belonging to the second group is detected only when the request for none of the single operations of the first group is present and the timer time of the second reference timer has elapsed. This is because steps 1086 and 1087 are given as conditions for the detection of the presence/absence of the request for the second group. In this case, the timer time of the second reference timer is decremented by 4 ms in step 1089 every time the ready task check operation of Fig. 10 is performed. When the timer time (FAT) of the second reference timer has elapsed in step 1088, the timer time is not set again in the second reference timer in step 1089 so as to prevent the timer count of the second reference timer from being negative. Fig. 13 shows a detailed flow of the task start operation in step 807 of Fig. 2. In step 1100, the CPU 200 resets the task ready flag (TRF) in the given task control memory area wherein the single operation request of this task ready flag is detected first. Thereafter, in step 1101, the start address of the signal operation program is read out from the given task control memory area. This start address is set in the address counter. Thereafter, the flow returns to the main routine of Fig. 2, and the corresponding single operation is performed in accordance with the program. As has been apparent from the above description, the all operations concerning speech processing and coin processing are classified as single operations whose priority order is predetermined. Operation requests are detected in the priority order, and the single operations are performed in a 4- or 32-ms cycle. When the single operations are completed, the CPU 200 is set in the idling state. Therefore, the irregular single operation such as coin insertion detection belongs to the first group which has a higher priority than the second group, so that quick response to the irregular operation can be provided. In addition, when the irregular operation is completed, the operations of the second group are performed for at least a processing cycle of 32 ms. During this processing cycle, the CPU 200 is set in the idling state, thereby achieving low power consumption. According to the embodiment as described above, there is provided a public telephone set processing control system, wherein respective processing contents of a public telephone set are divided into a plurality of groups in accordance with their priorities, a priority sequence of operations in each of the groups is specified, execution requests for the respective processing contents are detected for every basic period, a predetermined single sequence of the highest priority group is performed during the basic period in accordance with the detection result obtained, and single sequences of groups including the highest-priority group and the lower priority groups are performed at periods which are integer multiples of the basic period. The public telephone set can perform processing in a simple manner at low power consumption. Therefore, the control system can be applied to the office power supply type public telephone set whose power consumption is limited, thereby providing a telephone set with high performance at low cost. In the above embodiment, the order of operation data in the memory is predetermined in units of groups and in accordance with the priority order. The addresses are sequentially accessed to perform the subsequent operations. However, the groups and the priority orders can be controlled by software. Fig. 14 is a block diagram of an improved control system of the system of the above embodiment. Referring to Fig. 14, data of the public telephone set are supplied to an input detector 50 from the telephone circuit 10, the coin processing device 30, the posture sensor 206 and the hook switch HS2 shown in Fig. 1 device. The input detector 50 receives the input data in response to a pulse (having a relatively short processing cycle of 4 ms) generated from a pulse generator (PG) 53. An output from the input detector 50 is supplied to an operation determination circuit 60. The pulse generator 53 normally generates 4-ms pulses. When the input detector 50 detects no input, it supplies an idle signal S1 to a chip selection circuit 55 a control circuit 80. The chip selection circuit 55 controls enabling/disabling operations of elements 50, 61, 63, 64, 70 and 71 in accordance with the pulse generated from the pulse generator 53, the idle signal S1 and the output from a control circuit 80 (to be described later). A pulse generator 56 also receives the output (4 ms) from the pulse generator 53 and normally generates a 32-ms pulse in synchronism with the 4-ms pulse. A group determination circuit 61, first and second priority determination circuits 63 and 64, and a NAND gate 65 constitute an operation determination circuit 60. The group determination circuit 61 analyzes the signal supplied through the input detector 50 and determines which group shown in Table 1 includes the single operation represented by this input signal. For example, when the signal represents coin detection, this signal belongs to the first group. However, when the signal represents the hook operation, it belongs to the second group. In the previous embodiment, the position of the supplied signal stored in the RAM clearly represents the group to which this signal belongs and the priority order of the group. However, in Fig. 14 a given signal can be compared with reference data to determine which group includes the single operation represented by the given signal. The outputs from the group determination circuit 61 are supplied to the first and second priority determination circuits 63 and 64, respectively. The first priority determination circuit 63 determines a priority order of the signals belonging to the first group. Every time the circuit 63 receives the 4-ms pulse from the pulse generator 53, an output is supplied from the circuit 63 to a first memory 70. The memory 70 is accessed by the output from the circuit 63 and a program stored in a predetermined memory location in the memory 70 corresponding to a task to be executed is read out. At the same time, the output of logic "1" from the first priority determination circuit 63 is supplied to the NAND gate 65 which is then disabled. The second priority determination circuit 64 determines the highest priority signal among the signals of the second group which are supplied from the group determination circuit 61. The highest priority signal is supplied to the NAND gate 65 in response to a 32-ms pulse. The NAND gate 65 is enabled only when the output from the first priority determination circuit 63 is not supplied to the NAND gate 65 and then the output generated from the second priority determination circuit 64 is supplied to a second memory 71. The memory 71 is accessed by the output from the circuit 64 and a program stored in a predetermined memory location in the memory 71 corresponding to a task to be executed is read out. In this case, the first and second priority determination circuits 63 and 64 may compare outputs generated from the group determination circuit with reference data to select the highest priority signals, respectively. Alternatively, as described in the above embodiment, the priority order may be determined in accordance with storage locations of the respective memories. A control circuit 80 performs predetermined control operation in accordance with the programs read out from the first and second memories 70 and 71. When the control circuit 80 performs the task in accordance with the program, it is put in the idling state. At the same time, it supplies an idle signal to the chip selection circuit 55 so that no chip selection signal (disabling signal) is sent out to the elements 50, 61, 63, 64, 70 and 71 so that they are deenergized to be maintained in a sleeping state. When the control circuit 80 receives a next 4-ms output from the pulse generator 53, it changes the sleeping state into an enabling state to receive the output of the first or second memory 70 or 71. At the same time, sending the idling signal to the chip selection circuit 55 is stopped. As described before, the idling signal S1 is sent out from the input detector 50 when no signal is sent out. The idling signal S1 is supplied to the chip selection circuit 55 and the control circuit 80 to set them in disabling states. These disabling states are released when the next 4 ms-output from the pulse generator 53 is generated. During execution of a task such as the rate calculation, an additional task such as the decision of coin collection is required. In such case, the control circuit 80 performs forced interruption program where there is no coin when a rate signal is received. Then the control circuit 80 supplies a forced interruption control signal to the group determination circuit 61 through a line 80a for causing execution of a program of the forced interruption stored in the second memory 71. By way of simplicity, the description with reference to Fig. 14 is confined only to the part associated with main feature of the above embodiment. In addition to the telephone set, the present invention can be applied to other types of devices for performing a plurality of tasks.

Claims: Task processing control apparatus comprising: (a) generation means (201,802) for cyclically generating base signals, each base signal having a period longer than the period of time required for processing a single task; (b) detection means (204,804) for detecting received processing demands in response to each of said base signals; (c) memory means (202) for storing, in predetermined memory locations, a plurality of task processing programs, each of said task processing programs being associated with a respective one of said processing demands; (d) selection means (201, 805,806) for selecting a single processing demand during each base signal, each said task processing demand having a predetermined order of execution priority (table 1) and said selection means selecting demands to be executed in said predetermined order of execution priority from among those processing demands, if any, detected by said detection means; (e) address designation means, (807) for designating in said memory means the location of the task processing program associated with said selected single processing demand; (f) task execution means (808) for executing the task processing program in said memory location designated by said address designation means; and (g) idling mode control means (809) for disabling said detection means, said selection means, said address designation means and said task execution means in response to the completion of the execution of said designated task processing program and in response to said selection means not selecting a task processing demand for execution. Apparatus according to claim 1 for use in a public telephone set having a speech circuit (105) and a dial signal generation circuit (104) disposed in a telephone exchange loop line (L1,L2), a receiver and a transmitter coupled to said speech circuit (105) and a coin processing unit (301-305); characterized in that: said signal generation means (201,802) generates said base signals to have a period longer than the period of time required for the processing of any single one task of a set of tasks comprising coin processing (1060), dial control processing (1070), hook processing (1063) and charge processing (1074); and said detection means detects said received processing demands which each identify one task of said set of tasks. Apparatus according to Claim 1 or Claim 2 characterized by: a rechargeable power source (103) for supplying electrical power for the apparatus; and means (102) for recharging the power source (103) during a time period when said idling mode control means (809) has disabled said detection means, selection means, address designation means, and task execution means. Apparatus according to Claim 3, when dependent on Claim 2, characterized in that said recharging means (102) operates to charge said power source (103) with power supplied from a telephone exchange through said loop line (L1,L2). Apparatus according to any one Claims 1 to 4 characterized in that said predetermined order of execution priority is divided into a plurality of groups in accordance with the nature of the tasks, said groups including a first priority group of tasks to be executed in a first predetermined processing cycle and a second priority group of tasks to be executed in a second predetermined processing cycle whose period is an integral multiple of the period of said first cycle. Apparatus according to Claim 5 characterized in that said selection means (201, 805,806) selects a task processing demand from said second priority group when no task of said first priority group is to be processed, said selection being in a cycle whose period is said integral multiple of the selection period of said first cycle. Apparatus according to Claim 5 or Claim 6 characterized in that the tasks in said first and second priority groups are allotted individual priorities within their respective groups. Apparatus according to any one of Claims 1 to 7 characterized by: a first timer (201,1002) which starts in response to a signal generated by said task execution means (808) and generates a first time over output signal at a cycle rate which is an integral multiple of the period of said base signals; said memory means (202) also storing a plurality of start addresses and timer task programs to which access is gained by said start addresses; wherein said task execution means (808) generates a processing demand for said first timer, each said timer processing demand being associated with a respective one of said timer task programs, wherein said address designation means (807) reads out of said memory means (202) a said start address corresponding to the timer task program associated with the timer processing demand currently generated by said task execution means (808) and wherein said task execution means executes said timer task program identified by said start address. Apparatus according to Claim 8 characterized by a second timer (201,1006) which starts in response to a signal generated by said task execution means (808) and generates a second time over output signal at a cycle rate which is an integral multiple of the operational cycle period of said first time over output signal. Apparatus according to any one of Claims 1 to 9 characterized in that said memory means (201,202) includes: a program memory for storing said task processing programs; and an address memory for storing said start addresses of said task processing programs stored in said program memory; and wherein said address designation means (807) reads out of said address memory a task start address associated with said single processing demand selected by said selection means (201, 805,806), and said task execution means (808) executes the task processing program stored in said program memory identified by said read out address. Apparatus according to Claim 10 characterized in that said address memory (201,202) includes an area for writing in data as to the existence or non-existence of an output from said detection means (204,804) and said address designation means (807,613) reads out the start address of said single processing demand based on such data. Apparatus according to any one of Claims 1 to 11 characterized in that said generation means (201,802), said detection means (204,804), said selection means (201 ,805,806), said address designation means (807), said task execution means (808), and said idling mode control means (809) are comprised by a central processing unit (200) and a read only memory (202) having stored programs for controlling the operations of said central processing unit. Apparatus according to Claim 12 characterized in that said detection means, said selection means, said address designation means and said task execution means, which are disabled when the execution of a task processing program is completed or there is no task processing demand selected by said selection means (201,805,806) are constituted within said read only memory (202), and said idling mode control means (809) disables said read only memory. A method for controlling task processes comprising the steps of: dividing a plurality of single task operations into a plurality of groups in accordance with the priorities thereof and giving the single task operations priorities within each of said groups; repetitively generating process cycle periods, detecting execution demands corresponding to the respective single task operations during each process cycle period; selecting from the highest priority task operation group the highest priority task operation from that group whose execution demand is detected; executing said selected task operation within said process cycle period; selecting from a lower priority task operation group the highest priority task operation of that group whose execution is detected; and executing the task operation selected of said lower priority group within a cycle period which is an integral multiple of said process cycle period when there is no processing demand for a task operation in said higher priority group. A method according to Claim 14 characterized by: receiving data signals for each said single task operation; and storing, during each process cycle, the data signals of the higher or highest priority group and the data signals of the other or next highest priority group when an execution demand for the data signals of the higher or highest priority group is absent. A method according to Claim 14 or 15 characterized by setting a task execution means in an idling mode after said single task is completed within each said processing cycle and immediately setting said task execution means in said idling mode when a task execution demand is not present, and releasing said task execution means from said idling mode at initiation of the next processing cycle.

Inventors: HAYASAKA, TOSHIAKI, KAI, OSAMU, KUBOTA, TOSHIMICHI, OYAMADA, TAKASHI, TAKEDA, YOSHIAKI
Applicants: TAMURA ELECTRIC WORKS, LTD.
Application year: 1984
Main classification: H04M17
IPC codes: H04M17, G06F9