Control device, illumination device, and program for control device

A control device including a CPU is provided. The CPU outputs a plurality of pulses each having a duty set independently to LED. The CPU creates a schedule in which on-timing and off-timing of the plurality of pluses are designated such that the on-timing or the off-timing of two or more of the plurality of pulses is respectively not close to each other based on the set duty and a duty of the pulse. Further, the CPU sets, in a timer for counting time, time from a time point where the timer finishes counting the time already set to on-timing or off-timing of a pulse to be first turned on or off after the time point in accordance with the schedule. The CPU turns on or off the pulse in accordance with the schedule when the timer finishes counting the set time.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is based on and claims priority under 35 USC 119 from Japanese Patent Application No. 2019-010475 filed on Jan. 24, 2019, the contents of which are incorporated herein by reference.

TECHNICAL FIELD

The present invention relates to a control device that outputs a plurality of pulses each having a duty set independently, an illumination device in which a light source is controlled by the control device, and a program for the control device.

BACKGROUND ART

Conventionally, a pulse width modulation (PWM) control has been used to control a light source of an automobile as a plurality of loads described above (Patent Literatures 1, 2). By controlling the light source by the PWM control, brightness of the light source can be easily changed. Specifically, the brightness can be adjusted by changing a pulse width for one cycle. In addition, by gradually changing to a target duty, the light source can be gradually brightened or darkened.

The PWM control described above is performed using a PWM function of a general-purpose microcomputer. In the PWM function, a CPU of the microcomputer turns on (rises) a pulse and causes a timer to count time from on to off (fall) of the pulse based on the set duty. When the timer count ends, the CPU turns off the pulse, and then causes the timer to count the time from when the pulse is turned off to the end of one cycle of the pulse. When the timer count ends, the CPU then turns on the pulse again and repeats the above-described operation.

The CPU is provided with a plurality of ports so that a plurality of pulses can be output. In addition, the duties of the plurality of pulses can be set optionally. However, with the use of the timer described above, the timers are required for the number of ports, and it is necessary to use an expensive CPU, which is a problem in terms of cost.

In order to reduce high-frequency noise, it is considered to prevent the plurality of pulses from being turned on and off at the same time. In this case, there has been a problem that a timer is further required in order to shift the plurality of pulses on and off.

CITATION LIST

Patent Literature

SUMMARY OF INVENTION

The present invention has been made in view of the above-described circumstances, and an object thereof is to provide a control device, an illumination device, and a program for a control device in consideration of noise at low cost.

In order to achieve the above object, a control device, an illumination device, and a program for a control device according to the present invention are characterized by the following [1] to [8].

[1] A control device that outputs a plurality of pulses each having a duty set independently, the control device including:

a schedule creation section configured to create a schedule in which on-timing and off-timing of the plurality of pulses are designated such that the on-timing or the off-timing of two or more of the plurality of pulses is respectively not close to each other, based on the set duty and a cycle of the pulse;

a setting section configured to set, in a timer for counting time, time from a time point where the timer finishes counting the time already set to on-timing or off-timing of a pulse to be first turned on or off after the time point in accordance with the schedule; and

a pulse output section configured to turn on or off the pulse in accordance with the schedule when the timer finishes counting the set time.

[2] The control device according to the above configuration [1],

wherein the schedule creation section includesa first creation section configured to create the schedule in which one of the on-timing and the off-timing of the plurality of pulses is shifted at a constant interval,a second creation section configured to create the schedule by obtaining another of the on-timing and the off-timing of the plurality of pulses based on the set duty from the one of the on-timing and the off-timing created by the first creation section, anda correction section configured to correct the schedule so as to shift the other of the on-timing and the off-timing of the pulses at which the other of the on-timing and the off-timing is close, when the other of the on-timing and the off-timing of two of the plurality of pulses is close.
[3] The control device according to the above configuration [2],

wherein the correction section corrects the schedule by adding a predetermined value to the other of the on-timing and the off-timing of one of the two pulses at which the other of the on-timing and the off-timing is close.

[4] The control device according to the above configuration [2] or [3],

wherein the correction section determines that the other of the on-timing and the off-timing is close when a difference of the other of the on-timing and the off-timing of the plurality of pulses is less than predetermined time.

[5] The control device according to any one of the above configuration [2] to [4],

wherein the first creation section arranges the plurality of pulses in an order of a value of the set duty, and shifts the one of the on-timing and the off-timing at a constant interval in the arrangement order.

[6] An illumination device including:

the control device according to any one of the above configuration [1] to [5]; and

