WO2017203776A1 - モータ駆動システム、モータ制御システムおよび自走ロボット - Google Patents

モータ駆動システム、モータ制御システムおよび自走ロボット Download PDF

Info

Publication number
WO2017203776A1
WO2017203776A1 PCT/JP2017/007625 JP2017007625W WO2017203776A1 WO 2017203776 A1 WO2017203776 A1 WO 2017203776A1 JP 2017007625 W JP2017007625 W JP 2017007625W WO 2017203776 A1 WO2017203776 A1 WO 2017203776A1
Authority
WO
WIPO (PCT)
Prior art keywords
timer
count value
motor
value
motor control
Prior art date
Application number
PCT/JP2017/007625
Other languages
English (en)
French (fr)
Inventor
綱 張
Original Assignee
日本電産株式会社
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 日本電産株式会社 filed Critical 日本電産株式会社
Publication of WO2017203776A1 publication Critical patent/WO2017203776A1/ja
Priority to US16/194,478 priority Critical patent/US10613495B2/en

Links

Images

Classifications

    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B11/00Automatic controllers
    • G05B11/01Automatic controllers electric
    • G05B11/011Automatic controllers electric details of the correcting means
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B15/00Systems controlled by a computer
    • G05B15/02Systems controlled by a computer electric
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4812Task transfer initiation or dispatching by interrupt, e.g. masked
    • G06F9/4825Interrupt from clock, e.g. time of day
    • HELECTRICITY
    • H02GENERATION; CONVERSION OR DISTRIBUTION OF ELECTRIC POWER
    • H02PCONTROL OR REGULATION OF ELECTRIC MOTORS, ELECTRIC GENERATORS OR DYNAMO-ELECTRIC CONVERTERS; CONTROLLING TRANSFORMERS, REACTORS OR CHOKE COILS
    • H02P29/00Arrangements for regulating or controlling electric motors, appropriate for both AC and DC motors

