Go to GlobalSpec.com Home
Alert   Product Alerts
Keep current on the latest products, new suppliers, and technical articles of interest to you. (See Topics)

Chapter 13: Program Examples

By et al.
From PIC Microcontrollers: Know It All

13.1 Counting Events

Counting is a useful feature for any control circuit. We may wish to count the number of times a door has opened or closed, or count a number of pulses from a rotating disc. If we count cars into a car park we would increment a file count every time a car entered, using the instruction INCF COUNT. If we needed to know how many cars were in the car park, we would of course have to reduce the count by one every time a car left. We would do this by DECF COUNT. To clear the user file COUNT to start, we would CLRF COUNT. In this way the file count would store the number of cars in the car park.

Let's look at an application.

Design a circuit that will count 10 presses of a switch and then turn an LED on and reset when the next ten presses are started. The hardware is that of Fig. 11.1 with AO as the switch input and BO as the output to the LED.

There are two ways to count, UP and DOWN. We usually count up and know automatically when we have reached 10. A computer, however, knows when it reaches a count of 10 by subtracting the count from 10. If the answer is zero, then bingo. A simpler way, however, is to start at 10 and count down to zero after 10 events we will have reached zero without doing a subtraction. Zero for the...

Copyright Elsevier Inc. 2008 under license agreement with Books24x7

Products & Services
Mechanical counters are used to detect, totalize and indicate a sequence of events in applications that do not use electrical power. Search by Specification | Learn more about Mechanical Counters
Frequency counters are digital indicating meters for accurate measurement and display of square wave and pulse input signals. Learn more about Frequency Counters
Electromechanical counters and electromechanical timers accept inputs to operate mechanical display, such as rotating wheels or knobs. Search by Specification | Learn more about Electromechanical Counters and Electromechanical Timers
Counter and timer boards are computer cards that perform digital counting and/or timing functions. Search by Specification | Learn more about Counter and Timer Boards
Specialty IC timing devices are specialty or proprietary products related to IC timing devices. Learn more about Specialty IC Timing Devices

Product Announcements
N-TRON, Corp. - N-VIEW OPC Server Software
N-VIEWTM works with industrial standard OPC Client software and most popular Human Machine interface (HMI) packages to provide complete remote network traffic and status monitoring for N-TRON 200,... (read more)
Fotronic Corporation / Test Equipment Depot - GFC-8131H Frequency Counter
Frequency counters are digital indicating meters for accurate measurement and display of square wave and pulse input signals. There are several types of frequency counters which differ in frequency... (read more)
United Testing Systems, Inc. - United Specialized Testing Equipment
United manufactures a variety of special purpose tensile testing systems such as the FTF-48 Elastomer Testing System shown here. Do you have testing requirements that only a special purpose testing... (read more)
Gurley Precision Instruments - Virtual Absolute Technology
Gurley Precision Instruments has developed a unique encoding method that combines the simplicity of an incremental encoder with the reliability of an absolute encoder. (read more)
Brentwood Plastics, Inc. - Calculate shrink wrap film received from supplier
Q. How do I know whether or not I am receiving proper yield? We only get rolls marked with weight per roll and no footage. A. Anytime this happens, it is circumspect. You are probably getting a low... (read more)
 

Topics of Interest
Chapter List Chapter 14: PicBasic and PicBasic Pro Programming Chapter 15: Simple PIC Projects Chapter 16: Moving on with the 16F876 Chapter 17: Communication Overview BASIC is one... (Read More)
Counters are provided as built-in elements in PLCs and allow the number of occurrences of input signals to be counted. This might be where items have to be counted as they pass along a conveyor belt,... (Read More)
10.1 Introduction ThreadX provides 32-bit counting semaphores with counts that range in value from 0 to 2 32 1, or 4,294,967,295 (inclusive). There are two operations that affect the values of... (Read More)
Document The preceding cycle count activities should be documented in the form of a process map and standard operating procedures describing the exceptions to the procedures and how the cycle... (Read More)
Programs Now that we have a high level understanding of bar codes and wands, let's look at some code. We'll start with an experiment can we use MBasic to read the wand, or are we forced to code... (Read More)