a plurality of light sources controlled by a plurality of pulses output from the control device.

[7] A control method for a control device that outputs a plurality of pulses each having a duty set independently, the control method including:

a schedule creation step configured to create a schedule in which on-timing and off-timing of the plurality of pulses are designated such that the on-timing or the off-timing of two or more of the plurality of pulses is respectively not close to each other, based on the set duty and a cycle of the pulse;

a setting step configured to set, in a timer for counting time, time from a time point where the timer finishes counting the time already set to on-timing or off-timing of a pulse to be first turned on or off after the time point in accordance with the schedule; and

a pulse output step configured to turn on or off the pulse in accordance with the schedule when the timer finishes counting the set time.

[8] The control method according to the above configuration [7],

wherein the setting step and the pulse output step are performed as an interrupt processing by interrupting the schedule creation section, every time the timer finishes counting the set time.

[9] A computer readable storage medium on which a program for a control device so as to executing the control method according to claim7or8by a computer is stored.

According to the control device having the above configurations, the plurality of pulses, each of which the duty is independently controlled, can be output by the one timer so that the on-timing or the off-timing of the two or more pulses is not close. As a result, it is possible to provide the control device and the program for the control device in consideration of noise at low cost.

According to the control device having the above configuration [2], the one of the on-timing and the off-timing of the pulses is shifted at the constant interval, and the other timing is corrected so as to be shifted, so that it is possible to easily create the schedule in which the on-timing and the off-timing of the two or more pulses is not close.

According to the control device having the above configuration [3], the other timing can be corrected simply by adding the predetermined value to the other of the on-timing and the off-timing.

According to the control device having the above configuration [4], it is possible to easily determine that the other of the on-timing and the off-timing of the pulses is close.

According to the control device having the above configuration [5], by arranging the one timing in the order of the values of the duties at the constant interval, it is possible to prevent the other timing from coming close.

According to the control device having the above configuration [6], the plurality of light sources can be controlled.

According to the program for the control device having the above configuration [9], the program can be easily executed by one control device.

According to the present invention, it is possible to provide the control device, the illumination device, and the program for the control device in consideration of the noise at the low cost.

The present invention has been briefly described above. Further, details of the present invention will be clarified by reading a mode (hereinafter, referred to as “embodiment”) for carrying out the invention to be described below with reference to accompanying drawings.

DESCRIPTION OF EMBODIMENTS

A specific embodiment according to the present invention will be described below with reference to drawings.

An illumination device1incorporating a CPU3as a control device of the present invention will be described with reference toFIG. 1. The illumination device1of the present embodiment is a device configured to PWM-control a plurality of LEDs (light sources)2mounted in a vehicle interior of an automobile, for example. As shown inFIG. 1, the illumination device1includes the plurality of LEDs2, a plurality of FETQs, and the CPU3used as the control device.

In the present embodiment, 18 LEDs2are provided. The plurality of LEDs2are provided with six full-color LEDs21to26configured by three-color LEDs2of red, green, and blue. The full-color LEDs21to26emit light in full color by adjusting brightness of the three-color LEDs2. Anodes of the plurality of LEDs2are connected in common and are connected to a power source V.

The plurality of FETQs are provided in the same number18as the plurality of LEDs2, and the FETQs and the LEDs2are provided in a one-to-one correspondence. Each of the plurality of FETQs has a drain connected to a cathode of the corresponding LEDs2, and a source connected to the ground. As a result, when the FETQ is turned on, the power source V is supplied to the LED2so as to turn on the LED2, and when the FETQ is turned off, the power source V to the LED2is cut off so as to turn off the LED2.

The CPU3as the control device outputs PWM controlled pulses from the plurality of ports ch1 to ch18, respectively. Gates of the FETQs are connected to the ports ch1 to ch18, respectively. The CPU3can adjust the brightness of each of the plurality of LEDs2independently by outputting the plurality of PWM controlled pulses. Accordingly, for example, colors of the full-color LEDs21to26can be adjusted manually by a user, or the colors of the full-color LEDs21to26can be automatically changed in accordance with a predetermined trigger such as when a door is opened and/or closed.

In the present embodiment, the CPU3and the plurality of FETQs described above are incorporated in a housing of a connector C for connecting electric wires, such as a power supply line L1and a ground line L2, to the LEDs2. In addition, a communication line L3is connected to the connector C, and the CPU3and an external control device can communicate with each other.