Definitions

  • This disclosure relates to a technique for adjusting the timing at which one signal processing circuit (processor) starts a plurality of tasks.
  • Recent motor controllers are being equipped with many other functions in addition to the function of controlling the rotation of the motor. For example, it is a communication function for connecting a motor controller to the Internet or communicating with other devices. Therefore, an operating system (OS) has been introduced so that a user or application software can easily use each function of the motor controller.
  • OS operating system
  • Real-time OS is known as an OS installed in a motor drive system having a motor controller.
  • the real-time OS has a real-time property of managing the processor time (CPU time) and calling it accurately at a specified time of software processing.
  • the real-time OS operates based on an interrupt signal from the system timer.
  • the real-time OS detects the passage of time each time an interrupt signal is generated, and allocates resources such as CPU time and memory space using a process to be executed as a task.
  • the OS can manage the time more finely. However, this increases the number of times the OS is called per unit time. In general, each time a call is made, data overhead must be saved to the stack, data restored from the stack, and the like, which increases the overhead due to the introduction of the OS. As a result, the CPU time occupied by the OS increases. The time interval between system timer interruptions cannot be made infinitely small, and at present, it is realistic to set it to 1 millisecond or more.
  • control software is also repeatedly executed at regular intervals in order to control the controlled object.
  • the time interval for repeatedly executing the control software is called a control cycle.
  • the control cycle differs depending on the property of the controlled object and is often determined by the time constant of the controlled object. For example, the control software that controls the operation of the motor needs to be executed with a period much shorter than 1 millisecond.
  • Japanese Patent Laid-Open No. 10-161890 discloses a scheduler that assigns a certain execution time to a program.
  • the total execution time of each program may exceed the cycle, that is, the cycle constraint may not be satisfied.
  • the scheduler divides the processing of a certain program and assigns the divided processing to be executed over a plurality of cycles. Thereby, the execution of a plurality of programs is realized in the cycle.
  • control software having a relatively short control cycle and the OS for executing a task by generating a system timer interrupt at a relatively long time interval be operated on the same processor. It is necessary to reliably execute the control software and the OS at a period set for each.
  • This disclosure provides a technique for periodically executing each of the motor control software and the OS on the same processor.
  • the count start value of the second timer is set to the second count value.
  • the threshold value is set to a value that is counted earlier by the count value D, or the second threshold value is set to a value that is counted longer by the count value D.
  • the count value D is equal to or greater than the count value corresponding to the difference between the time Ta when the second interrupt signal is generated and the time Tb when the processing of the motor control software is completed.
  • the first timer and the second timer change each count value in the same cycle based on the clock signal, or change one count value in a cycle N times (N: an integer of 2 or more) the other count value. Change.
  • N an integer of 2 or more
  • An exemplary motor control system of the present disclosure includes the above-described motor drive system and a system controller that outputs a control signal for controlling the drive of the motor of the motor drive system.
  • An exemplary self-propelled robot of the present disclosure includes the motor control system described above, a plurality of wheels, including a plurality of wheels driven by the motor, and a transfer table on which an object is placed. Yes.
  • the execution timings of the tasks of the motor control software and the operating system are adjusted, so that duplication of the respective execution timings can be avoided.
  • FIG. 1 is a diagram showing a loop structure relating to three types of control included in a feedback type motor control model.
  • FIG. 2 is a diagram showing the relationship of the processing loop of the motor control software.
  • FIG. 3 is a diagram showing the configuration of the motor drive system 1.
  • FIG. 4 is a diagram illustrating how the execution timing of the motor control software 20 interferes with the task execution timing of the real-time OS 30.
  • FIG. 5 is a diagram illustrating an example of a hardware configuration of the motor drive system 1 according to the present disclosure.
  • FIG. 6 is a diagram showing the internal structure of the processor 10.
  • FIG. 7 is a diagram showing an internal configuration of the system timer 122.
  • FIG. 8 is a flowchart showing the procedure of the initial operation of the processor 10.
  • FIG. 1 is a diagram showing a loop structure relating to three types of control included in a feedback type motor control model.
  • FIG. 2 is a diagram showing the relationship of the processing loop of the motor control software.
  • FIG. 3 is
  • FIG. 9 is a flowchart illustrating a procedure of task activation timing adjustment processing of the processor 10.
  • FIG. 10 is a diagram mainly showing changes in the counter value of the system timer 122 when the processing of FIG. 9 is executed.
  • FIG. 11 is a flowchart illustrating a procedure of task activation timing adjustment processing of the processor 10 according to the modification.
  • FIG. 12 is a diagram mainly showing changes in the counter value of the system timer 122 when the processing of FIG. 9 is executed.
  • FIG. 13 is a diagram illustrating a configuration of the self-running robot 200.
  • FIG. 14 is a diagram illustrating a hardware structure of the self-running robot 200.
  • Fig. 1 shows the loop structure of three types of control included in the feedback type motor control model.
  • the motor control software designed according to this model mainly causes the processor to execute the normal current control process a, the speed control process b, and the position control process c. These three control processes can be executed at different control periods.
  • description of the specific content of each process ac is abbreviate
  • Each control cycle of the current control process a and the speed control process b is determined by the inductance of the motor and the rotational moment of inertia.
  • Each of the current control process a and the speed control process b may be required to be executed with a control period of less than 1 millisecond, for example, 50 nanoseconds.
  • An OS that manages time at intervals of 1 millisecond or more cannot naturally manage motor control software that requires a control cycle of less than 1 millisecond. Therefore, for example, it is conceivable that an interrupt signal is generated at a time interval of less than 1 millisecond using a hardware timer which is a peripheral of the processor, and motor control software is executed on the processor based on the interrupt signal.
  • Fig. 2 shows the relationship of the motor control software processing loop.
  • the motor control software causes the processor to execute the current control process a every time.
  • the processor executes speed control every time the interrupt signal is generated 10 times, and executes position control every time 1000 times.
  • the current control process a is executed every 50 nanoseconds
  • the speed control process b is executed every 500 nanoseconds.
  • the current control process a and the speed control process b are executed at a time interval of less than 1 millisecond.
  • an interrupt signal may be generated every 1 millisecond using a different timer, for example, a system timer.
  • a different timer for example, a system timer.
  • FIG. 3 shows the configuration of the motor drive system 1.
  • the motor drive system 1 has a processor 10 and a motor M.
  • the rotation of the motor M is controlled by the tasks of the motor control software 20 and the real-time OS 30 that the processor 10 executes.
  • the processor 10 and the motor M as hardware, and the motor control software 20 and the real-time OS 30 which are software (computer programs) are shown.
  • the motor control software 20 and the real-time OS 30 are both just computer programs, and the processor 10 is the main part of the actual processing. In practice, however, each computer program and the processor 10 cooperate to operate as one specific device, thereby realizing the functions provided by each program. Therefore, in this specification, a computer program may be described as if it is the subject of operation. For example, it may be described that the motor control software 20 controls the motor, or that the real-time OS 30 causes the processor 10 to execute various instructions.
  • the computer program here is not limited to the motor control software 20 and the real-time OS 30 but also includes “tasks” which are programs (processes) managed and executed by each software.
  • the processor 10 has a plurality of timers.
  • FIG. 3 shows two timers, a system timer 122 and a hardware timer 123.
  • the system timer 122 and the hardware timer 123 operate independently. Each timer has a timer counter, and when the clock signal is received, the timer counter is counted up or down. When the timer counter value reaches a predetermined value, the timer outputs an interrupt signal on the assumption that an overflow or underflow has occurred.
  • the system timer 122 outputs an interrupt signal every 1 millisecond
  • the hardware timer 123 outputs an interrupt signal every 50 microseconds.
  • the motor control software 20 is executed by an interrupt signal from the hardware timer 123. As described with reference to FIG. 1, the motor control software 20 includes a current control process a, a speed control process b, and a position control process c. In the present disclosure, at least the current control process a is executed every 50 microseconds.
  • the real-time OS 30 is executed by an interrupt signal from the system timer 122.
  • a scheduler 32 and two queues 34a and 34b are managed.
  • the scheduler 32 allocates processes (tasks) operating on the real-time OS 30 to the queue 12a for executable processes, the queue 12b for block processes, or the processor. Further, the scheduler 32 receives an interrupt signal from the system timer, and determines each task to be executed by the processor 10 each time. As a result of the determination, the scheduler 32 causes the processor 10 to execute a task having the highest executable priority, for example. Further, the scheduler 32 causes the processor 10 to execute a predetermined task in response to a signal for interrupting the event waiting process from the processor 10.
  • a certain task is executed every millisecond by the scheduler 32 of the real-time OS 30.
  • the system timer 122 and the hardware timer 123 generate an interrupt signal when each timer counter overflows.
  • the hardware timer 123 gives an example in which an overflow occurs 20 times faster than the system timer 122.
  • the hardware timer 123 will be described below as an overflow occurs twice as fast as the system timer 122.
  • FIG. 4 shows how the execution timing of the motor control software 20 interferes with the task execution timing of the real-time OS 30.
  • 4A and 4B show timings related to the operation of the motor control software 20
  • FIGS. 4C and 4D show timings related to the operation of the real-time OS 30.
  • FIG. 4A and 4B show timings related to the operation of the motor control software 20
  • FIGS. 4C and 4D show timings related to the operation of the real-time OS 30.
  • each of the system timer 122 (FIG. 4 (d)) and the hardware timer 123 (FIG. 4 (b)) outputs an interrupt signal with a different period, either of the interrupt signals will be at the same timing or close timing. Will occur. “Near” means that a later interrupt signal is generated before a task executed based on an interrupt signal generated earlier is completed. FIG. 4 shows a situation when both interrupt signals are generated at close timing.
  • the hardware timer 123 outputs an interrupt signal at time T0 when the count value of the hardware timer 123 shown in FIG. 4B overflows.
  • the processor 10 executes the process of the motor control software 20 from time T0. The process continues until time T2. In the time period from time T0 to T2, the processor 10 is occupied by the processing of the motor control software 20.
  • the system timer 122 outputs an interrupt signal at time T1 when the count value of the system timer 122 shown in FIG.
  • the time T1 is included in the time zone from the time T0 to T2.
  • the processor 10 cannot execute the task of the real-time OS 30.
  • FIG. 4C also shows a delay time E2 due to preemption as well as a period from time T3 to time T4.
  • an overflow interrupt by the system timer 122 is generated at a cycle Ta.
  • the task of the real-time OS 30 that should be executed in the control cycle Ta is executed in the control cycle Tb when a start delay due to preemption occurs, and the execution of the task in the assumed cycle is hindered.
  • a rule is adopted in which a high priority is given to an interrupt signal having a relatively short control cycle, and a low priority is given to an interrupt signal having a relatively long control cycle.
  • a low priority is given to the interrupt of the timer that drives the real-time system
  • a high priority is given to the interrupt of the timer that drives the motor control software.
  • the inventor of the present application has made a technique according to the present disclosure so that each of the motor control software 20 and the real-time OS 30 is executed in a preset control cycle.
  • the configuration and operation of the present disclosure will be described with reference to FIGS.
  • FIG. 5 is a diagram illustrating an example of a hardware configuration of the motor drive system 1 according to the present disclosure.
  • the motor drive system 1 includes a motor M, a ROM (read only memory) 2, a RAM (random access memory) 4, an I / F (input / output interface) 6, and a processor 10 that are connected to each other by a bus 8. Yes.
  • Other circuits or devices such as AD converters may be additionally connected to the bus 11.
  • the motor M includes not only the motor body but also a motor drive circuit for driving the motor body for convenience.
  • the motor M receives the PWM signal and rotates based on the PWM signal.
  • ROM 2 is a non-volatile memory that stores data of the real-time OS 30.
  • the ROM 2 may further store motor control software 20.
  • the motor control software 20 may be stored in a program flash memory of the processor 10 described later.
  • the RAM 4 is a volatile memory used as a work memory.
  • the I / F 6 is a data input / output terminal, and is used when the motor drive system 1 exchanges data with an external device.
  • the I / F 6 can be various connection terminals.
  • the I / F 6 may be a communication terminal for transmitting data generated by a task of the real-time OS 30.
  • the I / F 6 may be a data input terminal that receives a new version of the real-time OS 30.
  • the I / F 6 may be a wireless communication circuit that performs wireless communication.
  • the processor 10 executes the real-time OS 30 stored in the RAM 4 or the motor control software 20 stored in the SRAM inside the processor 10.
  • the processor 10 When the motor drive system 1 is turned on, the processor 10 reads the data of the real-time OS 30 from the ROM 2 and develops it in the RAM 4. Thereby, the processor 10 can execute the real-time OS 30. Further, the processor 10 reads the motor control software 20 from the ROM 2 and develops it in the SRAM inside the processor 10. Thereby, the processor 10 can execute the motor control software 20.
  • the processor 10 periodically executes the tasks of the motor control software 20 and the real-time OS 30 by executing the processing of the present disclosure described later.
  • the processor 10 sends a PWM signal generated by executing the motor control software 20 to the motor M, and controls the rotation of the motor M. Further, the processor 10 transmits data generated by operating the real-time OS 30 to the outside via the I / F 6.
  • the motor drive system 1 can be realized by, for example, a 32-bit general-purpose microcontroller. Such a microcontroller may be composed of one or more integrated circuit chips.
  • FIG. 6 shows the internal structure of the processor 10.
  • the processor 10 includes a processor core 120, a frequency divider 121, a system timer 122, a hardware timer 123, an SRAM 124, a program flash memory 125, an EEPROM 126, and a constant connected to each other via an internal data bus 119. It has a cycle / variable cycle timer group 127, a peripheral circuit group 128, and a register 129.
  • the processor core 120 is an arithmetic circuit having various configurations inside.
  • the processor core 120 includes, for example, a program counter, an instruction register, an instruction decoder, a stack pointer, a general-purpose register, and a timer interrupt control circuit. These are all general and will not be described in detail.
  • the frequency divider 121 receives an external clock signal from an oscillator 118 that is provided outside the processor 10 and uses crystal or silicon, divides the external clock signal, and outputs a clock signal having a predetermined frequency.
  • the system timer 122 generates an internal clock signal having a predetermined frequency for operating the processor 10 based on the clock signal received from the frequency divider 121.
  • Each of the system timer 122 and the hardware timer 123 counts up a timer counter (described later) using the clock signal received from the frequency divider 121, and outputs an interrupt signal when the counter value reaches a predetermined value.
  • the data is output to the processor core 120.
  • the number of hardware timers is arbitrary. A plurality may be provided.
  • the timer counter may count down. In this disclosure, an example of counting up will be described.
  • processor core 120 can select which frequency of the clock signal is input to the system timer 122 and the hardware timer 123 from the frequency divider 121.
  • the SRAM 124 is a work memory that is used when the processor core 120 operates, and stores data that is frequently rewritten.
  • the program flash memory 125 is a memory for storing programs and data with low rewrite frequency.
  • the EEPROM 126 is a kind of non-volatile memory in which recorded contents are not lost even when the power is turned off, and is a memory that can be electrically rewritten. Various values set in advance described below are stored in the EEPROM 126.
  • the fixed period / variable period timer group 127 is a circuit in which a plurality of timers for generating a PWM signal are combined. By combining a fixed period timer and a variable period timer, a pulse width modulated signal can be generated.
  • the peripheral circuit group 128 is a set of circuits other than the circuits described above.
  • the peripheral circuit group 128 includes, for example, a high-precision analog circuit (AD converter, DA converter), a motor control circuit, a UART (Universal Asynchronous Receiver Receiver Transmitter) that converts serial signals and parallel signals, and a communication interface device.
  • AD converter high-precision analog circuit
  • DA converter digital versatile disk drive
  • UART Universal Asynchronous Receiver Receiver Transmitter
  • the register 129 holds data designating the priorities of the system timer 122 and the hardware timer 123.
  • the priority of the hardware timer 123 is set higher than the priority of the system timer 122.
  • the priority of the hardware timer 123 is set to a value smaller than the priority of the system timer 122.
  • An interrupt signal from a timer having a relatively high priority is processed in preference to an interrupt signal from a timer having a relatively low priority.
  • the processor core 120 preferentially executes the motor control software 20 when receiving an interrupt signal from the hardware timer 123.
  • the above-described priority may be referred to as “interrupt priority”.
  • FIG. 7 shows the internal configuration of the system timer 122.
  • the system timer 122 includes a timer counter 130 and an automatic reload register (ARR) 132.
  • the ARR 132 holds data 136 indicating the upper limit count value Cf.
  • the timer counter 130 counts up the counter value from the count initial value C0 based on the clock signal supplied from the frequency divider 121.
  • the timer counter 130 stops counting when the counter value reaches the upper limit count value Cf held in the ARR 132, and outputs an overflow interrupt signal notifying the timer counter 130 that an overflow has occurred to the processor core 120. . Thereafter, the timer counter 130 resets the count value to the count initial value C0.
  • the time from the count initial value C0 to the upper limit count value Cf is 1 millisecond.
  • the timing at which the overflow occurs can be shifted thereafter.
  • the oscillator 118 and the frequency divider 121 output a sufficiently accurate clock signal.
  • the system timer 122 and the hardware timer 123 that count up in response to the clock signal can also count up with sufficient accuracy and cause an overflow every period P.
  • the timer counter 130 normally counts from the count initial value C0 to the upper limit count value Cf. However, when a signal designating the count setting value Cs is received from the processor core 120, counting starts from the count setting value Cs. By appropriately setting the count set value Cs, the time until the timer counter 130 overflows can be adjusted.
  • the timer counter 130 counts up from the designated count setting value Cs, and when the upper limit count value Cf is reached, the count value is reset to the count initial value C0. Therefore, the timer counter 130 changes the value to start counting only when the count setting value Cs is designated.
  • a method of changing the upper limit count value Cf instead of changing the count initial value C0 is conceivable. If the upper limit count value Cf is set smaller, the time until the timer counter 130 overflows becomes shorter, and if the upper limit count value Cf is set larger, the time until the timer counter 130 overflows becomes longer. After changing the upper limit count value Cf, the changed value may be continuously adopted, or may be returned to a predetermined value after the timer counter 130 is once reset.
  • the configuration of the hardware timer 123 (FIG. 6) can also be the same as the configuration of the system timer 122 shown in FIG. However, in the hardware timer 123, the time from the initial count value C0 to the upper limit count value Cf is 500 microseconds. The reason why it is twice as fast as the system timer 122 is that the timer counter 130 of the hardware timer 123 changes the count value by twice as large as that of the timer counter 130 of the system timer 122. As a result, even if the same clock signal is used and the same upper limit count value is set, the hardware timer 123 can always generate the overflow interrupt signal twice as fast as the system timer 122.
  • the processor core 120 can also read the timer counter 130 for each of the system timer 122 and the hardware timer 123, and the count initial value C0 of the timer counter 130 and / or It is possible to rewrite the upper limit count value Cf.
  • FIG. 8 is a flowchart showing the procedure of the initial operation of the processor 10.
  • step S11 the processor 10 sets the same count-up cycle for the system timer and the hardware timer. Specifically, the processor core 120 of the processor 10 inputs a clock signal having the same frequency from the frequency divider 121 to the system timer 122 and the hardware timer 123. As a result, the system timer 122 and the hardware timer 123 count up at equal intervals.
  • step S12 the processor core 120 performs a normal operation.
  • the normal operation is an operation in which the processor core 120 switches and executes the motor control software 20 and the real-time OS 30 in response to the overflow interrupt signal from the system timer 122 and the overflow interrupt signal from the hardware timer 123.
  • FIG. 9 is a flowchart showing a procedure of task activation timing adjustment processing of the processor 10.
  • the process of FIG. 9 is executed in parallel with the normal process after the start of FIG.
  • FIG. 10 mainly shows changes in the counter value of the system timer 122 when the processing of FIG. 9 is executed.
  • FIGS. 10A and 10B show timings related to the operation of the motor control software 20 based on the hardware timer 123.
  • FIGS. 10C and 10D show timings related to the operation of the real-time OS 30 based on the system timer 122.
  • FIG. 10 (e) is a partially enlarged view of FIG. 10 (d).
  • step S21 of FIG. 9 the processor core 120 executes normal processing until an interrupt signal is received from a timer having a high interrupt priority.
  • the “timer with a high interrupt priority” is the hardware timer 123.
  • the interrupt priority is preset in the register 129 (FIG. 6).
  • the processor core 120 executes the subsequent step S22. As shown in FIG. 10B, an interrupt signal is output from the hardware timer 123 at time T0.
  • step S22 the processor core 120 acquires the counter value A1 of the timer having a low interrupt priority.
  • the “timer with a low interrupt priority” is the system timer 122.
  • the processor core 120 stores the acquired counter value A1 in the SRAM 124. As shown in FIG. 10D, the counter value A1 of the system timer 122 is acquired at time T0.
  • step S23 the processor core 120 performs a normal operation. That is, the processor core 120 receives the interrupt signal from the hardware timer 123 (step S21), and therefore executes the motor control software 20 (FIG. 10A). After the execution of the motor control software 20 is completed, the processor core 120 executes the next step S24.
  • step S24 the processor core 120 acquires the count value A2 of the timer having a low interrupt priority.
  • the processor core 120 stores the acquired counter value A2 in the SRAM 124.
  • the counter value A2 of the system timer 122 is acquired at time T10.
  • the meaning of the process in step S25 is to determine whether or not the system timer 122 having a low interrupt priority has overflowed during the execution of the motor control software 20. Since the system timer 122 is counting up, if the value A2 acquired later is equal to or less than the previously acquired value A1, it means that the system timer 122 overflowed and was reset once. By executing the determination process of step S26, the processor core 120 can know that the interrupt signals of the system timer 122 and the hardware timer 123 are generated at the same timing or close timing.
  • step S ⁇ b> 26 the processor core 120 counts the initial count value Cs of the system timer 122 having a low interrupt priority by a value earlier by D than the count upper limit value Cf, that is, earlier by D as viewed from the count upper limit value Cf.
  • the system timer 122 is reset by changing the value (Cf-D). As a result, the system timer 122 starts counting from the initial count value Cf-D.
  • the count value D is a value set so that a low-priority interrupt is generated immediately after the processing of the high-priority motor control software 20 is completed. More specifically, as shown in FIG. 10 (d), this corresponds to the difference between time T11 when the system timer 122 overflows and an interrupt signal is generated, and time T10 when the processing of the motor control software 20 is completed. The value is equal to or greater than the count value.
  • the count value D is set to (T11-T10), an interrupt with a low priority is generated at the next count after the processing of the motor control software 20 with a high priority is completed.
  • the count value D may be set longer than (T11 ⁇ T10) to give a slight margin.
  • a count value corresponding to the worst execution time of the motor control software 20 can be set as the count value D.
  • FIG. 10E shows an example when a count value D corresponding to a time longer than (T11 ⁇ T10) is set.
  • FIG. 11 is a flowchart showing a procedure of task activation timing adjustment processing of the processor 10 according to the modification.
  • FIG. 12 mainly shows changes in the counter value of the system timer 122 when the processing of FIG. 9 is executed.
  • steps S21 to S25 are the same as those in FIG.
  • step S31 the processor core 120 changes the upper limit count value Cf of the system timer 122 having a low interrupt priority to a value counted later by the count D from the previous value.
  • the upper limit count value Cf before the change is set to Cfa
  • the upper limit count value Cf after the change is expressed as Cfa + D.
  • the system timer 122 overflows at a time later by the count D than the upper limit count value so far. That is, the generation of the overflow interrupt signal from the system timer 122 can be delayed by a time corresponding to the count value D.
  • the system timer 122 As a result of setting the count upper limit Cf to (Cfa + D), the system timer 122 generates an overflow interrupt signal at time T12 after the time when the processing of the motor control software 20 is completed. It has been shown.
  • the system timer 122 after the change of the upper limit count value starts counting later than the system timer 122 before the change by a time corresponding to the count value D, thereby causing an overflow. Therefore, after the processing of the motor control software 20 executed in response to the overflow interrupt signal of the hardware timer 123, the system timer 122 can overflow, and the task of the real-time OS 30 can be executed.
  • the hardware timer 123 generates the overflow interrupt signal twice or 20 times faster than the system timer 122.
  • the hardware timer 123 may change the count value at a frequency that is N times (N: a positive integer) higher than the system timer 122.
  • the processor core 120 may set the frequency of the clock signal input from the frequency divider 121 to the hardware timer 123 to be N times higher than the clock signal input to the system timer 122.
  • N may be 1.
  • the hardware timer 123 also causes an overflow in less than 1 millisecond. In that case, the processor core 120 may execute the task of the real-time OS 30 in response to the interrupt signal once every N interrupt signals from the system timer 122 are generated.
  • the hardware timer 123 may set the change amount of the count value to N (N: a positive integer) and change the count value.
  • the processor core 120 adjusts the count start value or the upper limit count value of the system timer 122 so that the task of the real-time OS 30 is executed after completion of the execution timing of all software. For example, the processor core 120 determines the count start value or the upper limit count value of the system timer 122 based on the overflow timing of each hardware timer 123 and the execution end time of software by the above-described processing, and the count at which no duplication occurs. One start value or upper limit count value may be determined.
  • motor control software having an execution cycle of 50 microseconds
  • resolver reader software having an execution cycle of 100 microseconds
  • the real-time OS 30 can be operated without causing a start delay due to preemption.
  • FIG. 13 shows a configuration of the self-running robot 200.
  • the self-running robot 200 has a transfer table 201, a system controller 202, motor drive systems 203A and 203B, and two drive wheels 204A and 204B.
  • the transport table 201 is a table on which a transported article is placed.
  • the system controller 202 controls the traveling direction and traveling speed of the self-running robot 200 based on a wired or wireless instruction from the host device 250. Specifically, the system controller 202 determines the rotation speed and rotation direction of the two drive wheels, the left wheel 204A and the right wheel 204B, and transmits control signals to the motor drive systems 203A and 203B.
  • Motor drive systems 203A and 203B independently control the rotation speed and rotation direction of drive wheels 204A and 204B, respectively, based on a control signal from system controller 102.
  • FIG. 14 shows a hardware structure of the self-running robot 200.
  • the host device 150 that does not constitute the self-running robot 200 is indicated by a broken line.
  • the system controller 202 has a processor 10C.
  • the processor 10C has a hardware structure shown in FIG. Therefore, detailed description of the processor 10C is omitted.
  • the motor drive system 203A includes a processor 10A and a motor MA.
  • the motor drive system 203B includes a processor 10B and a motor MB.
  • the motor drive systems 203A and 203B correspond to the motor drive system 1 shown in FIG.
  • the system controller 202 receives various control signals for controlling the driving of the motor, for example, a control signal for starting the rotation of the motor, a control signal for instructing the rotation speed of the motor, and a control signal for stopping the rotation of the motor. Output to each of 203A and 203B.
  • the motor drive systems 203A and 203B perform the above-described processing based on the control signal from the system controller 202, respectively, and execute the motor control software 20 and the real-time OS 30.
  • the processor 10C of the system controller 202 may also execute the motor control software and the real-time OS and perform the above-described synchronization processing, or may replace the motor control software with other software having a control cycle faster than the real-time OS. May be executed.
  • the processors 10A and 10B and the processor 112B are not necessarily products of the same manufacturer and the same model number. The same applies to the motors MA and MB. What is necessary is just to have the performance required as the self-propelled robot 200.
  • the motor drive systems 203A and 203B are sometimes referred to as intelligent motors.
  • the system controller 202 and the motor control systems 203A and 203B may be collectively referred to as a motor control system.
  • the present disclosure can be applied to a two-wheeled vehicle in which front wheels and rear wheels are driven by separate motors, a tricycle in which a plurality of wheels are driven by separate motors, and a four-wheeled vehicle.
  • the present disclosure can also be applied to a motor control system in which the system controller controls the operation of a motor drive system having one motor.
  • the processor core sets a count value corresponding to the worst execution time of the motor control software as the count value D.
  • the first timer changes the count value from the preset first initial value after the count value reaches the first threshold value.
  • the second timer changes the count value from a second initial value that is different from a preset count start value.
  • the count value A2 of the second timer at the end of execution of the motor control software is the count value A1 of the second timer at the start of execution of the motor control software. If so, the processor core detects that the second interrupt signal is generated during the execution of the motor control software.
  • the count value A2 of the second timer at the end of execution of the motor control software is the count value A1 of the second timer at the start of execution of the motor control software. If so, the processor core detects that the second interrupt signal is generated during the execution of the motor control software.
  • the processor core preferentially executes the motor control software when the second interrupt signal is generated even when the operating system task is being executed.
  • the change amount of the count value of the first timer is N times larger than the change amount of the count value of the second timer.
  • the processor core responds to the second interrupt signal once every second interrupt signal is generated N times. Perform the task.
  • the first timer receives a clock signal having a frequency N times higher than the clock signal received by the second timer.
  • An exemplary motor drive system operates on the same processor with control software having a relatively short control period and an OS that generates a system timer interrupt at a relatively long time interval to execute a task. Useful for.

