1. A method, comprising:
generating a periodic output signal from a periodic input signal;
obtaining a plurality of samples of a phase difference between the periodic output signal and the periodic input signal;
determining an average phase difference between the periodic output signal and the periodic input signal from the plurality of samples; and
adjusting a phase of the periodic output signal based on the average phase difference.
2. The method of claim 1, wherein adjusting a phase of the periodic output signal includes adjusting the phase of the periodic output signal to establish approximately zero phase difference between the periodic output signal and the periodic input signal.
3. The method of claim 1, wherein adjusting a phase of the periodic output signal includes delaying the periodic input signal based on the average phase difference to generate the periodic output signal.
4. The method of claim 1, wherein generating a periodic output signal includes generating a periodic output clock signal.
5. The method of claim 1, wherein adjusting a phase of the periodic output signal further includes adjusting the phase of the periodic output signal to maintain a predetermined phase relationship with the periodic input signal.
6. The method of claim 1, further comprising receiving an external clock signal as the periodic input signal.
7. The method of claim 1, wherein obtaining a plurality of samples includes using a phase detector to compare a reference signal and a feedback signal to generate a plurality of shift left commands and shift right commands.
8. The method of claim 7, wherein determining an average phase difference between the periodic output signal and the periodic input signal includes oscillation filtering and majority filtering the plurality of shift left commands and shift right commands.
9. The method of claim 8, wherein oscillation filtering and majority filtering includes generating output shift left commands and output shift right commands to a delay line of a delay locked loop circuit.
10. The method of claim 8, wherein majority filtering includes counting a quantity of successive shift commands to generate a valid shift command, and resetting to accumulate another counted quantity of successive shift commands to generate another valid shift command.
11. The method of claim 8, wherein oscillation filtering includes transitioning toward an output shift left command state of a state machine if one of the plurality of shift left commands is received and transitioning toward an output shift right command state if one of the plurality of shift right commands is received.
12. A method, comprising:
generating a periodic output signal from a periodic input signal;
determining an average phase difference between the periodic output signal and the periodic input signal over a plurality of periods of duration of the periodic input signal; and
delaying the periodic input signal based on the average phase difference to generate the periodic output signal.
13. The method of claim 12, wherein determining the average phase difference includes counting a quantity of successive shift commands to generate a shift for generating the periodic output signal, and resetting to accumulate another counted quantity of successive shifts to generate another shift for generating the periodic output signal.
14. The method of claim 7, wherein resetting includes resetting a plurality of counters responsive to counting a pre-determined quantity of shifts in a single direction.
15. The method of claim 12, wherein determining the average phase difference includes receiving shift left and shift right commands from a phase detector, and wherein delaying the periodic input signal includes generating an output shift right command and an output shift left command upon an accumulation of a minimum quantity of each respective shift left command and shift right command.
16. The method of claim 12, further comprising oscillation filtering opposite shift commands.
17. The method of claim 16, wherein oscillation filtering includes comparing a shift command to a previously buffered shift command to validate or nullify the shift command.
18. The method of claim 16, wherein oscillation filtering includes using at least one of a logic state machine, a synchronous counter, and a shift-register chain.
19. The method of claim 18, wherein the logic state machine includes an output shift left command state, an output shift right command state and at least one no-output state therebetween, wherein oscillation filtering further includes transitioning toward the output shift left command state when a shift left command is received and transitioning toward the output shift right command state when a shift right command is received.
20. The method of claim 16, wherein oscillation filtering occurs prior to determining an average phase difference.
The claims below are in addition to those above.
All refrences to claim(s) which appear below refer to the numbering after this setence.
1. A method for generating code for a closed-loop controller, comprising:
receiving input for a simulation model in a data processing system, the simulation model including a sensor;
concurrently executing the simulation model and control code for a simulated physical controller in the data processing system, the control code interacting with the simulation model according to a state of the sensor, the control code including instructions automatically generated by the data processing system at least partially in response to the data processing system receiving a user input of a sensor object being dragged into the control code;
generating revised control code, by the data processing system, based on the executed simulation model and control code;
generating controller-specific control code based on the revised control code by the data processing system; and
executing the simulation model and the controller-specific control code, the controller-specific control code interacting with the simulation model.
2. The method of claim 1, wherein the concurrently executing and generating revised control code steps are performed repeatedly until the data processing system receives an indication that a behavior of the simulation model is correct.
3. The method of claim 1, wherein the generating revised control code includes modifying the control code based on the state of the sensor.
4. The method of claim 1, wherein the controller-specific control code is executed using a specific controller corresponding to the controller-specific control code.
5. The method of claim 1, wherein the controller-specific control code is executed using a simulation of a specific controller corresponding to the controller-specific control code.
6. The method of claim 1, wherein the simulation model also includes an actuator.
7. The method of claim 1, wherein the control code controls a simulated physical controller.
8. A data processing system comprising a processor and accessible memory, the data processing system particularly configured to perform the steps of:
receiving input for a simulation model, the simulation model including a sensor;
concurrently executing the simulation model and control code for a simulated physical controller, the control code interacting with the simulation model according to a state of the sensor, the control code including instructions automatically generated by the data processing system at least partially in response to the data processing system receiving a user input of a sensor object being dragged into the control code;
generating revised control code based on the executed simulation model and control code;
generating controller-specific control code based on the revised control code; and
executing the simulation model and the controller-specific control code, the controller-specific control code interacting with the simulation model.
9. The data processing system of claim 8, wherein the concurrently executing and generating revised control code steps are performed repeatedly until the data processing system receives an indication that a behavior of the simulation model is correct.
10. The data processing system of claim 8, wherein the generating revised control code includes modifying the control code based on the state of the sensor.
11. The data processing system of claim 8, wherein the controller-specific control code is executed using a specific controller corresponding to the controller-specific control code.
12. The data processing system of claim 8, wherein the controller-specific control code is executed using a simulation of a specific controller corresponding to the controller-specific control code.
13. The data processing system of claim 8, wherein the simulation model also includes an actuator.
14. The data processing system of claim 8, wherein the control code controls a simulated physical controller.
15. A non-transitory computer-readable storage medium encoded with computer-executable instructions that, when executed, cause a data processing system to perform the steps of:
receiving input for a simulation model, the simulation model including a sensor;
concurrently executing the simulation model and control code for a simulated physical controller, the control code interacting with the simulation model according to a state of the sensor, the control code including instructions automatically generated by the data processing system at least partially in response to the data processing system receiving a user input of a sensor object being dragged into the control code;
generating revised control code based on the executed simulation model and control code;
generating controller-specific control code based on the revised control code; and
executing the simulation model and the controller-specific control code, the controller-specific control code interacting with the simulation model.
16. The computer-readable storage medium of claim 15, wherein the concurrently executing and generating revised control code steps are performed repeatedly until the data processing system receives an indication that a behavior of the simulation model is correct.
17. The computer-readable storage medium of claim 15, wherein the generating revised control code includes modifying the control code based on the state of the sensor.
18. The computer-readable storage medium of claim 15, wherein the controller-specific control code is executed using a specific controller corresponding to the controller-specific control code.
19. The computer-readable storage medium of claim 15, wherein the controller-specific control code is executed using a simulation of a specific controller corresponding to the controller-specific control code.
20. The computer-readable storage medium of claim 15, wherein the control code controls a simulated physical controller.
21. The computer-readable storage medium of claim 15, further comprising instructions that, when executed, cause a data processing system to display the simulation model, sensor and actuator states, and control code states while executing the simulation model and the controller-specific control code.