The colors of the full-color LEDs21to26described above are changed manually or automatically at any timing as described above. In addition, a table showing a relationship between the colors and duties of the three-color LEDs2is stored in advance in a storage unit (not shown). Every time the color is changed, the CPU3obtains the duty of each of the three-color LEDs2corresponding to the changed color with reference to the table. Then, the CPU3changes a setting of the obtained duty as a duty of a pulse to be output to each of the three-color LEDs2. Incidentally, the change in the setting of the duty using the above-described table may be performed by the external control device, and a result thereof may be transmitted to the CPU3.

Next, an outline of an operation of the illumination device1having the above-described configuration will be described with reference toFIG. 2. In the embodiment shown inFIG. 1, the 18 ports ch1 to ch18 are provided in the CPU3, but here, in order to simplify the description, an example in which a total of two ports chX, chY are provided in the CPU3, and duties 95% and 90% are respectively set to the ports chX, chY will be described. First, as shown inFIG. 2, based on the set duties, the CPU3creates a schedule in which on-timing and off-timing of the pulses are designated such that the on-timing of the pulses from the ports chX, chY is not close to each other, and the off-timing of the pulses is not close to each other.

In the example shown inFIG. 2, the schedule is created in which the pulses of the ports chX, chY are respectively turned on at 100 μs and 300 μs from start of one cycle (10000 μs in this case) of the pulses. In addition, the schedule is created in which the pulses of the ports chX, chY are turned off at 9600 μs (=100 μs+10000 μs×0.95) and 9300 μs (=300 μs+10000 μs×0.9), respectively.

The CPU3outputs the pulses from the ports chX, chY in accordance with the schedule created as described above. Specifically, the CPU3first sets a soft timer to 100 μs, and sets the pulse from the port chX as a pulse to be first turned on. When the soft timer finishes counting 100 μs, the CPU3turns on the pulse from the port chX. Subsequently, the CPU3sets the pulse from the port chY as the pulse to be first turned on after the time point from the end of the timing, and sets the soft timer to time of 200 μs (=300 μs−100 μs) until the pulse from the port chY is turned on. Thereafter, when the soft timer finishes counting 200 μs, the CPU3turns on the pulse from the port chY.

Next, the CPU3sets the pulse from the port chY as the pulse to be first turned off after the time point from the end of the timing, and sets the soft timer to time of 9000 μs (=9300 μs-300 μs) until the pulse from the port chY is turned off. When the soft timer finishes counting 9000 μs, the CPU3turns off the pulse from the port chY. Subsequently, the CPU3sets the pulse from the port chX as the pulse to be first turned off after the time point from the end of the timing, and sets the soft timer to time of 300 μs (=9600 μs−9300 μs) until the pulse from the port chX is turned off.

When the soft timer finishes counting 300 μs, the CPU3turns off the pulse from the port chX. When the output of the pulses from all of the ports chX, chY ends, the CPU3sets an end flag. Accordingly, the duties of the pulses from the ports chX, chY can be controlled as set using the one soft timer.

Next, a detailed operation of the illumination device1described above will be described with reference toFIGS. 3 to 5. Programs for a main processing shown inFIG. 3and an interrupt processing shown inFIG. 4are stored in a storage medium (not shown). The CPU3executes these programs to realize the main processing and the interrupt processing.

The pulses output from the ports ch1 to ch18 described above are all output at the same cycle (for example, 10000 μs). The CPU3functions as a schedule creation section, and executes the main processing shown inFIG. 3for each cycle of the pulse described above. In the main processing, the CPU3functions as a first creation section and a second creation section, and creates a schedule in which the on-timing and the off-timing of the plurality of pulses are designated such that the on-timing of the plurality of pulses is not close to each other (step S1).

Step S1will be described in detail. The CPU3obtains the duties set for the pulses of the ports ch1 to ch18 as described above. An example of the obtained duties is shown inFIG. 5A.

Next, as shown inFIG. 5B, the CPU3rearranges the pulses in a descending order of the duties. Thereafter, as shown inFIG. 5C, the CPU3sets the on-timing of the pulse of the port ch1 having the largest duty to, for example, 100 μs. In addition, the CPU3creates the schedule in which the on-timing of the pulses are shifted at a constant interval in an arrangement order of the pulses.

In the present embodiment, the schedule in which the on-timing of the pulses is shifted at the constant interval=200 μs is created. Specifically, as shown inFIG. 5C, the CPU3designates the on-timing of the pulse of the port ch8 having the second largest duty to 300 μs. In addition, the on-timing of the pulse of the port ch9 having the third largest duty is designated to be 500 μs. Incidentally, the on-timing of the pulse of the port ch2 having the duty of 0% is designated at 0 μs.