Abstract

【課題】 モータ制御のソフトウェアおよびOSの各々を、同一のプロセッサ上で周期的に実行させる。 【解決手段】 モータ駆動システムのプロセッサは、閾値に到達すると第1および第2割込信号をそれぞれ出力する第1および第2タイマーと、プロセッサコアとを備えている。第1タイマーは第2タイマーと等倍または整数倍の速くカウントする。プロセッサコアは、第1割込信号に応答してモータ制御ソフトウェアを実行し、第2割込信号に応答してOSのタスクを実行する。プロセッサコアは、モータ制御ソフトウェアの実行中に第2割込信号が発生すると、第2タイマーのカウント開始値を、第2閾値を基準としてカウント値Dだけ早くカウントされる値、または、第2閾値をカウント値Dだけ長くカウントされる値に設定する。カウント値Dは、第2割込信号の発生時刻とモータ制御ソフトウェアの処理完了時刻との差分に相当するカウント値以上である。

Description

モータ駆動システム、モータ制御システムおよび自走ロボット
 本開示は、1つの信号処理回路(プロセッサ)が、複数のタスクを開始するタイミングを調整する技術に関する。
 近年のモータ制御器には、モータの回転を制御する機能だけでなく、他の多くの機能が搭載されるようになりつつある。たとえば、モータ制御器をインターネットに接続させ、または他の機器と相互に通信させるための通信機能である。そのため、ユーザまたはアプリケーションソフトウェアが、モータ制御器の各機能を容易に利用できるよう、オペレーティングシステム(OS)が導入されるようになってきた。
 モータ制御器を有するモータ駆動システムに導入されるOSとして、リアルタイムOSが知られている。リアルタイムOSは、プロセッサの時間(CPU時間)を管理し、ソフトウェア処理の指定された時間に正確に呼び出すリアルタイム性を持つ。リアルタイムOSは、システムタイマーからの割り込み信号に基づいて動作する。リアルタイムOSは、割り込み信号が発生する度に時間の経過を検知し、実行すべき処理をタスクとして、CPU時間、メモリ空間等の資源を割り当てる。
 システムタイマーに割り込みを発生させる時間間隔を短くすると、OSはより細かく時間を管理することができる。ただしそうすると、単位時間におけるOSの呼び出し回数が増える。一般的には、呼び出しの度に、スタックへのデータの退避、スタックからのデータの復旧等を行わなければならないため、OSの導入によるオーバーヘッドが大きくなる。結果的に、OSによって占有されるCPU時間が増える。システムタイマー割り込みの時間間隔を無限に小さくできるわけではなく、現在では、1ミリ秒以上に設定するのが現実的である。
 一方、制御ソフトウェアもまた、制御対象を制御するために一定時間ごとに繰り返し実行される。制御ソフトウェアを繰り返し実行する時間間隔は、制御周期と呼ばれている。制御周期は制御対象の性質によって異なり、制御対象の時定数によって決定されることが多い。たとえば、モータの動作を制御する制御ソフトウェアは、1ミリ秒よりもはるかに短い周期で実行される必要がある。
 たとえば特開平10-161890号公報は、プログラムに一定の実行時間を割り当てるスケジューラを開示する。所与の周期で複数のプログラムを実行するにあたり、各プログラムの実行時間の合計値が当該周期を超える場合、つまり周期制約を満たせない場合がある。すると、スケジューラは、あるプログラムの処理を分割して、分割された処理が複数の周期にわたって実行されるよう割り当てる。それにより、当該周期で複数のプログラムの実行を実現している。
