Lesson 6 Counters - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

Lesson 6 Counters

Description:

NI-TIO is only counter chip that directly supports quadrature encoders ... A quadrature encoder is a transducer that converts rotary motion into two pulse ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 34
Provided by: archanas
Category:

less

Transcript and Presenter's Notes

Title: Lesson 6 Counters


1
Counters
  • Topics
  • Counter Overview
  • Easy Counter VIs for
  • Event Counting
  • Pulse Generation
  • Pulse Measurement
  • Frequency Measurement
  • Position Measurement

2
Counter Signals
  • Counters accept and generate TTL signals

3
Parts of a Counter
  • Count Register
  • Stores the current count
  • Source
  • Input signal that changes the current count
  • Active edge (rising or falling) of input signal
    changes the count
  • Choose if count increments or decrements on an
    active edge
  • Gate
  • Input signal that controls when counting occurs
  • Counting can occur when gate is high, low, or
    between various combinations of rising and
    falling edges
  • Out
  • Output signal used to generate pulses

4
Counter Pins
  • Counter gate and source are PFI pins
  • PFI stands for Programmable Function Input
  • Allows use of one pin for multiple applications
  • For Example
  • Use pin 3 as digital trigger for analog input and
    counter gate

5
Counter Terminology
  • Terminal Count
  • Term for the last count before a counter reaches
    0
  • When counter reaches max count it starts over at
    0
  • Resolution
  • The size of the counter register specified in
    bits
  • Counter register size 2(resolution) - 1
  • Typical resolutions - 16, 24, 32 bit
  • Timebase
  • Internal signal that can be routed to the source
  • Common timebases - 100kHz, 20MHz

6
Different Counter Chips
Less
  • 8253 (16-bit)
  • Used on Lab and 1200 Series Devices
  • Am9513 (16-bit)
  • Used on PC-TIO-10 and Legacy Devices (i.e.
    AT-MIO-16F)
  • DAQ-STC (24-bit)
  • Used on E-Series Devices
  • Created by NI
  • NI-TIO (32-bit)
  • Used on 660x Devices
  • Created by NI

Features
More
7
Counter Palette
8
Easy VIs
  • Perform basic counter operations
  • Not suitable for more advanced applications
  • Compatible with Am9513 and DAQ-STC
  • Count Events or Time
  • Generate Delayed Pulse
  • Generate Pulse Train
  • Measure Frequency
  • Measure Pulse Width or Period

9
Counter Applications
  • Event Counting
  • Simple Event Counting
  • Time Measurement
  • Pulse Generation
  • Single Pulse Generation
  • Pulse Train Generation
  • Pulse Measurement
  • Period Measurement
  • Pulse Width Measurement
  • Frequency Measurement
  • Position Measurement

10
Event Counting
Simple Event Counting
  • Active edges on source signal increment the count
  • Active edge can either be rising or falling

Time Measurement
  • Timebase has known frequency
  • Time elapsed (Count) x (timebase period)

11
Event Counting
  • Count will increment for each rising edge on
    source
  • You can change active edge to falling
  • Counter will roll over when it reaches terminal
    count
  • Terminal count 2(Counter resolution) - 1

12
Count Events or Time VI
  • Source Edge
  • Chooses active edge of source signal (rising or
    falling)
  • Event Source/Timebase
  • Chooses source signal
  • Counter
  • Chooses counter to address
  • Start/Restart
  • Set to TRUE to start/restart counter
  • Stop
  • Set to TRUE to stop counter
  • Count
  • Returns value stored in count register
  • Seconds Since Start
  • Time since counter started

13
Pulse Generation
  • Generates a TTL signal on counters out pin

14
Pulse Characteristics
Pulse Polarity
15
Generate Delayed Pulse VI
  • Timebase Source
  • Internal or External
  • Counter
  • Chooses counter to address
  • Pulse Polarity
  • High or Low
  • Pulse Delay Width
  • Seconds if using internal timebase
  • Cycles if using external timebase
  • Actual Delay Width
  • May differ from desired values because hardware
    has limited resolution

16
Generate Pulse Train VI
  • Pulse Polarity
  • High or Low
  • Counter
  • Chooses counter to address
  • Number of Pulses
  • Set to 0 for continuous
  • Set to -1 to stop
  • Frequency (Hz)
  • 1/(Pulse Period)
  • Duty Cycle
  • (Width)/(Pulse Period)
  • Actual Parameters
  • May differ from desired values because hardware
    has limited resolution