The CPU3obtains the schedule in which the timing at which the plurality of pulses are turned off are designate based on the duties obtained from the schedule created as described above. For example, as shown inFIG. 5C, since the pulse of the port ch1 has the on-timing of 100 μs and the duty of 100%, the off-timing is 10100 μs (=100 μs+10000 μs×1). Incidentally, in the present embodiment, as a result of obtaining the off-timing based on the duty, the CPU3creates the schedule in which all of the pulses with the timing exceeding one cycle are turned off after the one cycle (=10000 μs).

Since the pulse of the port ch8 has the on-timing of 300 μs and the duty of 90%, the CPU3creates the schedule with 300 μs+one cycle×0.9=9300 μs as the off-timing. Similarly, the CPU3obtains the off-timing of all of the pulses of the ports ch1 to ch18, creates the schedule, and ends step S1. Incidentally, the off-timing of the pulse of the port ch2 having the duty of 0% is designated to 100 μs.

In the schedule created in step S1described above, the on-timing of all of the pulses output from the ports ch1 to ch18 can be shifted, but the off-timing may be close to each other. Therefore, the CPU3determines whether or not the off-timing of two pulses is close to each other (step S2).

In step S2, the CPU3determines that the off-timing is close to each other when a difference in the off-timing of the pulses is less than predetermined time (29 μs in the present embodiment) in the schedule created in step S1. In the present embodiment, it is determined that the off-timing (3900 μs) of the pulse from the port ch12 and the off-timing (3880 μs) of the pulse from the port ch16 are close to each other.

It is determined that the off-timing (3600 μs) of the pulse from the port ch6 and the off-timing (3590 μs) of the pulse from the port ch18 are close to each other. In addition, it is determined that the off-timing (3800 μs) of the pulse from the port ch14 and the off-timing (3800 μs) of the pulse from the port ch15 are close to each other.

If it is determined that the off-timing is close (Y in step S2), the CPU3functions as a correction section, and corrects the schedule by adding a predetermined value (50 μs>predetermined time in the present embodiment) to the off-timing of one of the two pulses at which the off-timing is close to each other (step S3). In the present embodiment, since the CPU3determines that the off-timing of the pulses from the ports ch12, ch16 is close as described above, as shown inFIG. 5D, the CPU3adds 50 μs to the off-timing of the pulses from the port ch12 and corrects the off-timing to 3950 μs.

Since the CPU3determines that the off-timing of the pulses from the ports ch6, ch18 are close, the CPU3adds 50 μs to the off-timing of the pulse from the port ch6 and corrects the off-timing to 3650 μs. Further, since the CPU3determines that the off-timing of the pulses from the ports ch14, ch15 are close, the CPU3adds 50 μs to the off-timing of the pulse from the port ch15 and corrects the off-timing to 3850 μs.

When the correction is completed (step S3), the CPU3returns to step S2and again determines whether or not the off-timing is close. If it is determined in step S2that the off-timing is not close (N in step S2), the CPU3immediately ends the main processing.

On the other hand, the CPU3stops the above-described main processing every time the soft timer finishes the counting, and executes the interrupt processing shown inFIG. 4. In the interrupt processing, the CPU3functions as a pulse output section, and turns on or off the pulses of the ports ch1 to ch18 set in step S5to be described later (step S4).

Thereafter, the CPU3functions as a setting section, and sets a pulse to be turned on or off next to the pulse that is turned on or off in step S4in accordance with the schedule created in the previous cycle of the schedule that is currently created in the main processing (step S5). In addition, the CPU3sets the time until the set next pulse is turned on or off in the soft timer (step S5), and ends the processing. After the interrupt processing is completed, the CPU3continues the main processing. By the above operation, the CPU3operates in accordance with the corrected schedule shown inFIG. 5D.

According to the embodiment described above, the plurality of pulses can be output so that the on-timing or the off-timing of the two or more pulses is respectively not close to each other using the one soft timer. As a result, noise can be taken into account at low cost.

According to the embodiment described above, after creating the schedule in which the on-timing of the pulses is shifted at the constant interval, since the CPU3corrects the schedule such that the off-timing shifts, the CPU3can easily create the schedule such that the on-timing or the off-timing of the two or more pulses is respectively not close to each other.

According to the embodiment described above, the CPU3adds the predetermined value to the off-timing of one of the two pulses at which the off-timing is close. Accordingly, the off-timing can be corrected to be shifted simply by adding the predetermined value to the off-timing.