日本国公開公報平10-161890号公報
 相対的に短い制御周期の制御ソフトウェアと、相対的に長い時間間隔でシステムタイマー割り込みを発生させてタスクを実行するOSとを同じプロセッサ上で動作させることが求められている。各々に設定された周期で制御ソフトウェアおよびOSを確実に実行することが必要とされる。
 本開示は、モータ制御のソフトウェアおよびOSの各々を、同一のプロセッサ上で周期的に実行する技術を提供する。
 本開示の例示的なモータ駆動システムによれば、モータ制御ソフトウェアの実行中に、オペレーティングシステムを動作させるための第2割込信号が発生したときは、第2タイマーのカウント開始値を、第2閾値を基準としてカウント値Dだけ早くカウントされる値に設定し、または、第2閾値をカウント値Dだけ長くカウントされる値に設定する。当該カウント値Dは、第2割込信号が発生した時刻Taとモータ制御ソフトウェアの処理が完了した時刻Tbとの差分に相当するカウント値以上である。第1タイマーおよび第2タイマーは、クロック信号に基づいて、各カウント値を同じ周期で変化させ、または、一方のカウント値を他方のカウント値のN倍(N:2以上の整数)の周期で変化させる。これにより、各割り込みが干渉しないよう調整され、タスクを開始するタイミングを調整することができる。よって、モータ制御ソフトウェアの実行タイミングとオペレーティングシステムのタスクの実行タイミングとの重複を避けることができる。
 本開示の例示的なモータ制御システムは、上述のモータ駆動システムと、前記モータ駆動システムのモータの駆動を制御する制御信号を出力するシステムコントローラとを備えている。
 本開示の例示的な自走ロボットは、上述のモータ制御システムと、複数の車輪であって、前記モータによって駆動される車輪を含む複数の車輪と、物を載置する搬送テーブルとを備えている。
 本発明の例示的な実施形態によれば、モータ制御ソフトウェアおよびオペレーティングシステムのタスクの実行タイミングを調整するため、それぞれの実行タイミングの重複を避けることができる。
