Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
learn:microprocessor:tutorials:software-timing-delays:start [2017/12/21 19:37] – [Project Testing] Marthalearn:microprocessor:tutorials:software-timing-delays:start [2022/10/04 11:38] (current) – external edit 127.0.0.1
Line 3: Line 3:
  
 The purpose of this project is to investigate methods of creating software time delays to pace processor operations. The timing methods that control when a process is to be executed can be implemented by using polling techniques that sample a free running clock or by executing code that requires a fixed amount of time. This project also demonstrates the use of time delays for signal conditioning. The purpose of this project is to investigate methods of creating software time delays to pace processor operations. The timing methods that control when a process is to be executed can be implemented by using polling techniques that sample a free running clock or by executing code that requires a fixed amount of time. This project also demonstrates the use of time delays for signal conditioning.
 +
 +\\
 +<html>
 +<a href="/learn/microprocessor/tutorials/pmodstep-parts-layout/start" class="btn btn-success" role="button">Pmod STEP Parts Layout</a>
 +</html>
 +\\
 +\\
 +<html>
 +<a href="/learn/microprocessor/tutorials/pic32-interrupts-appendices/start" class="btn btn-success" role="button">Determining Delay Constants</a>
 +</html>
 +\\
 +\\
 +<html>
 +<a href="/learn/microprocessor/tutorials/pic32-interrupts-appendices/start" class="btn btn-success" role="button">MPLAB X Stopwatch</a>
 +</html>
 +\\
 +\\
 +<html>
 +<a href="/learn/microprocessor/tutorials/pic32-interrupts-appendices/start" class="btn btn-success" role="button">Time Delay Application</a>
 +</html>
 +\\
 +\\
  
 ---- ----
Line 13: Line 35:
  
 ==== Inventory ==== ==== Inventory ====
-  * 1 [[http://store.digilentinc.com/digilent-pro-mx7-pic32-based-embedded-systems-trainer-board/| Digilent Pro MX7]]+  * 1 [[https://digilent.com/shop/digilent-pro-mx7-pic32-based-embedded-systems-trainer-board/| Digilent Pro MX7]]
   * [[http://www.microchip.com/mplab/mplab-x-ide| MPLAB X IDE]]   * [[http://www.microchip.com/mplab/mplab-x-ide| MPLAB X IDE]]
-  * 1 [[http://store.digilentinc.com/pmod-tph-6-pin-test-point-header/|Pmod TPH]], 1 [[http://store.digilentinc.com/pmod-tph2-12-pin-test-point-header/|Pmod TPH2]], 1 [[http://store.digilentinc.com/pmod-step-stepper-motor-driver/|Pmod STEP]] +  * 1 [[https://digilent.com/shop/pmod-tph-6-pin-test-point-header/|Pmod TPH]], 1 [[https://digilent.com/shop/pmod-tph2-12-pin-test-point-header/|Pmod TPH2]], 1 [[https://digilent.com/shop/pmod-step-stepper-motor-driver/|Pmod STEP]] 
-  * 1 Logic analyzer or oscilloscope (Digilent [[http://store.digilentinc.com/analog-discovery-100msps-usb-oscilloscope-logic-analyzer-limited-time/| Analog Discovery]] or [[http://store.digilentinc.com/analog-discovery-2-100msps-usb-oscilloscope-logic-analyzer-and-variable-power-supply/| Analog Discovery 2]] recommended)+  * 1 Logic analyzer or oscilloscope (Digilent [[https://digilent.com/reference/test-and-measurement/analog-discovery/start|Analog Discovery]] or [[https://digilent.com/shop/analog-discovery-2-100ms-s-usb-oscilloscope-logic-analyzer-and-variable-power-supply/|Analog Discovery 2]] recommended)
  
 ---- ----
Line 61: Line 83:
  
 It is sufficient to say that each C instruction can require multiple assembly language instructions to implement and each assembly instruction requires time to execute. The bottom line is that the execution of C code requires time and we can use this time to generate predictable time delays. An alternate method to generate a time delay is to use one of the timer resources of the processor. We will investigate both of these two methods of creating a delay function in this project. It is sufficient to say that each C instruction can require multiple assembly language instructions to implement and each assembly instruction requires time to execute. The bottom line is that the execution of C code requires time and we can use this time to generate predictable time delays. An alternate method to generate a time delay is to use one of the timer resources of the processor. We will investigate both of these two methods of creating a delay function in this project.
 +
 +----
  
 ==== Pacing the Computer ==== ==== Pacing the Computer ====
Line 66: Line 90:
  
 Two approaches for developing a delay function will be explored in this project. One of them requires no special hardware but instead relies strictly upon the execution time of a software loop. We will refer to this approach as the software delay method. The other uses one of the processor's built-in timers to generate a delay by counting clock cycles. We call this approach a hardware-assisted software delay method. Delay functions have two controlling interrelated elements: the resolution and the range. The resolution is defined by the smallest possible delay and the range by the longest possible delay. To some extent these parameters are determined by the method chosen to implement the delay. Two approaches for developing a delay function will be explored in this project. One of them requires no special hardware but instead relies strictly upon the execution time of a software loop. We will refer to this approach as the software delay method. The other uses one of the processor's built-in timers to generate a delay by counting clock cycles. We call this approach a hardware-assisted software delay method. Delay functions have two controlling interrelated elements: the resolution and the range. The resolution is defined by the smallest possible delay and the range by the longest possible delay. To some extent these parameters are determined by the method chosen to implement the delay.
 +
 +----
  
 ==== Pure Software Delays ==== ==== Pure Software Delays ====
Line 95: Line 121:
  
 Given that the “mS” variable that specifies the number of milliseconds to delay is an unsigned integer, the range, or longest possible delay, is 4,294,967,295 ms or 49.71 days. The disadvantage of the software delay loop is that the value assigned to COUNTS_PER_MS depends upon the processor speed. If the processor speed changes, then the delay function is no longer calibrated correctly. Given that the “mS” variable that specifies the number of milliseconds to delay is an unsigned integer, the range, or longest possible delay, is 4,294,967,295 ms or 49.71 days. The disadvantage of the software delay loop is that the value assigned to COUNTS_PER_MS depends upon the processor speed. If the processor speed changes, then the delay function is no longer calibrated correctly.
 +
 +----
  
 ==== Calibrating Time for Software Delays ==== ==== Calibrating Time for Software Delays ====
Line 102: Line 130:
  
 An effective alternative for measuring delay time is to use the MPLAB X Stopwatch tool described in the third tab on the right. An effective alternative for measuring delay time is to use the MPLAB X Stopwatch tool described in the third tab on the right.
 +
 +----
  
 ==== Hardware-Assisted Delays ==== ==== Hardware-Assisted Delays ====