ABSTRACT

The PLC scan time depends on the size of the user program and the number of digital and analog inputs and outputs. Events may occur in an application that require a response from the PLC before the scan cycle is complete. For such applications, high-speed instructions can be used to avoid errors. In this chapter, a 32-bit high speed up counter is explained. Pulse width modulation (PWM) is a scheme that provides power to a load by switching quickly between fully ON and fully OFF states. The PWM signal resembles a square wave where the HIGH portion of the signal is considered the ON state and the LOW portion of the signal is considered the OFF state. In this chapter, the following high speed counter and PWM macros are described: “HSC_RB6” (32-bit high speed up counter), “PWM_RA4v” (a standard PWM operation with a variable duty cycle using the RA4 pin), “PWM_RA4c” (a standard PWM operation with a fixed duty cycle using the RA4 pin), “PWM_RA7v” (a standard PWM operation with a variable duty cycle using the RA7 pin), and “PWM_RA7c” (a standard PWM operation with a fixed duty cycle using the RA7 pin). Eleven examples are considered to show the application of the high speed counter and PWM macros presented in this chapter.