図1は、フィードバック型モータ制御モデルに含まれる、三種類の制御に関するループ構造を示す図である。 図2は、モータ制御のソフトウェアの処理ループの関係を示す図である。 図3は、モータ駆動システム1の構成を示す図である。 図4は、モータ制御ソフトウェア20の実行タイミングとリアルタイムOS30のタスク実行タイミングとが干渉している様子を示す図である。 図5は、本開示によるモータ駆動システム1のハードウェア構成の例を示す図である。 図6は、プロセッサ10の内部構造を示す図である。 図7は、システムタイマー122の内部構成を示す図である。 図8は、プロセッサ10の初期動作の手順を示すフローチャートである。 図9は、プロセッサ10のタスク起動タイミング調整処理の手順を示すフローチャートである。 図10は、主として、図9の処理を実行したときのシステムタイマー122のカウンタ値の変化を示す図である。 図11は、変形例によるプロセッサ10のタスク起動タイミング調整処理の手順を示すフローチャートである。 図12は、主として、図9の処理を実行したときのシステムタイマー122のカウンタ値の変化を示す図である。 図13は、自走ロボット200の構成を示す図である。 図14は、自走ロボット200のハードウェア構造を示す図である。
 まず、図1~図3を参照しながら、モータ制御器の信号処理回路(プロセッサ)によって実行されるモータ制御のソフトウェアおよびオペレーティングシステムを説明し、続いて図4を参照しながら本願発明者が見出した課題を説明する。その後、図5以降の図面を参照しながら、本開示に係るモータ制御システムを説明する。以下の説明では、「オペレーティングシステム」を「OS」と略記する。
 図1は、フィードバック型モータ制御モデルに含まれる、三種類の制御に関するループ構造を示す。本モデルに従って設計されたモータ制御のソフトウェアは、主として通常電流制御処理a、速度制御処理bおよび位置制御処理cをプロセッサに実行させる。これら三つの制御処理はそれぞれ異なる制御周期で実行させることが可能である。なお、各処理a~cの具体的な内容の説明は省略する。
 電流制御処理aおよび速度制御処理bの各制御周期は、モータのインダクタンスおよび回転慣性モーメントによって決定される。電流制御処理aおよび速度制御処理bは、それぞれ1ミリ秒未満、たとえば50ナノ秒の制御周期で実行することが求められ得る。
 1ミリ秒以上間隔で時間を管理するOSは、当然に、1ミリ秒未満の制御周期を必要とするモータ制御のソフトウェアを管理することはできない。そこで、たとえばプロセッサのペリフェラルであるハードウェアタイマーを用いて1ミリ秒未満の時間間隔で割込信号を発生させ、割込信号に基づいてプロセッサ上でモータ制御ソフトウェアを実行させることが考えられる。
 図2は、モータ制御のソフトウェアの処理ループの関係を示す。ハードウェアタイマーが50ナノ秒の時間間隔で割込信号を発生させると、割込信号の受信に応答して、モータ制御のソフトウェアはプロセッサに都度電流制御処理aを実行させる。プロセッサは、割込信号が10回発生する毎に速度制御を実行し、1000回発生する毎に位置制御を実行する。これにより、電流制御処理aは50ナノ秒毎に実行され、速度制御処理bは500ナノ秒毎に実行される。電流制御処理aおよび速度制御処理bは1ミリ秒未満の時間間隔で実行される。
 一方、同一プロセッサ上で実行されるリアルタイムOSに関しては、異なるタイマー、たとえばシステムタイマーを利用して、1ミリ秒ごとに割込信号を発生させればよい。これにより、1ミリ秒以上の制御周期を必要とする種々のソフトウェアをリアルタイムOS管理下のタスクとして実行することができる。
 図3は、モータ駆動システム1の構成を示す。
 モータ駆動システム1は、プロセッサ10と、モータMとを有している。モータMの回転は、プロセッサ10がそれぞれ実行するモータ制御ソフトウェア20およびリアルタイムOS30のタスクによって制御される。
 図3では、理解の便宜のため、ハードウェアとしてのプロセッサ10およびモータMと、ソフトウェア(コンピュータプログラム)であるモータ制御ソフトウェア20およびリアルタイムOS30とを併記している。モータ制御ソフトウェア20およびリアルタイムOS30は、いずれもコンピュータプログラムに過ぎず、実際の処理の主体となるのはプロセッサ10である。しかしながら実際には、各コンピュータプログラムとプロセッサ10とが協働して見かけ上1つの具体的な装置として動作し、それにより各プログラムによって提供される機能が実現されている。そこで本明細書では、コンピュータプログラムが動作の主体であるかのように記載することがある。たとえば、モータ制御ソフトウェア20がモータを制御する、と記載したり、リアルタイムOS30が種々の命令をプロセッサ10に実行させる、などと記載することがある。ここでいうコンピュータプログラムは、モータ制御ソフトウェア20およびリアルタイムOS30に限られず、各ソフトウェアによって管理され実行されるプログラム(処理)である「タスク」も含まれる。
 プロセッサ10は、複数のタイマーを有している。図3には、2つのタイマー、すなわちシステムタイマー122およびハードウェアタイマー123が示されている。
 システムタイマー122およびハードウェアタイマー123は独立して動作する。いずれのタイマーもタイマーカウンタを有しており、クロック信号を受け取るとタイマーカウンタをカウントアップまたはカウントダウンする。タイマーカウンタ値が予め定められた値になると、オーバーフローまたはアンダーフローが発生したとして、タイマーは割込信号を出力する。
 本開示では、システムタイマー122は1ミリ秒ごとに割込信号を出力し、ハードウェアタイマー123は50マイクロ秒ごとに割込信号を出力するとして説明する。
 モータ制御ソフトウェア20は、ハードウェアタイマー123からの割込信号によって実行される。図1を参照しながら説明したように、モータ制御ソフトウェア20は、電流制御処理a、速度制御処理bおよび位置制御処理cを含む。本開示では、少なくとも電流制御処理aは50マイクロ秒ごとに実行される。
 リアルタイムOS30は、システムタイマー122からの割込信号によって実行される。リアルタイムOS30では、スケジューラ32と、2つの待ち行列34aおよび34bとが管理されている。
 スケジューラ32は、リアルタイムOS30上で動作する処理(タスク)を、実行可能処理の待ち行列12a、ブロック処理の待ち行列12b、またはプロセッサ上に割り当てる。また、スケジューラ32は、システムタイマーから割込信号を受け取り、その都度、管理下のどのタスクをプロセッサ10に実行させるか判断する。その判断の結果、スケジューラ32は、たとえば実行可能な最高優先度を持つタスクをプロセッサ10に実行させる。また、スケジューラ32は、プロセッサ10からのイベント待ち処理を中断する信号に応答して、所定のタスクをプロセッサ10に実行させる。
 本開示では、リアルタイムOS30のスケジューラ32によって、1ミリ秒ごとに何らかのタスクが実行されることになる。
 次に、図4を参照しながら、本願発明者が見出した、モータ駆動システム1の動作上の課題を説明する。なお、以下の説明では、システムタイマー122およびハードウェアタイマー123は、各タイマーカウンタがオーバーフローしたときに割込信号を発生させるとする。ただし、これまでは、システムタイマー122は1ミリ秒ごとに、ハードウェアタイマー123は50マイクロ秒ごとにオーバーフローが発生する例を挙げていた。つまり、ハードウェアタイマー123はシステムタイマー122より20倍速くオーバーフローが発生する例を挙げていた。しかしながら、図面上煩雑になるため、以下では、ハードウェアタイマー123はシステムタイマー122より2倍速くオーバーフローが発生するとして説明する。
 図4は、モータ制御ソフトウェア20の実行タイミングとリアルタイムOS30のタスク実行タイミングとが干渉している様子を示す。図4(a)および(b)はモータ制御ソフトウェア20の動作に関するタイミングを示し、図4(c)および(d)は、リアルタイムOS30の動作に関するタイミングを示す。
 システムタイマー122(図4(d))およびハードウェアタイマー123(図4(b))の各々は、異なる周期で割り込み信号を出力するため、いずれ、両者の割込信号が同じタイミングもしくは近いタイミングで発生することになる。「近い」とは、先に発生した割り込み信号に基づいて実行されたタスクが終了する前に、後の割り込み信号が発生することを言う。図4は、両者の割込信号が近いタイミングで発生したときの状況を示している。
 モータ制御ソフトウェア20について見ると、図4(b)に示すハードウェアタイマー123のカウント値がオーバーフローした時刻T0で、ハードウェアタイマー123は割り込み信号を出力する。その結果、プロセッサ10は、時刻T0からモータ制御ソフトウェア20の処理を実行する。処理は時刻T2まで継続する。時刻T0からT2までの時間帯では、プロセッサ10はモータ制御ソフトウェア20の処理に占有される。
 一方、リアルタイムOS30について見ると、図4(d)に示すシステムタイマー122のカウント値がオーバーフローした時刻T1で、システムタイマー122は割り込み信号を出力する。しかしながら、図示されるように、時刻T1は、時刻T0からT2までの時間帯に含まれている。プロセッサ10は、リアルタイムOS30のタスクを実行することができない。
 そのため、リアルタイムOS30のタスクの実行は時刻T2まで保留され、時刻T2から開始される。本来、時刻T1から実行されるべきタスクが、時刻T2から実行されるため、(T2-T1)の時間E1だけタスクの実行開始が遅延する。この遅延時間E1を、「プリエンプションによる開始遅延」と言う。図4(c)には、時刻T3から時刻T4までの期間もプリエンプションによる遅延時間E2も示されている。
 図4(d)に示すように、システムタイマー122によるオーバーフロー割り込みは周期Taで発生している。本来、制御周期Taで実行されるべきリアルタイムOS30のタスクは、プリエンプションによる開始遅延が発生すると、制御周期Tbで実行されることになり、想定された周期によるタスクの実行が阻害される。
 一般的には、制御周期が相対的に短い割り込み信号には高い優先度を与え、制御周期が相対的に長い割り込み信号には低い優先度を与える、という規則を採用する。同じ規則をモータ制御ソフトウェアとリアルタイムシステムが共存するシステムに適用する場合、リアルタイムシステムを駆動するタイマーの割り込みに低い優先度を与え、モータ制御ソフトウェアを駆動するタイマーの割り込みに高い優先度を与えることになる。そのため、図4では、モータ制御ソフトウェア20が先に実行されている場合には、システムタイマー122からの割り込み信号が発生しても、優先度が低いため、リアルタイムOS30のタスクにプリエンプションによる開始遅延が発生していた。
 ただし、上述の規則を適用しない場合には、リアルタイムOS30のタスクが先に実行されていることにより、モータ制御ソフトウェア20にプリエンプションによる開始遅延が発生する状況も想定され得る。高速に回転するモータMを正確に制御するために、モータ制御ソフトウェア20の制御周期は相対的に短く設定されている。したがって、プリエンプションによる開始遅延が発生すると、モータ駆動システム1の動作に影響を与え得る。影響の程度は、リアルタイムOS30に発生したプリエンプションによる開始遅延の影響よりも大きいと考えられる。
 本願発明者は、モータ制御ソフトウェア20およびリアルタイムOS30の各々が、予め設定された制御周期で実行されるようにするために、本開示にかかる技術をなすに至った。以下、図5から13を参照しながら本開示の構成および動作を説明する。
 まず、図5~7を参照しながら、本開示の処理を実現するためのモータ駆動システム1の具体的な構成を説明する。その後図8~13を参照しながら、プロセッサ10の具体的な処理を説明する。
 図5は、本開示によるモータ駆動システム1のハードウェア構成の例を示す図である。
 モータ駆動システム1は、モータMと、互いにバス8によって接続された、ROM(リードオンリーメモリ)2、RAM(ランダムアクセスメモリ)4、I/F(入出力インタフェース)6およびプロセッサ10を有している。図示されていない他の回路またはデバイス(AD変換器など)が付加的にバス11に接続されていても良い。
 モータMは、便宜上、モータ本体だけではなく、モータ本体を駆動するモータ駆動回路も含む。モータMは、PWM信号を受け取り、当該PWM信号に基づいて回転する。
 ROM2は、リアルタイムOS30のデータを格納する不揮発性メモリである。ROM2は、さらに、モータ制御ソフトウェア20を格納していてもよい。ただしモータ制御ソフトウェア20は、後述するプロセッサ10のプログラム用フラッシュメモリに格納されていてもよい。RAM4は、ワークメモリとして使用される揮発性メモリである。
 I/F6は、データ入出力端子であり、モータ駆動システム1が外部装置とデータを授受する際に利用される。I/F6は種々の接続端子であり得る。I/F6は、リアルタイムOS30のタスクによって生成されたデータを送信するための通信端子であってもよい。または、ROM2が書換可能であるときにおいて、I/F6は、新たなバージョンのリアルタイムOS30を受け取るデータ入力端子であってもよい。またはI/F6は、無線による通信を行う無線通信回路であってもよい。
 プロセッサ10は、RAM4に格納されたリアルタイムOS30を実行し、またはプロセッサ10内部のSRAMに格納されたモータ制御ソフトウェア20を実行する。
 モータ駆動システム1に電源が投入されると、プロセッサ10はROM2からリアルタイムOS30のデータを読み出し、RAM4に展開する。これにより、プロセッサ10はリアルタイムOS30を実行することができる。また、プロセッサ10は、ROM2からモータ制御ソフトウェア20を読み出し、プロセッサ10内部のSRAMに展開する。これにより、プロセッサ10はモータ制御ソフトウェア20を実行することができる。
 プロセッサ10が、後述する本開示の処理を実行することにより、モータ制御ソフトウェア20およびリアルタイムOS30のタスクをそれぞれ周期的に実行する。プロセッサ10は、モータ制御ソフトウェア20を実行することによって生成したPWM信号をモータMに送り、モータMの回転を制御する。また、プロセッサ10は、リアルタイムOS30を動作させることによって生成したデータを、I/F6を介して外部に送信する。
 モータ駆動システム1は、たとえば32ビットの汎用的なマイクロコントローラによって実現され得る。そのようなマイクロコントローラは、1個または複数の集積回路チップから構成され得る。
 次に、プロセッサ10の内部構造を説明する。
 図6は、プロセッサ10の内部構造を示す。
 プロセッサ10は、内部データバス119で互いに接続された、プロセッサコア120と、分周器121と、システムタイマー122と、ハードウェアタイマー123と、SRAM124と、プログラム用フラッシュメモリ125と、EEPROM126と、定周期/可変周期タイマー群127と、周辺回路群128と、レジスタ129とを有する。
 プロセッサコア120は、内部にさらに種々の構成を有する演算回路である。プロセッサコア120の内部には、たとえば、プログラムカウンタ、命令レジスタ、命令デコーダ、スタックポインタ、汎用レジスタ、タイマー割り込み制御回路を有している。これらはいずれも一般的であり、詳細な説明は省略する。
 分周器121は、プロセッサ10の外部に設けられた、水晶またはシリコンを用いる発振子118から外部クロック信号を受け取り、外部クロック信号を分周して所定の周波数のクロック信号を出力する。
 システムタイマー122は、分周器121から受け取ったクロック信号に基づいて、プロセッサ10を動作させるための所定周波数の内部クロック信号を生成する。
 またシステムタイマー122およびハードウェアタイマー123は、それぞれ、分周器121から受け取ったクロック信号を利用してタイマーカウンタ(後述)をカウントアップし、カウンタ値が予め定められた値になると割込信号をプロセッサコア120に出力する。なお、ハードウェアタイマーの数は任意である。複数個設けられていてもよい。また、タイマーカウンタは、カウントダウンを行ってもよい。本開示ではカウントアップの例を挙げて説明する。
 なお、分周器121から、どの周波数のクロック信号をシステムタイマー122およびハードウェアタイマー123に入力するかは、プロセッサコア120が選択することができる。
 SRAM124は、プロセッサコア120が動作する際に利用されるワークメモリであり、書き換え頻度が高いデータを格納する。
 プログラム用フラッシュメモリ125は、プログラムおよび書き換え頻度が低いデータを格納するメモリである。
 EEPROM126は、電源が遮断されても記録内容が消えない不揮発メモリの一種であり、電気的に内容を書き換えることが可能なメモリである。以下で説明する、予め設定された各種の値は、EEPROM126に格納されている。
 定周期/可変周期タイマー群127は、PWM信号を生成するための複数のタイマーが組み合わされた回路である。定周期タイマーと可変周期タイマーとを組み合わせることにより、パルス幅変調された信号を生成することができる。
 周辺回路群128は、上述した回路以外の回路の集合である。周辺回路群128は、たとえば、高精度アナログ回路(ADコンバータ、DAコンバータ)、モータ制御回路、シリアル信号とパラレル信号とを相互に変換するUART(Universal Asynchronous Receiver Transmitter)、通信インタフェース装置を含む。
 レジスタ129は、システムタイマー122およびハードウェアタイマー123の各々の優先度を指定するデータを保持する。本開示では、ハードウェアタイマー123の優先度の方がシステムタイマー122の優先度よりも高く設定される。たとえば小さい値ほど優先度が高いという規則を採用した場合には、ハードウェアタイマー123の優先度の方が、システムタイマー122の優先度よりも小さい値が設定される。優先度が相対的に高いタイマーからの割込信号は、優先度が相対的に低いタイマーからの割込信号よりも優先して処理される。たとえば、プロセッサコア120は、リアルタイムOS30のタスクの実行中であっても、ハードウェアタイマー123から割込信号を受けたときは、モータ制御ソフトウェア20を優先して実行する。本開示において、上述の優先度を「割り込み優先度」と呼ぶことがある。
 本開示においては、ハードウェアタイマー123のオーバーフロー割り込みに応答してプロセッサコア120がモータ制御ソフトウェア20を実行している時間帯に、システムタイマー122のオーバーフロー割り込みが発生したとしても、プロセッサコア120はシステムタイマー122の割り込みの処理を行わない。したがって、リアルタイムOS30の実行は保留される。
 次に、システムタイマー122の構成を説明する。
 図7は、システムタイマー122の内部構成を示す。
 システムタイマー122は、タイマーカウンタ130および自動再ロードレジスタ(ARR:Auto Reload Register)132を有している。ARR132は、上限カウント値Cfを示すデータ136を保持している。タイマーカウンタ130は、分周器121から供給されるクロック信号に基づいてカウンタ値を、カウント初期値C0からカウントアップする。そしてタイマーカウンタ130は、カウンタ値がARR132に保持された上限カウント値Cfに到達するとカウントを停止し、プロセッサコア120に、タイマーカウンタ130にオーバーフローが発生したことを通知するオーバーフロー割込信号を出力する。その後、タイマーカウンタ130は、カウント値をカウント初期値C0にリセットする。
 本開示では、カウント初期値C0から上限カウント値Cfに到達するまでの時間は、1ミリ秒である。ただし後述の処理により、その値を変更して、オーバーフローが発生するまでの時間を一時的に変更することにより、その後、オーバーフローが発生するタイミングをずらすことができる。
 発振子118および分周器121は十分な精度のクロック信号を出力する。当該クロック信号を受けてカウントアップするシステムタイマー122およびハードウェアタイマー123もまた、十分な精度でカウントアップし、周期Pごとにオーバーフローを発生させ得る。
 タイマーカウンタ130は、通常は、カウント初期値C0から上限カウント値Cfまでカウントする。しかしながら、プロセッサコア120からカウント設定値Csを指定する信号を受け取ると、当該カウント設定値Csからカウントを開始する。カウント設定値Csを適宜設定することにより、タイマーカウンタ130がオーバーフローするまでの時間を調整することができる。
 本実施形態では、タイマーカウンタ130は指定されたカウント設定値Csからカウントアップし、上限カウント値Cfに到達すると、カウント値をカウント初期値C0にリセットする。したがって、タイマーカウンタ130は、カウント設定値Csが指定された時だけ、カウントを開始する値を変更する。
 なお、タイマーカウンタ130がオーバーフローするまでの時間を調整する他の方法として、カウント初期値C0を変更するのではなく、上限カウント値Cfを変更する方法が考えられる。上限カウント値Cfをより小さく設定すれば、タイマーカウンタ130がオーバーフローするまでの時間は短くなり、上限カウント値Cfをより大きく設定すれば、タイマーカウンタ130がオーバーフローするまでの時間は長くなる。上限カウント値Cfを変更した後は、変更後の値が引き続き採用されてもよいし、タイマーカウンタ130が一旦リセットされた後は所定値に戻してもよい。
 ハードウェアタイマー123(図6)の構成もまた、図7に示すシステムタイマー122の構成と同じであり得る。ただしハードウェアタイマー123においては、カウント初期値C0から上限カウント値Cfに到達するまでの時間は、500マイクロ秒である。システムタイマー122よりも2倍速い理由は、ハードウェアタイマー123のタイマーカウンタ130は、システムタイマー122のタイマーカウンタ130よりも、1クロック信号あたり2倍の大きさでカウント値を変化させるからである。この結果、同じクロック信号を用い、同じ上限カウント値が設定されていたとしても、ハードウェアタイマー123はシステムタイマー122よりも常に2倍速くオーバーフロー割込信号を発生させることができる。
 上述の説明から理解されるように、プロセッサコア120は、システムタイマー122およびハードウェアタイマー123の各々について、タイマーカウンタ130を読み出すことも可能であるし、タイマーカウンタ130のカウント初期値C0および/または上限カウント値Cfを書き換えることが可能である。
 次に、図8~図11を参照しながら、本開示によるプロセッサ10の動作を説明する。
 図8は、プロセッサ10の初期動作の手順を示すフローチャートである。
 ステップS11において、プロセッサ10は、システムタイマーおよびハードウェアタイマーに同一のカウントアップ周期を設定する。具体的には、プロセッサ10のプロセッサコア120は、システムタイマー122およびハードウェアタイマー123に、分周器121から同じ周波数のクロック信号を入力する。これにより、システムタイマー122およびハードウェアタイマー123は、等しい周期でカウントアップを行う。
 ステップS12において、プロセッサコア120は、通常動作を行う。通常動作とは、プロセッサコア120が、システムタイマー122からオーバーフロー割込信号およびハードウェアタイマー123からのオーバーフロー割込信号に応答して、モータ制御ソフトウェア20およびリアルタイムOS30を切り換えて実行する動作である。
 図8の処理により、モータ駆動システム1の動作が開始される。
 次に、図9および図10を参照する。
 図9は、プロセッサ10のタスク起動タイミング調整処理の手順を示すフローチャートである。図9の処理は、図8の開始後から、通常処理と平行して実行される。また図10は、主として、図9の処理を実行したときのシステムタイマー122のカウンタ値の変化を示す。図10(a)および(b)はハードウェアタイマー123に基づくモータ制御ソフトウェア20の動作に関するタイミングを示す。図10(c)および(d)は、システムタイマー122に基づくリアルタイムOS30の動作に関するタイミングを示す。また図10(e)は図10(d)の部分拡大図である。
 図9のステップS21において、プロセッサコア120は、割り込み優先度の高いタイマーから割込信号を受信するまで、通常処理を実行する。ここでいう「割り込み優先度の高いタイマー」とは、ハードウェアタイマー123である。なお、割り込み優先度はレジスタ129(図6)に予め設定されている。プロセッサコア120は、ハードウェアタイマー123から割込信号を受け取ると、続くステップS22を実行する。図10(b)に示されるように、時刻T0において、ハードウェアタイマー123から割込信号が出力されている。
 ステップS22において、プロセッサコア120は、割り込み優先度の低いタイマーのカウンタ値A1を取得する。ここでいう「割り込み優先度の低いタイマー」とはシステムタイマー122である。プロセッサコア120は、取得したカウンタ値A1をSRAM124に格納する。図10(d)に示されるように、時刻T0において、システムタイマー122のカウンタ値A1が取得されている。
 ステップS23において、プロセッサコア120は、通常動作を行う。すなわちプロセッサコア120は、ハードウェアタイマー123から割込信号を受け取っているため(ステップS21)、モータ制御ソフトウェア20を実行する(図10(a))。モータ制御ソフトウェア20の実行が完了した後、プロセッサコア120は次のステップS24を実行する。
 ステップS24において、プロセッサコア120は、割り込み優先度の低いタイマーのカウント値A2を取得する。プロセッサコア120は、取得したカウンタ値A2をSRAM124に格納する。図10(d)に示されるように、時刻T10において、システムタイマー122のカウンタ値A2が取得されている。
 ステップS25において、プロセッサコア120は、取得した各カウンタ値A1およびA2が、A2<=A1であるか否かを判定する。A2<=A1である場合には処理はステップS26に進み、A2>A1である場合には処理はステップS26に進む。ステップS25の処理の意味は、モータ制御ソフトウェア20の実行中に、割り込み優先度の低いシステムタイマー122がオーバーフローしたか否かを判定することにある。システムタイマー122はカウントアップしているため、後に取得した値A2が、先に取得した値A1以下の場合には、システムタイマー122がオーバーフローして一旦リセットされたことを意味する。ステップS26の判定処理を実行することにより、プロセッサコア120は、システムタイマー122およびハードウェアタイマー123の割込信号が同じタイミングもしくは近いタイミングで発生したことを知ることができる。
 なお、図10(d)は、A2<=A1が成り立つ場合の例である。時刻T0と時刻10の間で、システムタイマー122はオーバーフロー割り込みを出力していることが理解される。
 ステップS26において、プロセッサコア120は、割り込み優先度の低いシステムタイマー122のカウント初期値Csを、カウント上限値CfからDだけ前の値、つまり、カウント上限値Cfから見てDだけ早くカウントされる値(Cf-D)に変更してシステムタイマー122をリセットする。これにより、システムタイマー122はカウント初期値Cf-Dからカウントを開始する。
 ここで、カウント値Dは、優先度の高いモータ制御ソフトウェア20の処理が終了した後にすぐに優先度の低い割り込みが発生するように設定する値である。より具体的には、図10(d)に示すように、システムタイマー122のオーバーフローが発生し割り込み信号が発生する時刻T11と、モータ制御ソフトウェア20の処理が完了した時刻T10との差に相当するカウント値以上の値である。カウント値Dを(T11―T10)に設定すると、優先度の高いモータ制御ソフトウェア20の処理が終了した後の次のカウントで優先度の低い割り込みが発生する。カウント値Dを(T11―T10)より長く設定して若干の余裕を持たせてもよい。たとえば、モータ制御ソフトウェア20の最悪実行時間に相当するカウント値をカウント値Dとして設定することができる。図10(e)は、(T11―T10)より長い時間に相当するカウント値Dを設定したときの例である。システムタイマー122は、T10よりも前の時刻Txにリセットされ、カウント値Cs(=Cf―D)からカウントが開始されている。
 上述の図9のステップS25の説明は、カウントアップするシステムタイマー122に適用される処理である。システムタイマー122がカウントダウンを行う場合には、先に取得されたカウント値A1と、後に取得されたカウント値A2との関係は、A1<=A2に読み替えればよい。A1<=A2が成り立つとき、プロセッサコア120は、モータ制御ソフトウェア20の実行中にシステムタイマー122からのアンダーフロー割込信号が発生したことを検出する。
 次に、図11および図12を参照しながら、変形例を説明する。図9および図10の例では、システムタイマー122に設けられたタイマーカウンタ130のカウント初期値を変更した。本変形例では、タイマーカウンタ130の上限カウント値を変更する。
 図11は、変形例によるプロセッサ10のタスク起動タイミング調整処理の手順を示すフローチャートである。また図12は、主として、図9の処理を実行したときのシステムタイマー122のカウンタ値の変化を示す。
 図11の処理のうち、ステップS21からS25までは図9と同じであるため説明を省略する。
 ステップS31において、プロセッサコア120は、割り込み優先度の低いシステムタイマー122の上限カウント値Cfを、これまでの値からカウントDだけ遅くカウントされる値に変更する。変更前の上限カウント値CfをCfaとおくと、変更後の上限カウント値Cfは、Cfa+Dと表現される。これにより、システムタイマー122はこれまでの上限カウント値よりもカウントDだけ遅い時間にオーバーフローする。つまり、システムタイマー122からのオーバーフロー割込信号の発生を、カウント値Dに相当する時間だけ遅らせることができる。
 図12(d)には、カウント上限値Cfが(Cfa+D)に設定された結果、モータ制御ソフトウェア20の処理が完了した時刻以後の時刻T12においてシステムタイマー122がオーバーフロー割込信号を発生させていることが示されている。
 ステップS32において、プロセッサコア120は、システムタイマー122のカウント値リセット後に、システムタイマー122の上限カウント値Cf(=Cfa+D)を、再びDだけ小さい値に設定する。つまり、ステップS31において変更される前の上限カウント値Cfaに戻す。これにより、上限カウント値変更後のシステムタイマー122は、変更前のシステムタイマー122と比較すると、カウント値Dに相当する時間だけ遅くカウントを開始し、オーバーフローを発生させることになる。よって、ハードウェアタイマー123のオーバーフロー割込信号に応答して実行されるモータ制御ソフトウェア20の処理後に、システムタイマー122がオーバーフローを発生し、リアルタイムOS30のタスクを実行させることができる。
 なお、上述の説明では、ハードウェアタイマー123はシステムタイマー122よりも2倍または20倍速くオーバーフロー割込信号を発生させる例を挙げた。しかしながらこれらの値は一例に過ぎない。ハードウェアタイマー123はシステムタイマー122よりもN倍(N:正の整数)高い周波数でカウント値を変化させればよい。そのために、プロセッサコア120は、分周器121からハードウェアタイマー123に入力されるクロック信号の周波数を、システムタイマー122に入力されるクロック信号よりもN倍高周波にすればよい。なお、Nは1であってもよい。このときは、ハードウェアタイマー123の仕様が優先されるため、ハードウェアタイマー123も1ミリ秒未満でオーバーフローを発生させることになる。その場合には、プロセッサコア120は、システムタイマー122からの割込信号がN回発生する度に1回、割込信号に応答してリアルタイムOS30のタスクを実行すればよい。
 あるいは、システムタイマー122のカウント値の変化量を1としたとき、ハードウェアタイマー123はカウント値の変化量をN(N:正の整数)に設定して、カウント値を変化させればよい。
 また、上述の説明では、モータ制御ソフトウェア20およびリアルタイムOS30の2つのソフトウェアを動作させる例を挙げた。しかしながら、リアルタイムOS30の制御周期よりも速い他のソフトウェアをさらに同時に動作させることも可能である。その場合には、複数のハードウェアタイマー123が用いられる。プロセッサコア120は、全てのソフトウェアの実行タイミング終了後にリアルタイムOS30のタスクが実行されるよう、システムタイマー122のカウント開始値または上限カウント値を調整する。たとえばプロセッサコア120は、上述の処理により、各ハードウェアタイマー123のオーバーフロータイミングおよびソフトウェアの実行終了時刻に基づいて、システムタイマー122のカウント開始値または上限カウント値をそれぞれ決定し、重複が生じないカウント開始値または上限カウント値を一つ決定すればよい。
 具体例として、50マイクロ秒の実行周期を持つモータ制御ソフトウェアと、100マイクロ秒周期の実行周期を持つレゾルバーリーダソフトウェアと、1ミリ秒または1ミリ秒より遅い周期で動作する複数のタスクを管理するリアルタイムOS30とを、プリエンプションによる開始遅延を生じさせることなくそれぞれ動作させることができる。
 (応用例)以下、上述のモータ駆動システムを搭載した応用例を説明する。
 図13は、自走ロボット200の構成を示す。自走ロボット200は、搬送テーブル201と、システムコントローラ202と、モータ駆動システム203Aおよび203Bと、2つの駆動輪204Aおよび204Bとを有する。
 搬送テーブル201は運搬物を載置するテーブルである。
 システムコントローラ202は、上位装置250からの有線または無線による指示に基づいて、自走ロボット200の進行方向および走行速度を制御する。具体的には、システムコントローラ202は、2つの駆動輪である左輪204Aおよび右輪204Bの回転速度および回転方向を決定し、モータ駆動システム203Aおよび203Bへ制御信号を送信する。
 モータ駆動システム203Aおよび203Bは、システムコントローラ102からの制御信号に基づいて、それぞれ、駆動輪204Aおよび204Bの回転速度および回転方向を独立して制御する。
 図14は、自走ロボット200のハードウェア構造を示す。参考のため、自走ロボット200を構成しない上位装置150を破線で示す。
 システムコントローラ202は、プロセッサ10Cを有している。プロセッサ10Cは、図6で示すハードウェア構造を有している。そのため、プロセッサ10Cの詳細な説明は省略する。
 モータ駆動システム203Aは、プロセッサ10Aと、モータM-Aとを有する。モータ駆動システム203Bは、プロセッサ10Bと、モータM-Bとを有する。モータ駆動システム203Aおよび203Bは、それぞれ、図5に示すモータ駆動システム1に相当する。システムコントローラ202は、モータの駆動を制御する種々の制御信号、たとえば、モータの回転を開始させる制御信号、モータの回転速度を指示する制御信号、モータの回転を停止させる制御信号を、モータ駆動システム203Aおよび203Bの各々に出力する。モータ駆動システム203Aおよび203Bは、システムコントローラ202からの制御信号に基づいて、それぞれ上述の処理を行って、モータ制御ソフトウェア20およびリアルタイムOS30を実行する。さらに、システムコントローラ202のプロセッサ10Cもまた、モータ制御ソフトウェアおよびリアルタイムOSを実行し、上述の同期処理を行ってもよいし、モータ制御ソフトウェアに代えて、リアルタイムOSよりも速い制御周期の他のソフトウェアを実行してもよい。
 なお、プロセッサ10Aおよび10Bとプロセッサ112Bとは、必ずしも同じメーカの同じ型番の製品である必要はない。モータM-AおよびM-Bについても同様である。自走ロボット200として必要とされる性能を有していればよい。モータ駆動システム203Aおよび203Bは、それぞれインテリジェントモータと呼ばれることもある。
 なお、システムコントローラ202、モータ制御システム203Aおよび203Bをまとめて、モータ制御システムと呼ぶことがある。
 上述の例は、2つの後輪が駆動輪であるとして説明したが、これは一例である。たとえば前輪および後輪を別個のモータで駆動する二輪車、複数の車輪を別個のモータで駆動する三輪車、四輪車などにも、本開示は適用可能である。さらに、本開示は、システムコントローラが1つのモータを有するモータ駆動システムの動作を制御するモータ制御システムにも適用可能である。
 本開示によれば、異なる周期を持つ互いに無関係な複数の制御プログラムを同一プロセッサ上で並列的に実行させる場合であっても、互いの実行が干渉せず、プリエンプションによる開始遅延を生じない。従来はセマフォーなどによってプログラム間の同期を行っていた。しかしながら本開示の方法によれば、セマフォーを使うことなく、オーバーヘッドなしに実行順序を保証することができる。
 本開示おける例示的なモータ駆動システムにおいて、プロセッサコアは、カウント値Dとして、モータ制御ソフトウェアの最悪実行時間に相当するカウント値を設定する。
 第1タイマーは、カウント値が第1閾値に到達した後は予め設定された第1初期値からカウント値を変化させる。カウント値が第2閾値に到達した後は、第2タイマーは、予め設定されたカウント開始値と異なる第2初期値からカウント値を変化させる。
 第2タイマーが、クロック信号に基づいてカウント値を増加させるときにおいて、モータ制御ソフトウェアの実行終了時の第2タイマーのカウント値A2が、モータ制御ソフトウェアの実行開始時の第2タイマーのカウント値A1以下であれば、プロセッサコアは、モータ制御ソフトウェアの実行中に第2割込信号が発生したことを検出する。
 第2タイマーが、クロック信号に基づいてカウント値を減少させるときにおいて、モータ制御ソフトウェアの実行終了時の第2タイマーのカウント値A2が、モータ制御ソフトウェアの実行開始時の第2タイマーのカウント値A1以上であれば、プロセッサコアは、モータ制御ソフトウェアの実行中に第2割込信号が発生したことを検出する。
 プロセッサコアは、オペレーティングシステムのタスクの実行中であっても、第2割込信号が発生したときは、モータ制御ソフトウェアを優先して実行する。
 第1タイマーが、第2タイマーと同じ周波数でカウント値を変化させるときにおいて、第1タイマーのカウント値の変化量は、第2タイマーのカウント値の変化量よりもN倍大きい。
 第1タイマーが、第2タイマーと同じ周波数でカウント値を変化させるときにおいて、プロセッサコアは、第2割込信号がN回発生する度に1回、第2割込信号に応答してオペレーティングシステムのタスクを実行する。
 第1タイマーは、第2タイマーが受け取るクロック信号よりもN倍高い周波数のクロック信号を受け取る。
 本開示の例示的なモータ駆動システムは、相対的に短い制御周期の制御ソフトウェアと、相対的に長い時間間隔でシステムタイマー割り込みを発生させてタスクを実行するOSとを同じプロセッサ上で動作させる際に有用である。
 1…モータ駆動システム 10…プロセッサ 120…プロセッサコア 121…分周器 122…システムタイマー 123…ハードウェアタイマー 124…SRAM 125…プログラム用フラッシュメモリ 126…EEPROM 127…定周期/可変周期タイマー群 128…周辺回路群 129…レジスタ130…タイマーカウンタ 132…自動再ロードレジスタ Cs…カウント設定値 Cf…上限カウント値