Further, according to the embodiment described above, the CPU3determines that the off-timing is close when the difference in the off-timing of the plurality of pulses is less than the predetermined time. Accordingly, it can be easily determine that the off-timing of the pulses is close.

According to the embodiment described above, the CPU3can prevent the off-timing from coming close by arranging the on-timing at the constant interval in the order of values of the duties.

According to the embodiment described above, every time the soft timer finishes counting the set time, the interrupt processing is executed by interrupting the main processing performed by the CPU3. Accordingly, the program can be easily executed by one CPU3.

According to the embodiment described above, the soft timer is used as a timer, but a hard timer may be used.

According to the embodiment described above, the CPU3arranges the pulses in the order of the values of the duties, but the present invention is not limited thereto. The arrangement order may be any order, and may be an order of arrangement of the ports ch1 to ch18 as shown inFIG. 5A.

According to the embodiment described above, the on-timing of the pulses is shifted at the constant interval, and the off-timing is corrected, but the present invention is not limited thereto. Conversely, the off-timing of the pulses may be shifted at the constant interval, and the on-timing is corrected.

According to the embodiment described above, the CPU3is used for controlling the LEDs2(light source), but the present invention is not limited thereto. The CPU3may be used for PWM control of a load, and the load may be a heater or the like.

Herein, characteristics of the control device, the illumination device, and the program for the control device according to the above embodiment of the present invention are summarized briefly in the following [1] to [8] respectively.

[1] A control device (3) that outputs a plurality of pulses each having a duty set independently, the control device including:

a schedule creation section (3) configured to create a schedule in which on-timing and off-timing of the plurality of pulses are designated such that the on-timing or the off-timing of two or more of the plurality of pulses is respectively not close to each other, based on the set duty and a cycle of the pulse;

a setting section (3) configured to set, in a timer for counting time, time from a time point where the timer finishes counting the time already set to on-timing or off-timing of a pulse to be first turned on or off after the time point in accordance with the schedule; and

a pulse output section (3) configured to turn on or off the pulse in accordance with the schedule when the timer finishes counting the set time.

[2] The control device (3) according to [1],

wherein the schedule creation section (3) includesa first creation section (3) configured to create the schedule in which one of the on-timing and the off-timing of the plurality of pulses is shifted at a constant interval,a second creation section (3) configured to create the schedule by obtaining another of the on-timing and the off-timing of the plurality of pulses based on the set duty from the one of the on-timing and the off-timing created by the first creation section, anda correction section (3) configured to correct the schedule so as to shift the other of the on-timing and the off-timing of the pulses at which the other of the on-timing and the off-timing is close, when the other of the on-timing and the off-timing of two of the plurality of pulses is close.
[3] The control device (3) according to [2],

wherein the correction section (3) corrects the schedule by adding a predetermined value to the other of the on-timing and the off-timing of one of the two pulses at which the other of the on-timing and the off-timing is close.

[4] The control device (3) according to [2] or [3],

wherein the correction section (3) determines that the other of the on-timing and the off-timing is close when a difference of the other of the on-timing and the off-timing of the plurality of pulses is less than predetermined time.

[5] The control device (3) according to any one of [2] to [4],

wherein the first creation section (3) arranges the plurality of pulses in an order of a value of the set duty, and shifts the one of the on-timing and the off-timing at a constant interval in the arrangement order.

the control device (3) according to any one of [1] to [5]; and

a plurality of light sources (2) controlled by a plurality of pulses output from the control device (3).

[7] A control method for a control device (3) that outputs a plurality of pulses each having a duty set independently, the control method comprising:

a schedule creation step (3) configured to create a schedule in which on-timing and off-timing of the plurality of pulses are designated such that the on-timing or the off-timing of two or more of the plurality of pulses is respectively not close to each other, based on the set duty and a cycle of the pulse;

a setting step (3) configured to set, in a timer for counting time, time from a time point where the timer finishes counting the time already set to on-timing or off-timing of a pulse to be first turned on or off after the time point in accordance with the schedule; and

a pulse output step (3) configured to turn on or off the pulse in accordance with the schedule when the timer finishes counting the set time.

[8] The control method for the control device (3) according to [7],

wherein the setting step (3) and the pulse output step (3) are performed as an interrupt processing by interrupting the schedule creation section (3), every time the timer finishes counting the set time.

[9] A computer readable storage medium on which a program for a control device so as to executing the control method according to [7] or [8] by a computer is stored.