17
Pulse Measurement
  • Use a timebase with a known frequency to measure
    characteristics of a unknown signal

18
Period Measurement
  • Count will increment for each rising edge on
    source
  • Counting can either start and end on rising or
    falling edges
  • Period of Gate (Count) x (1/source frequency)

19
Pulse Width Measurement
  • Count will increment for each rising edge on
    source
  • Counting can start on either rising or falling
    edge
  • Width of Gate (Count) x (1/source frequency)

20
Measure Pulse Width or Period VI
  • Counter
  • Chooses counter to address
  • Type of Measurement
  • Measure high pulse width
  • Measure low pulse width
  • Measure period (rising edge to rising edge)
  • Measure period (falling edge to falling edge)
  • Timebase
  • Routed to source
  • DAQ-STC has choice of 100kHz or 20Mhz
  • Pulse Width/Period (s)
  • Returns value in seconds
  • Valid
  • False if counter rolls over

21
Frequency Measurement
Your Signal
High Frequency
Low Frequency
Measure Pulse Width or Period
Measure Frequency
22
Low Frequency Measurement
Your Signal
  • Measure period and take the inverse
  • Frequency 1/Period
  • Pros
  • Only uses one counter
  • Good at low frequencies
  • Cons
  • Can see large error at high frequencies due to a
    phenomenon called synchronization error

Low Frequency
Measure Pulse Width or Period
23
Synchronization Error
  • Gate period is exactly four source cycles
  • Measurement could be off by /- 1

24
Effect of Synchronization error
  • You can measure a frequency of F with error of
    0.x
  • FMAX FSOURCE - (FSOURCE/(10.x))
  • If frequency you are measuring exceeds acceptable
    error use Measure Frequency VI

25
High Frequency Measurement
Your Signal
  • Still Period Measurement except
  • Gate is known
  • Pulse from another counter
  • Source is your signal
  • Pro
  • Works well at high frequencies
  • Con
  • Uses two counters

High Frequency
Measure Frequency
26
High Frequency Setup
Pulse Width Measurement
Single Pulse Generation
Gate
Out
Gate
Out
Count Register
Count Register
Known Pulse
Source
Source
Counter 1
Counter 0
Your Signal
Timebase
  • Frequency (count of Counter 1)/(pulse width of
    Counter 0 Out)
  • Synchronization error still exists in count of
    Counter 1
  • Error (/-1)/(period of Counter 0 Out)

27
Measure Frequency VI
  • Counter
  • Chooses counter to address
  • Gate Width (s)
  • Desired length of pulse used to gate the signal
  • The lower the signal frequency, the longer the
    width must be
  • Frequency (Hz)
  • Returns value in Hertz
  • Valid
  • False if counter rolls over
  • NOTE You must connect
  • Gate of chosen counter to
  • Out of other counter

28
Position Measurement
  • With a transducer called a quadrature encoder you
    can measure position
  • DAQ Signal Accessory has a quadrature encoder
  • NI-TIO is only counter chip that directly
    supports quadrature encoders
  • Possible to measure quadrature encoder with
    Am9513 and DAQ-STC

29
How Does an Encoder Work?
  • Shaft and disk rotate
  • Code track either passes or blocks light to
    sensor
  • Light sensor creates two pulse trains

Quadrature Encoder
30
Quadrature Encoder
  • Quadrature Encoders produce two pulse trains 90
    degrees out of phase
  • Clockwise rotation
  • Channel A leads Channel B
  • Counter-Clockwise rotation
  • Channel B leads Channel A

Clockwise Rotation
Counter-Clockwise Rotation
31
Up/Down Line
  • DAQ-STC counters also have an up/down line
  • DIO6 is up/down for counter 0
  • DIO7 is up/down for counter 1
  • TTL High Count up
  • TTL Low Count down

32
DAQ-STC and Encoders
  • Count on the falling edge of Channel A
  • Clockwise - B is high so count increments
  • Counter-Clockwise - B is low so count decrements
  • Channel B is hardwired to DIO6 on the DAQ Signal
    Accessory

33
Chapter 6 Summary
  • Counters accept and generate TTL signals
  • The main components of a counter are the source,
    gate, out, and count register
  • National Instruments devices could have one of
    four different counter chips
  • E-Series devices use the DAQ-STC chip
  • The Easy VIs can be used to perform event
    counting, pulse generation, pulse measurement,
    and frequency measurement
  • A quadrature encoder is a transducer that
    converts rotary motion into two pulse trains
    which are out of phase by 90 degrees
Write a Comment
User Comments (0)
About PowerShow.com