Claims (11)

  1.  モータと、
     クロック信号を出力する発振回路と、
     前記クロック信号に基づいて動作して、前記モータを制御するプロセッサと
     を有するモータ駆動システムであって、
     前記プロセッサは、
      設定された第1カウント開始値からカウント値を変化させ、前記カウント値が第1閾値に到達した時刻に第1割込信号を出力する第1タイマーと、
      設定された第2カウント開始値からカウント値を変化させ、前記カウント値が第2閾値に到達した時刻に第2割込信号を出力する第2タイマーと、
      前記第1割込信号および前記第2割込信号に応答して、前記モータを制御するためのモータ制御ソフトウェアおよびオペレーティングシステムを切り換えて実行するプロセッサコアと
     を備えており、
     前記クロック信号に基づいて、前記第1タイマーは、前記第2タイマーと同じ周波数またはN倍(N:2以上の整数)の周波数でカウント値を変化させ、
     前記プロセッサコアは、
      前記第1割込信号に応答して前記モータ制御ソフトウェアを実行し、前記第2割込信号に応答して前記オペレーティングシステムのタスクを実行し、
      前記モータ制御ソフトウェアの実行中に前記第2割込信号が発生したときは、前記第2タイマーの前記カウント開始値を、前記第2閾値を基準としてカウント値Dだけ早くカウントされる値に設定し、または、前記第2閾値をカウント値Dだけ長くカウントされる値に設定し、
     前記カウント値Dは、前記第2割込信号が発生した時刻Taと前記モータ制御ソフトウェアの処理が完了した時刻Tbとの差分に相当するカウント値以上である、モータ駆動システム。
  2.  前記プロセッサコアは、前記カウント値Dとして、前記モータ制御ソフトウェアの最悪実行時間に相当するカウント値を設定する、請求項1に記載のモータ駆動システム。
  3.  前記第1タイマーは、前記カウント値が前記第1閾値に到達した後は予め設定された第1初期値から前記カウント値を変化させ、
     前記第2タイマーは、前記カウント値が前記第2閾値に到達した後は、予め設定された、前記カウント開始値と異なる第2初期値から前記カウント値を変化させる、請求項1または2に記載のモータ駆動システム。
  4.  前記第2タイマーが、前記クロック信号に基づいて前記カウント値を増加させるときにおいて、
     前記モータ制御ソフトウェアの実行終了時の前記第2タイマーのカウント値A2が、前記モータ制御ソフトウェアの実行開始時の前記第2タイマーのカウント値A1以下であれば、前記プロセッサコアは、前記モータ制御ソフトウェアの実行中に前記第2割込信号が発生したことを検出する、請求項1から3のいずれかに記載のモータ駆動システム。
  5.  前記第2タイマーが、前記クロック信号に基づいて前記カウント値を減少させるときにおいて、
     前記モータ制御ソフトウェアの実行終了時の前記第2タイマーのカウント値A2が、前記モータ制御ソフトウェアの実行開始時の前記第2タイマーのカウント値A1以上であれば、前記プロセッサコアは、前記モータ制御ソフトウェアの実行中に前記第2割込信号が発生したことを検出する、請求項1から3のいずれかに記載のモータ駆動システム。
  6.  前記プロセッサコアは、前記オペレーティングシステムのタスクの実行中であっても、前記第2割込信号が発生したときは、前記モータ制御ソフトウェアを優先して実行する、請求項1から5のいずれかに記載のモータ駆動システム。
  7.  前記第1タイマーが、前記第2タイマーと同じ周波数でカウント値を変化させるときにおいて、前記第1タイマーのカウント値の変化量は、前記第2タイマーのカウント値の変化量よりもN倍大きい、請求項1から6のいずれかに記載のモータ駆動システム。
  8.  前記第1タイマーが、前記第2タイマーと同じ周波数でカウント値を変化させるときにおいて、前記プロセッサコアは、前記第2割込信号がN回発生する度に1回、第2割込信号に応答して前記オペレーティングシステムのタスクを実行する、請求項1から6のいずれかに記載のモータ駆動システム。
  9.  前記第1タイマーは、前記第2タイマーが受け取るクロック信号よりもN倍高い周波数のクロック信号を受け取る、請求項1から6のいずれかに記載のモータ駆動システム。
  10.  請求項1から9のいずれかに記載のモータ駆動システムと、 前記モータ駆動システムのモータの駆動を制御する制御信号を出力するシステムコントローラと を備えたモータ制御システム。
  11.  請求項10に記載のモータ制御システムと、
     複数の車輪であって、前記モータによって駆動される車輪を含む複数の車輪と、
     物を載置する搬送テーブルと を備えた自走ロボット。
