Abstract:
An object of this invention is to stably correct and control the image write position of a recording medium in a horizontal scanning direction (main scanning direction) at low cost and high precision in an image forming apparatus having a function of detecting the end of a recording medium by a photosensor, and correcting and controlling the image write position in the horizontal scanning direction on the basis of the detection result. In the arrangement of the image forming apparatus according to the present invention, the light amount of a sheet end detection unit is adjusted by itself such that the end of a recording medium can always be detected at an appropriate light amount regardless of the state of the sheet end detection unit. The image write position in a direction (main scanning direction) perpendicular to the recording medium convey direction is corrected and controlled on the basis of a high-precision end detection result.

Description:
BACKGROUND OF THE INVENTION  
         [0001]    1. Field of the Invention  
           [0002]    The present invention relates to an image forming apparatus such as a copying machine or printer using electrophotography and, more particularly, to an image forming apparatus having a control means for detecting an end of a recording medium by a photosensor, and correcting and controlling an image write position in a direction (main scanning direction) perpendicular to the convey direction of the recording medium on the basis of the detection result.  
           [0003]    2. Related Background Art  
           [0004]    [0004]FIG. 17 shows a method of determining an image write position in a direction (main scanning direction) perpendicular to the convey direction of a recording medium in a conventional image forming apparatus.  
           [0005]    To record image information in a conventional image forming apparatus, the image forming apparatus comprises a convey guide  101  as a reference, as shown in FIG. 17. A recording medium  102  is conveyed while either a right or left end in the main scanning direction with respect to the recording medium convey direction abuts against the convey guide  101 . For example, when the left side serves as the image write reference of the recording medium  102 , the left end of the recording medium  102  abuts against the convey guide to convey the recording medium  102 . With this arrangement, the recording medium  102  can always be conveyed at the same position, and image information can always be recorded at the same position on the recording medium  102  with respect to the end of the recording medium  102 .  
           [0006]    As a method of not moving a recording medium, the positional shift (deviation) amount of the recording medium in the main scanning direction is detected, and the image write timing is corrected. FIG. 18 shows a conventional image write timing correction method.  
           [0007]    A sheet end detection means  103  is mechanically driven using a motor (not shown) or the like with respect to the recording medium  102 . The sheet end detection means  103  passes the end of the recording medium  102 , and then an output from the sheet end detection means  103  changes. The image forming apparatus calculates, e.g., a moving distance until the output changes after the start of moving the sheet end detection means  103  on the basis of the rotation amount of the motor. The image forming apparatus corrects the image write timing on the basis of the calculation result.  
           [0008]    As a means for detecting the end of a recording medium without moving the sheet end detection means, a photosensor can be adopted. A conventional method of detecting the end of a recording medium by using a photosensor will be explained. FIG. 19 is a block diagram showing the image forming apparatus.  
           [0009]    A controller  104  sends image data to a printer engine  105  on the basis of a horizontal sync signal (BD signal) and vertical sync signal (TOP signal) sent from the printer engine  105 . For example, the controller  104  sends image data to the printer engine  105  on the basis of a horizontal sync signal (BD signal) upon reception of a vertical sync signal (TOP signal) sent from the printer engine  105 .  
           [0010]    [0010]FIG. 20 is a schematic view showing the printer engine. The printer engine is constituted by a sheet end detection means  106 , a registration roller  107 , a attraction roller  108  which makes an electrostatic convey belt  113  attract a recording medium, image forming portions  109  to  112 , the electrostatic convey belt  113 , a feed unit  114 , a fixing device  115 , a fixing/discharge portion  116 , and double-side convey portions  117 .  
           [0011]    The outline of image forming operation will be described by exemplifying double-side recording with reference to FIGS. 19 and 20.  
           [0012]    An image is formed on the second surface (lower surface) of a recording medium. The recording medium is conveyed from the feed unit  114 , and the registration roller  107  removes any skew. The sheet end detection means  106  between the registration roller  107  and the attraction roller  108  detects the sheet end (e.g., left end) of the recording medium in the main scanning direction. Then, the recording medium is attracted by the electrostatic convey belt  113  by using the attraction roller  108 , and conveyed to the image forming portions  109  to  112 .  
           [0013]    The sheet end detection means  106  uses a photosensor so as to detect a recording medium in a noncontact state.  
           [0014]    The printer engine  105  notifies the controller  104  of positional information about the detected end of the recording medium as status information. The controller  104  controls the image data transmission timing to the printer engine  105  on the basis of the received positional information about the end of the recording medium. The controller  104  adjusts the image write position in the main scanning direction. An image is formed on the recording medium at the image forming portions  109  to  112 .  
           [0015]    The image formed on the recording medium is fixed as a permanent image onto the recording medium by heat and pressure at the fixing device  115 . The recording medium is discharged by a predetermined amount from the fixing/discharge portion  116 , and then the fixing/discharge portion  116  is reversely rotated to convey the recording medium to the double-side convey portions  117 .  
           [0016]    The recording medium reaches the registration roller  107  again through the double-side convey portions  117 , and the registration roller  107  removes any skew. The sheet end detection means  106  detects the sheet end (e.g., left end) of the recording medium in the main scanning direction again, and an image is formed on the first surface (front surface) by the same method as that for the image on the second surface (back surface).  
           [0017]    A method of detecting the end of a recording medium will be described. FIGS. 21 and 22 show the sheet end detection means. The sheet end detection means is made up of an LED  135 , a transparent material  136  which guides light from the LED, and a CIS (Contact Image Sensor)  137  which detects light from the LED as an analog signal.  
           [0018]    [0018]FIG. 23 is a control block diagram showing the sheet end detection means, and FIG. 24 is a timing chart of the sheet end detection means. The printer engine  105  comprises the sheet end detection means  106 , a binarization means  118 , an oscillation unit (X&#39;tal)  119 , an ASIC  120 , a CPU  121 , a BD detection means  122  which receives a BD signal serving as the reference of an image write position in the main scanning direction, and a TOP generation means  123  which generates a TOP signal serving as the reference of an image write position in the subscanning direction.  
           [0019]    A TOP signal serving as the reference of an image write position in the subscanning direction is generated (T 1801 ). At a predetermined timing, a detection start signal Start Pulse is input from the ASIC  120  to the sheet end detection means  106  (T 1802 ). Start Pulse is used as a reset pulse for a CIS  34  and initializes the CIS  34 . The LED  135  is turned on by an LED ON/OFF signal from the ASIC  120  (T 1803 ).  
           [0020]    The LED  135  emits light under predetermined driving conditions, and the light from the LED  135  irradiates the CIS  34  via the transparent material  136 . The CIS output changes to “H” at a portion irradiated with light, whereas the CIS output changes to “L” at a portion where light is shielded by a recording medium. After that, a detection clock SNS CLK is input from the ASIC  120  to the sheet end detection means  106  (T 1804 ).  
           [0021]    The sheet end detection means  106  outputs the detection results of the CIS  34  as analog signals sequentially from the end in synchronism with the clock pulse SNS CLK. An output (analog output) from the sheet end detection means  106  is binarized by the binarization means  118  and input to the ASIC  120  (T 1805 ).  
           [0022]    The ASIC  120  generates a WINDOW signal which enables an output from the binarization means  118  (T 1806 ). During the effective (H) period of the WINDOW signal, the ASIC  120  counts the number of H outputs from the binarization means  118  in synchronism with the clock pulse SNS CLK (T 1807 ).  
           [0023]    The CPU  121  calculates the distance of a light permeable portion in the sheet end detection means  106  from the count result, and detects the end of the recording medium.  
           [0024]    The controller  104  is notified of positional information about the end of the recording medium as status information.  
           [0025]    In the conventional image forming apparatus, a recording medium is mechanically moved to a normal position during the conveyance of the recording medium, as shown in FIG. 17. When recording media subjected to recording processing have a variety of sizes, it is difficult to move recording media with all the sizes to the normal position.  
           [0026]    To mechanically move a recording medium during conveyance, the recording medium must be released from the convey means. This is difficult to realize when the recording medium is conveyed vertically from a lower portion to an upper portion or from an upper portion to a lower portion.  
           [0027]    It is therefore difficult to always maintain the same image write position with respect to the recording medium at low cost and high precision.  
           [0028]    Particularly when an image on the second surface is recorded in double-side recording, the convey path of a recording medium is unstably long and the image write position is more difficult to match.  
           [0029]    In the method of moving the sheet end detection means to detect the positional shift amount of a recording medium and correcting the image write position, the detection means must be mechanically driven to a position where the means can detect at least either the right or left end of the recording medium with respect to the convey direction. The apparatus requires a bulky arrangement and cannot be downsized.  
           [0030]    Further, a motor for driving the detection means is needed, resulting in an expensive system.  
           [0031]    In the method of detecting the end position of a recording medium and correcting the image write position in accordance with the detected end position of the recording medium, the end position of the recording medium may be erroneously detected. In this case, the image write position is controlled based on the erroneously detected result.  
           [0032]    Especially when a photosensor is used as a means for detecting the end position of a recording medium, the light emission portion of the photosensor keeps driving conditions constant. For example, the light amount of the light emission side decreases, failing to obtain a predetermined sensor output due to a decrease in the light amount of the light emission portion in accordance with the service life, or dust at the light emission portion under the influence of toner scattering or the like caused by long-term use in the image recording apparatus.  
           [0033]    Alternatively, the light receiving amount decreases owing to dust at the light receiving portion, and a predetermined sensor output cannot be attained.  
           [0034]    As a result, image information cannot be recorded at a normal position on a recording medium.  
         SUMMARY OF THE INVENTION  
         [0035]    It is an object of the present invention to stably correct and control the image write position of a recording medium in the main scanning direction at low cost and high precision in an image forming apparatus having a control means for detecting the end of a recording medium by a photosensor, and correcting and controlling the image write position in the main scanning direction on the basis of the detection result.  
           [0036]    To achieve the above object, according to the present invention, there is provided an image forming apparatus comprising: detection means for detecting an end position of a recording medium by a photosensor; control means for correcting an image write position in a direction perpendicular to a recording medium convey direction on the basis of a detection result of the detection means; and correction means for correcting a light emission amount of the photosensor.  
           [0037]    The above and other objects, features, and advantages of the present invention will be apparent from the following detailed description of the preferred embodiments in conjunction with the accompanying drawings. 
       
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0038]    [0038]FIG. 1 is a block diagram showing an image forming apparatus in the first embodiment;  
         [0039]    [0039]FIG. 2 is a schematic view showing a printer engine;  
         [0040]    [0040]FIG. 3 is a perspective view showing a sheet end detection means;  
         [0041]    [0041]FIG. 4 is a sectional view showing the sheet end detection means;  
         [0042]    [0042]FIG. 5 is a timing chart of the sheet end detection means;  
         [0043]    [0043]FIG. 6 is a block diagram showing correction control of an image write position;  
         [0044]    [0044]FIG. 7 is a block diagram showing an ASIC;  
         [0045]    [0045]FIG. 8 is a flow chart showing setting of the light amount of the sheet end detection means;  
         [0046]    [0046]FIG. 9 is a graph showing the output voltage distribution of the sheet end detection means;  
         [0047]    [0047]FIG. 10 is a flow chart showing setting of the light amount of a sheet end detection means in the second embodiment;  
         [0048]    [0048]FIG. 11 is a graph showing the output voltage distribution of the sheet end detection means;  
         [0049]    [0049]FIG. 12 is a block diagram showing a sheet end detection means in the third embodiment;  
         [0050]    [0050]FIG. 13 is a flow chart showing setting of the light amount of the sheet end detection means;  
         [0051]    [0051]FIG. 14 is a block diagram showing a printer engine in the fourth embodiment;  
         [0052]    [0052]FIG. 15 is a flow chart;  
         [0053]    [0053]FIG. 16 is a flow chart;  
         [0054]    [0054]FIG. 17 is a view showing a conventional image write position determination method;  
         [0055]    [0055]FIG. 18 is a view showing a conventional image write timing correction method;  
         [0056]    [0056]FIG. 19 is a block diagram showing a conventional image forming apparatus;  
         [0057]    [0057]FIG. 20 is a schematic view showing a conventional printer engine;  
         [0058]    [0058]FIG. 21 is a perspective view showing a conventional sheet end detection means;  
         [0059]    [0059]FIG. 22 is a sectional view showing the conventional sheet end detection means;  
         [0060]    [0060]FIG. 23 is a control block diagram showing the conventional sheet end detection means; and  
         [0061]    [0061]FIG. 24 is a timing chart of the conventional sheet end detection means. 
     
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS  
       [0062]    (First Embodiment)  
         [0063]    An image forming apparatus according to the first embodiment of the present invention will be described with reference to the accompanying drawings. In the first embodiment, the light amount of a sheet end detection means is not kept at a constant value but is set to a light amount optimal for detection at a predetermined timing.  
         [0064]    [0064]FIG. 1 is a block diagram showing the image forming apparatus. A controller  1  as a control means sends image data to a printer engine  2  on the basis of a horizontal sync signal (BD signal) and vertical sync signal (TOP signal) sent from the printer engine  2 . The controller  1  sends image data to the printer engine  2  on the basis of a horizontal sync signal (BD signal) upon reception of a vertical sync signal (TOP signal) sent from the printer engine  2 .  
         [0065]    [0065]FIG. 2 is a schematic view showing the printer engine. The printer engine is constituted by a sheet end detection means  3 , a registration roller  4 , a attraction roller  5  which makes an electrostatic convey belt attract a recording medium, image forming portions  6  to  9 , an electrostatic convey belt  10 , a feed unit  11 , a fixing device  12 , fixing/discharge portions  13 , and double-side convey portions  14 .  
         [0066]    The outline of image forming operation will be described by exemplifying double-side recording with reference to FIGS. 1 and 2.  
         [0067]    An image is formed on the second surface (back surface) of a recording medium. The recording medium is conveyed from the feed unit  11 , and the registration roller  4  removes any skew. The sheet end detection means  3  between the registration roller  4  and the attraction roller  5  detects the sheet end (e.g., left end) of the recording medium in the main scanning direction. Then, the recording medium is attracted by the electrostatic convey belt  10  by using the attraction roller  5 , and conveyed to the image forming portions  6  to  9 .  
         [0068]    The sheet end detection means  3  uses a photosensor so as to detect a recording medium in a noncontact state.  
         [0069]    The printer engine  2  notifies the controller  1  of positional information about the detected end of the recording medium as status information. The controller  1  controls the image data transmission timing to the printer engine  2  on the basis of the received positional information about the end of the recording medium. The controller  1  adjusts the image write position in a direction perpendicular to the recording medium convey direction. An image is formed on the recording medium at the image forming portions  6  to  9 .  
         [0070]    The image formed on the recording medium is fixed as a permanent image onto the recording medium by heat and pressure at the fixing device  12 . The recording medium is discharged by a predetermined amount from the fixing/discharge portions  13 , and then the fixing/discharge portions  13  are reversely rotated to convey the recording medium to the double-side convey portions  14 .  
         [0071]    The recording medium reaches the registration roller  4  again through the double-side convey portions  14 , and the registration roller  4  removes any skew. The sheet end detection means  3  detects the sheet end (e.g., left end) of the recording medium in the main scanning direction again, and an image is formed on the first surface (front surface) by the same method as that for the image on the second surface (back surface).  
         [0072]    A method of detecting the end of a recording medium will be described. FIGS. 3 and 4 show the sheet end detection means. The sheet end detection means is made up of an LED  32 , a transparent material  33  which guides light from the LED, and a CIS (Contact Image Sensor)  34  which detects light from the LED as an analog signal. The LED  32 , transparent material  33 , and CIS  34  constitute the sheet end detection means  3  (see FIG. 2).  
         [0073]    [0073]FIG. 6 is a block diagram showing correction control of the image write position by using a photosensor, and FIG. 5 is a timing chart of an optical detection means. The printer engine  2  comprises the sheet end detection means  3 , a binarization means  15 , an oscillation unit (X&#39;tal)  16 , an ASIC  17 , a CPU  18 , a BD detection means  19  which receives a BD signal serving as the reference of an image write position in the main scanning direction, and a TOP generation means  20  which generates a TOP signal serving as the reference of an image write position in the subscanning direction.  
         [0074]    In the first embodiment, the LED  32  emits pulses. Further, this embodiment adopts an SNS OUT signal for inputting an output from the sheet end detection means  3  to the internal A/D converter of the ASIC  17  in addition to the binarization means  15 .  
         [0075]    A TOP signal serving as the reference of an image write position in the subscanning direction is generated (T 1801 ). At a predetermined timing, a detection start signal Start Pulse is input from the ASIC  17  to the sheet end detection means  3  (T 1802 ). Start Pulse is used as a reset pulse for the CIS  34  and initializes the CIS  34 . The LED  32  is turned on by an LED ON/OFF signal from the ASIC  17  (T 1803 ).  
         [0076]    The LED  32  emits light under predetermined driving conditions, and the light from the LED  32  irradiates the CIS  34  via the transparent material  33 . The CIS output changes to “H” at a portion irradiated with light, whereas the CIS output changes to “L” at a portion where light is shielded by a recording medium. After that, a detection clock SNS CLK is input from the ASIC  17  to the sheet end detection means  3  (T 1804 ).  
         [0077]    The sheet end detection means  3  outputs the detection results of the CIS  34  as analog signals sequentially from the end in synchronism with the clock pulse SNS CLK. An output (analog output) from the sheet end detection means  3  is binarized by the binarization means  15  and input to the ASIC  17  (T 1805 ).  
         [0078]    The ASIC  17  generates a WINDOW signal which enables an output from the binarization means  15  (T 1806 ). During the effective (H) period of the WINDOW signal, the ASIC  17  counts the number of H outputs from the binarization means  15  in synchronism with the clock pulse SNS CLK (T 1807 ).  
         [0079]    The CPU  18  calculates the distance of a light permeable portion in the sheet end detection means  3  from the count result, and detects the end of the recording medium.  
         [0080]    The controller  1  is notified of positional information about the end of the recording medium as status information.  
         [0081]    [0081]FIG. 7 is a block diagram showing the ASIC in the first embodiment, and FIG. 8 is a flow chart showing setting of the light amount of the sheet end detection means in the first embodiment. The ASIC comprises an LED lighting pulse register  21 , effective range setting registers  22  and  23 , an A/D converter register  24 , an A/D conversion start signal generation unit (to be referred to as an ADSTART generation unit hereinafter)  25  which controls a timing when a digital value detected by an A/D converter is stored in the register, an LED lighting pulse generation unit  26  which causes the LED to emit light as pulses on the basis of the register value, an effective range setting register generation unit (to be referred to as a WINDOW generation unit hereinafter)  27  which determines the effective period of a CIS output, a Start Pulse generation unit (to be referred to as a CISRST generation unit hereinafter)  28  which generates a CISRST signal for resetting the sheet end detection means  3 , a sync clock generation unit (to be referred to as a SNS CLK generation unit hereinafter)  29  which supplies CLK to the sheet end detection means  3 , and an A/D converter  30  which converts an analog input into a digital value.  
         [0082]    Light amount setting operation of the sheet end detection means in the first embodiment will be explained with reference to FIGS. 7 and 8.  
         [0083]    After the printer engine  2  is powered on in S 801 , the CISRST generation unit  28  outputs an “L” CISRST signal to turn on the sheet end detection means  3  in S 802 . In S 803 , the CPU  18  sets a value in the effective range setting registers  22  and  23  which determine an area corresponding to the size of a recording medium in the main scanning direction.  
         [0084]    The WINDOW generation unit  27  generates a WINDOW signal near the end of the recording medium on the basis of the value set in the effective range setting registers  22  and  23 . An output from the CIS  34  becomes effective only in an area where the WINDOW is set. The LED  32  is driven at a maximum light amount (full lighting of the LED) in S 804 , and the saturation voltage of the sheet end detection means  3  is measured in S 805 .  
         [0085]    The saturation voltage is measured by, e.g., the following method.  
         [0086]    The CIS  34  outputs an analog value SNS OUT in synchronism with a clock SNS CLK supplied from the SNS CLK generation unit  29  of the ASIC  17 . The A/D converter  30  in the ASIC  17  converts the analog value SNS OUT into a digital value at a timing based on a signal from the ADSTART generation unit  25 , and stores the digital value in the A/D converter register  24 . The CPU  18  writes the value of the A/D converter register  24  in a RAM area (not shown).  
         [0087]    This operation is repeated while the WINDOW is active. The CPU  18  calculates the maximum output voltage value of the CIS  34  in the WINDOW active period, and sets the maximum voltage value as the saturation voltage of the sheet end detection means  3 .  
         [0088]    After the saturation voltage is measured, whether the saturation voltage is a predetermined voltage or more is checked in S 806 . If NO in S 806 , it is determined in S 807  that the sheet end detection means  3  fails or a recording medium or the like exists in the sheet end detection means  3 , and the abnormal state is informed. If YES in S 806 , the light amount of the LED  32  is set so that the CIS output at the center of the WINDOW active period becomes a “saturation voltage −α”.  
         [0089]    The light amount of the LED  32  is controlled by changing the lighting time of the LED  32  as follows.  
         [0090]    First, the CPU  18  sets an LED lighting time per unit time in the LED lighting pulse register  21  of the ASIC  17 . Then, the ASIC  17  causes the LED lighting pulse generation unit  26  to generate an LED lightning pulse on the basis of the value of the LED lighting pulse register  21 .  
         [0091]    [0091]FIG. 9 shows the output voltage distribution of the sheet end detection means  3  when a sheet end is detected before/after the LED light amount is set. L 1  represents a light amount distribution when the LED  32  is driven at a maximum light amount; L 2 , a light amount distribution after the LED light amount is adjusted; V 1 , the output voltage (saturation voltage) of the sheet end detection means  3  when the LED  32  is driven at a maximum light amount; V 21 , the output voltage of the sheet end detection means  3  in a light permeable area after the LED light amount is adjusted; and V 22 , the output voltage of the sheet end detection means  3  in a light impermeable area after the LED light amount is adjusted.  
         [0092]    Since light is shielded by a recording medium in an area where the recording medium exists, the CIS output voltage decreases.  
         [0093]    In the above description, the controller  1  is notified of positional information about a detected end of a recording medium as status information, and corrects the image write position. The image write position correction method is not limited to the above one. For example, a correction amount may be calculated in the printer engine on the basis of positional information about a detected end of a recording medium, and the controller may be notified of the calculation result. Alternatively, the image write timing may be corrected in the printer engine on the basis of positional information about a detected end of a recording medium.  
         [0094]    The sheet end detection means  3  uses an LED and transparent material for the light emission portion and a CIS for the light receiving portion, but is not limited to this arrangement. For example, the sheet end detection means  3  may be implemented by another photosensor unit using an LED array for the light emission portion and a CCD sensor and the like for the light receiving portion.  
         [0095]    The sheet end detection means  3  is not limited to a light permeable photosensor unit, but may be a reflection photosensor unit.  
         [0096]    An electrophotographic 4-drum color image forming apparatus has been described. However, the image forming apparatus is not limited to the 4-drum color type, but may be a 1-drum color image forming apparatus or monochrome image forming apparatus.  
         [0097]    In this embodiment, the light amount adjustment point is set to the center of the WINDOW active period. The adjustment point is not limited to the center and may be another point in the WINDOW active period.  
         [0098]    As described above, the light amount of the sheet end detection means  3  is not kept at a constant value, but is set such that the CIS output at the center of the WINDOW active period becomes a saturation voltage −α when the saturation voltage is a predetermined voltage or more. Accordingly, the end of a recording medium can always be detected at a proper light amount regardless of the state of the sheet end detection means.  
         [0099]    (Second Embodiment)  
         [0100]    An image forming apparatus according to the second embodiment of the present invention will be described with reference to the accompanying drawings. The same reference numerals as in the first embodiment denote the same parts, and a repetitive description thereof will be omitted.  
         [0101]    In the first embodiment, the light emission amount is corrected such that an output at a predetermined position in an area where the detection result of the optical detection means becomes effective has a predetermined value. In the second embodiment, the light emission amount is corrected such that an output at an output generation portion exhibiting the smallest light receiving amount in the area where the detection result of the optical detection means becomes effective has a predetermined value.  
         [0102]    [0102]FIG. 10 is a flow chart showing setting of the light amount of a sheet end detection means in the second embodiment.  
         [0103]    After a printer engine  2  is powered on in S 1001 , a CISRST generation unit  28  outputs an “L” CISRST signal to turn on a sheet end detection means  3  in S 1002 .  
         [0104]    In S 1003 , a CPU  18  sets a value in effective range setting registers  22  and  23  which determine an area corresponding to the size of a recording medium in the main scanning direction. A WINDOW generation unit  27  generates a WINDOW signal near the end of the recording medium on the basis of the value set in the effective range setting registers  22  and  23 . A CIS  34  becomes effective only in an area where the WINDOW is set. An LED  32  is driven at a maximum light amount in S 1004 , and the saturation voltage of the sheet end detection means  3  is measured in S 1005 .  
         [0105]    In S 1006 , whether the saturation voltage is a predetermined voltage or more is checked. If NO in S 1006 , it is determined in S 1007  that the sheet end detection means  3  fails or a recording medium or the like exists in the sheet end detection means  3 , and the abnormal state is informed. If YES in S 1006 , the light amount of the LED  32  is set so that the minimum voltage of the sheet end detection means  3  during the WINDOW active period becomes a saturation voltage.  
         [0106]    [0106]FIG. 11 shows the output voltage distribution of the sheet end detection means  3  when a sheet end is detected before/after the LED light amount is set. L 3  represents a light amount distribution when the LED  32  is driven at a maximum light amount; L 4 , a light amount distribution after the LED light amount is adjusted; V 3 , the output voltage (saturation voltage) of the sheet end detection means  3  when the LED  32  is driven at a maximum light amount; V 41 , the output voltage of the sheet end detection means  3  in a light permeable area after the LED light amount is adjusted; and V 42 , the output voltage of the sheet end detection means  3  in a light impermeable area after the LED light amount is adjusted.  
         [0107]    Since light is shielded by a recording medium in an area where the recording medium exists, the CIS output voltage decreases.  
         [0108]    In this embodiment, the light emission amount is corrected such that an output at an output generation portion exhibiting the smallest light receiving value in the area where the detection result of the optical detection means becomes effective has a predetermined value. The present invention is not limited to this, and the light emission amount may be corrected such that an output at an output generation portion exhibiting the smallest output value in the area where the detection result of the optical detection means becomes effective has a predetermined value.  
         [0109]    As described above, the light amount of the sheet end detection means  3  is not kept at a constant value, but is set such that the minimum voltage of the sheet end detection means  3  in the WINDOW active period becomes a saturation voltage when the saturation voltage is a predetermined voltage or more. As a result, the end of a recording medium can always be detected at a proper light amount regardless of the state of the sheet end detection means  3 .  
         [0110]    (Third Embodiment)  
         [0111]    An image forming apparatus according to the third embodiment of the present invention will be described with reference to the accompanying drawings. The same reference numerals as in the first embodiment denote the same parts, and a repetitive description thereof will be omitted.  
         [0112]    In the third embodiment, the WINDOW active period as an area where the detection result of the optical detection means becomes effective is divided into a plurality of periods. FIG. 12 shows an arrangement when the WINDOW active period is divided into three, and FIG. 13 is a flow chart showing setting of the light amount of a sheet end detection means in the third embodiment.  
         [0113]    After a printer engine  2  is powered on in S 1301 , a sheet end detection means  3  is turned on in S 1302 , and the light amount of area  1  is set in S 1303 . The light amount of area  2  is set in S 1304 , and that of area  3  is set in S 1305 .  
         [0114]    In image formation, the size of a recording medium is detected in advance by a recording medium size detection means (not shown) or the like, and the sheet end is detected only in an area corresponding to the end of the recording medium.  
         [0115]    The WINDOW active period is divided into three in this embodiment, but the division number is not limited to three.  
         [0116]    As described above, the WINDOW active period is divided into three, the light emission amounts of areas  1  to  3  are corrected, and end detection is executed in an area corresponding to the size of a recording medium detected in advance by the recording medium size detection means or the like. With this arrangement, the end of a recording medium can be detected at an optimal light amount for each recording medium size.  
         [0117]    (Fourth Embodiment)  
         [0118]    An image forming apparatus according to the fourth embodiment of the present invention will be described with reference to the accompanying drawings. The same reference numerals as in the first embodiment denote the same parts, and a repetitive description thereof will be omitted.  
         [0119]    In this embodiment, the light amount of a sheet end detection means  3  is set in accordance with not only activation of the image forming apparatus but also each predetermined number of prints. FIG. 14 is a block diagram showing a printer engine in the fourth embodiment, and FIG. 15 is a flow chart showing the fourth embodiment. A page counter  31  counts the number of prints on the basis of an output signal from a TOP generation means  20 .  
         [0120]    After a printer engine  2  is powered on in S 1501 , the sheet end detection means  3  is turned on in S 1502 . The page counter  31  is reset to zero in S 1503 , and the light amount of the sheet end detection means  3  is set in S 1504 . Printing starts in S 1505 , and the page counter  31  is incremented in S 1506 . Whether printing has ended is checked in S 1507 , and if YES, the flow returns to S 1505  to wait for the next printing instruction.  
         [0121]    If printing continues, whether a predetermined of sheets have been printed is checked in S 1508 . If NO in S 1508 , the flow returns to S 1505  to continue printing. If YES in S 1508 , whether the power supply has been turned off is checked in S 1509 . If NO in S 1509 , the flow returns to step S 1503  to reset the page counter  31  to zero, and the light amount of the sheet end detection means  3  is set in S 1504 . If YES in S 1509 , the flow ends.  
         [0122]    In the fourth embodiment, the light amount is set for each predetermined number of prints, but the light amount setting execution timing is not limited to the number of prints. The light amount may be set based on another information which changes in accordance with the number of prints such as residual toner amount detection information.  
         [0123]    As described above, the light emission amount is corrected on the basis of not only activation of the image forming apparatus but also information which changes in accordance with the number of prints of the image forming apparatus. This can prevent degradation of the sheet end detection means over time, or a decrease in the detection precision of the sheet end detection means caused by toner scattering or the like in the image recording apparatus.  
         [0124]    (Fifth Embodiment)  
         [0125]    An image forming apparatus according to the fifth embodiment of the present invention will be described with reference to the accompanying drawings. The same reference numerals as in the first embodiment denote the same parts, and a repetitive description thereof will be omitted.  
         [0126]    In the fifth embodiment, the light amount of a sheet end detection means is set in accordance with not only activation of the image forming apparatus but also occurrence of a jam. FIG. 16 is a flow chart showing the fifth embodiment.  
         [0127]    After a printer engine  2  is powered on in S 1601 , a sheet end detection means  3  is turned on in S 1602 , and the light amount of the sheet end detection means  3  is set in S 1603 . Printing starts in S 1604 , and whether a jam has occurred is checked in S 1605 .  
         [0128]    If YES in S 1605 , the flow returns to S 1603  to set the light amount of the sheet end detection means  3 ; if NO, whether printing has ended is checked in S 1606 .  
         [0129]    If NO in S 1606 , the flow returns to S 1604  to continue printing; if YES, the flow ends.  
         [0130]    In the fifth embodiment, the light amount is set upon occurrence of a jam, but the light amount setting execution timing is not limited to occurrence of a jam. Alternatively, the light amount may be set when printing operation fails due to the failure of a fixing unit or motor. Alternatively, the light amount may be set when the door is opened/closed.  
         [0131]    As described above, the light emission amount is corrected not only in activation of the image forming apparatus, but also in occurrence of a jam, opening/closing of the door, or the failure of the fixing unit or driving unit. Hence, the abnormal state of the sheet end detection means can be detected in advance.  
         [0132]    As has been described above, according to the present invention, the end of a recording medium can always be detected at a proper light amount regardless of the state of the sheet end detection means.  
         [0133]    The end of a recording medium can be detected at an optimal light amount for each recording medium size.  
         [0134]    In addition, degradation of the sheet end detection means owing to secular change, or a decrease in the detection precision of the sheet end detection means caused by toner scattering or the like within the image recording apparatus can be avoided.  
         [0135]    The abnormal state of the sheet end detection means can be detected in advance.  
         [0136]    As a result, image information can always be recorded on a recording medium on the basis of a stable end detection result. Information can always be recorded at a proper position, increasing the recording quality.  
         [0137]    The present invention is not limited to the above embodiments, and can be modified without departing from the spirit and scope of the invention.