PCT/JP2017/007625 2016-05-25 2017-02-28 モータ駆動システム、モータ制御システムおよび自走ロボット WO2017203776A1 (ja)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US16/194,478 US10613495B2 (en) 2016-05-25 2018-11-19 Motor drive system, motor control system, and self-propelled robot

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2016-104066 2016-05-25
JP2016104066A JP2019133206A (ja) 2016-05-25 2016-05-25 モータ駆動システム、モータ制御システムおよび自走ロボット

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/194,478 Continuation US10613495B2 (en) 2016-05-25 2018-11-19 Motor drive system, motor control system, and self-propelled robot

Publications (1)

Publication Number Publication Date
WO2017203776A1 true WO2017203776A1 (ja) 2017-11-30

Family

ID=60411211

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2017/007625 WO2017203776A1 (ja) 2016-05-25 2017-02-28 モータ駆動システム、モータ制御システムおよび自走ロボット

Country Status (3)

Country Link
US (1) US10613495B2 (ja)
JP (1) JP2019133206A (ja)
WO (1) WO2017203776A1 (ja)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113183167A (zh) * 2021-04-30 2021-07-30 智能移动机器人(中山)研究院 一种足式机器人的运动控制系统
CN115865060B (zh) * 2023-02-22 2023-06-06 广东亚数智能科技股份有限公司 一种pwm信号生成方法、电路、控制芯片及加工设备

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002199766A (ja) * 2000-12-25 2002-07-12 Sony Corp 回転制御系のためのサーボ制御装置及び方法
JP2002272184A (ja) * 2001-03-13 2002-09-20 Nissan Motor Co Ltd 電動機の駆動制御装置

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH10161890A (ja) 1996-11-27 1998-06-19 Mitsubishi Electric Corp スケジューラ
JP4302070B2 (ja) * 2005-02-25 2009-07-22 Okiセミコンダクタ株式会社 電源切換回路、マイクロコンピュータ、携帯端末機器、および電源切換制御方法
JP2019039799A (ja) * 2017-08-25 2019-03-14 セイコーエプソン株式会社 時間デジタル変換回路、回路装置、物理量測定装置、電子機器及び移動体

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002199766A (ja) * 2000-12-25 2002-07-12 Sony Corp 回転制御系のためのサーボ制御装置及び方法
JP2002272184A (ja) * 2001-03-13 2002-09-20 Nissan Motor Co Ltd 電動機の駆動制御装置

Also Published As

Publication number Publication date
US20190086884A1 (en) 2019-03-21
US10613495B2 (en) 2020-04-07
JP2019133206A (ja) 2019-08-08

Similar Documents

Publication Publication Date Title
Zuberi et al. Non-preemptive scheduling of messages on controller area network for real-time control applications
EP2573683A1 (en) Data processor and electronic control unit
US8190941B2 (en) Field control system
WO2019072624A1 (en) CONTROL UNIT, METHOD FOR OPERATING A CONTROL UNIT, METHOD FOR CONFIGURING A VIRTUALIZATION SYSTEM OF A CONTROL UNIT
WO2017203776A1 (ja) モータ駆動システム、モータ制御システムおよび自走ロボット
KR20220028120A (ko) 하드웨어 가속 기반의 spi 인터페이스의 자동 판독 제어 시스템 및 방법
US10606225B2 (en) Motor drive system, motor control system, and self-propelled robot
CN112889218A (zh) 步进马达的自动化速度渐变控制
EP1422627B1 (en) Method for generating interrupt commands in a microprocessor system and relative priority interrupt controller
JP6460137B2 (ja) 制御装置、制御方法、およびプログラム
US20160048156A1 (en) Automation device and method for reducing jitter
EP3159761B1 (en) A method of independent control period allocation of axis in the plc positioning system
JP2000194683A (ja) 共有メモリの調停回路およびその調停方法
CN105302640B (zh) 一种时间片的管理与控制装置及其管理与控制方法
JPWO2018211865A1 (ja) 車両制御装置
US11055163B2 (en) Method and device for error handling in a communication between distributed software components
JP3538358B2 (ja) プログラマブル・コントローラ
JP6224545B2 (ja) 電子制御装置
CN113495781B (zh) 任务调度方法、装置、设备及可读存储介质
US11048575B2 (en) Method and device for error handling in a communication between distributed software components
JP7455239B2 (ja) 数値制御システム、タスク割り当て変更装置及び数値制御方法
CN107621974B (zh) 中断请求分配装置和对此的运行方法
JP2000078891A (ja) モータ制御装置
JP2019213163A (ja) 通信制御装置
EP1450255B1 (en) Microcontroller device for complex processing procedures and corresponding interrupt management process

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17802378

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 17802378

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: JP