LabVIEW Crank-Angle Pressure Acquisition with E-Series Cards

Brian Holt11 min read
Data AcquisitionOther ManufacturerTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview

Crank-angle resolved (CAR) data acquisition is a standard measurement requirement in engine development. The goal is straightforward: capture one or more analog samples (typically cylinder pressure, but also crankcase pressure, vibration, ion current, or injector drive current) at a known angular position of the crankshaft, with a resolution commonly expressed as 1 scan/°CA (one analog-to-digital scan per crank-angle degree). Unlike time-based sampling, CAR sampling stays phase-locked to the engine cycle regardless of speed, which is essential for combustion analysis, valve-event timing, and knock detection.

National Instruments E-Series multifunction DAQ cards such as the PCI-6071E support the architecture required for this measurement: an external scan clock can be routed from a counter/timer or from a PFI (Programmable Function Input) terminal directly into the analog input sample-clock line. When the encoder pulse train (channel A or channel B) is used as that external scan clock, the AI subsystem acquires a new sample on every rising or falling edge of the encoder pulse — meaning one scan per encoder increment, not per elapsed time.

Prerequisites

  • Hardware: NI E-Series DAQ card (PCI-6071E, PCI-6024E, PCI-6031E, PCI-6052E, etc.) with available PFI pins supporting external AI sample clock routing.
  • Encoder: Incremental optical or magnetic encoder mounted to the crankshaft, providing channel A, channel B (90° quadrature, optional) and a once-per-revolution index Z pulse. TTL or open-collector with pull-up capable of meeting NI's digital input thresholds.
  • Transducers: Cylinder pressure transducer (piezoelectric or strain gauge with amplifier), GCD-SE linear transducers for piston travel, bucket-tappet LVDTs for valve lift, or any low-bandwidth analog source.
  • Software: LabVIEW with the NI-DAQ (Traditional) driver. The example VI Cont Acq&Graph ExtScanClk D-Trig.vi in the labview\examples\daq\anlogin\anlog8x.llb library serves as the starting point.
  • Signal conditioning: Charge amplifier or strain-gauge amplifier with anti-alias filter matched to the highest expected crank speed.

Hardware Wiring and Pinout

The E-Series AI subsystem uses pin PFI0 as the default external sample clock input on most PCI-60xxE boards. The 68-pin shield pinout varies by model; on the PCI-6071E the relevant terminals are:

Signal NI Terminal Encoder Pin Notes
Encoder A (or A') PFI0 / AI SCAN CLK Channel A output Drives AI sample clock. 1 sample/edge.
Encoder Z (index) PFI1 (or any DI line) Index output Once per revolution; used for digital trigger and revolution counter reset.
Encoder B (optional) PFI2 / Source 1 of CTR1 Channel B output Required only if direction is needed.
Pressure transducer + AI0 (ACH0) Amplifier output Differential recommended for noisy engine bays.
Encoder power +5V (pin 14 on SH68-68) +V supply Verify encoder current draw ≤ NI's 5V sourcing limit.
Digital ground DGND (pin X) Common Mandatory: encoder ground must tie to NI DGND, not chassis ground alone.
Critical wiring note: Encoder signal ground must return to the NI card's DGND reference. Using chassis or engine ground creates a ground loop that injects mains-frequency noise into the pressure trace and corrupts the AI scan-clock edges, producing dropped or extra samples.

Encoder Resolution and Scan-Rate Math

The number of analog scans acquired per crankshaft revolution is set entirely by the encoder's pulse count per revolution (PPR). The relationship is:

scans/rev = PPR × quadrature_factor × edge_factor

Where:

  • quadruple_factor = 1 for single-channel A, 2 for A and B in quadrature, 4 for full quadrature (x4 decoding).
  • edge_factor = 1 if sampling on rising edge only, 2 for rising+falling.

Examples of scan-per-revolution values at common resolutions:

Encoder PPR (×1) Scans/rev (×1 A only, rising) Resolution (°CA/scan)
360 360 1.000 °CA
720 720 0.500 °CA
1024 1024 0.352 °CA
1800 1800 0.200 °CA
3600 3600 0.100 °CA

To achieve exactly 1 scan/°CA, a 360-PPR encoder in x1 mode is required. This is what the original forum user (Woodi) configured. Higher resolution (e.g., 7200 PPR) gives 0.05 °CA/scan — useful for combustion-knock analysis where 0.1° crank-angle resolution is the typical floor.

Sample-rate burden on the NI card is:

effective_AI_rate = (RPM/60) × scans_per_rev

For a 4-stroke engine at 3000 RPM with 3600 scans/rev:

AI_rate = 50 × 3600 = 180,000 S/s

The PCI-6071E is rated at 1.25 MS/s aggregate, so this leaves substantial headroom for additional channels (pressure, ion current, injection control current) provided the DMA path is configured for high-speed streaming.

Configuring the AI Task in Traditional NI-DAQ

Two timing signals must be configured in parallel:

  1. AI sample clock source: Set to External Scan Clock, source = PFI0. Polarity = rising edge. Number of scans = finite or continuous (continuous is the practical choice for sustained engine runs).
  2. Counter task for position tracking: Configure CTR1 in Event Counting mode gated by the Z-index pulse; this gives a revolution counter and lets the software reset the degrees display to 0°CA on every Z transition.

LabVIEW block diagram wiring for the canonical example VI Cont Acq&Graph ExtScanClk D-Trig.vi:

AI Config (CH0, range ±10V, continuous)
   clock source → External (PFI0)
   trigger      → Digital trigger on PFI1 (encoder Z, rising edge)
   buffer size  → 14400 (matches 7200 PPR × 2 rev history)
   AI Start

CTR Config (Counter 1)
   gate   → PFI1 (Z index, rising)
   source → Internal 20 MHz timebase
   mode   → Counting Edges
   output → revolutions.int32

The Z index must be routed to both a digital trigger input (to capture the first revolution synchronously) and a counter (to count revolutions and reset the angular position). If the application needs to label each scan with its absolute crank angle in real time, the index event is also written to the AI buffer's metadata stream via AI_Read with position-event timestamps.

Does the VI Truly Acquire 1 Scan per Encoder Pulse?

Yes — when the AI sample clock is sourced from PFI0 (or any other PFI pin configured as the external scan clock) and the encoder A channel is wired to that same PFI, the AI subsystem performs one analog-to-digital conversion on each valid clock edge. The hardware does not measure the time between the first two pulses and extrapolate; the ADC is clocked by the encoder line directly. The post-condition is:

scan_n timestamp ≈ n × (60 / (RPM × PPR)) seconds after last Z

However, two real-world effects can break this assumption:

  1. Encoder jitter: Optical encoders exhibit ±0.05° to ±0.1° mechanical jitter on individual pulses. This translates to point-to-point angular noise in the pressure trace, not a structural error in the sample count.
  2. Missed edges: If the encoder cable picks up EMI from the ignition system, a few edges can be lost or doubled, causing single scans to be skipped or duplicated. This is detectable as a sudden jump in the pressure trace that does not repeat every revolution.

For this reason, an external verification with a function generator is the recommended commissioning step:

  • Drive PFI0 with a known 100 Hz TTL square wave.
  • Acquire for 10 seconds.
  • Confirm exactly 1000 samples are returned in continuous mode (sample counter in the AI Read block).
  • If sample count matches frequency × time, the AI is being clocked correctly by the external pin.

Triggering and Crank-Angle Reset Logic

The Z index pulse should be configured as the digital trigger source. In Traditional NI-DAQ, set:

AI Trigger:
   type    = Digital
   source  = PFI1
   slope   = Rising
   mode    = Start on Trigger (one-shot) or Restart (re-armable)

For continuous per-revolution re-arming (so the system recovers from a missed tooth or stall), use Pre-Trigger Reference mode and route the Z pulse as a reference trigger; this lets the buffer pre-fill with N scans of pre-trigger data, then re-center on each Z event.

Resetting the displayed crank angle to 0°CA at every Z event is a software function performed in the LabVIEW block diagram:

Revolution counter (CTR1) → i32
Angle = (i32 MOD 720) × 0.5 °CA  // for 720 PPR
Display = Angle - TDC_offset       // configurable per cylinder

TDC (top-dead-center) offset calibration is performed with a TDC indicator on the crank and a static compression test; the angular difference between the index pulse edge and the actual TDC position of cylinder 1 is stored as a constant and subtracted from the displayed angle.

Dual-Measurement Architecture (Counter + AI)

The recommended architecture runs two hardware-timed tasks in parallel:

  • Task 1: Analog Input — pressure, lift, ion current, all clocked by the encoder A pulse. Buffer continuously, write to disk in chunks.
  • Task 2: Counter — measures instantaneous RPM by counting encoder edges against the 20 MHz timebase over each Z-to-Z period. This provides a tachometer trace phase-locked to the same data set.

On E-Series hardware, the two tasks share the RTSI bus and can run simultaneously without CPU intervention. Critical point: the counter must not use PFI0 as its source, because that pin is already the AI sample clock. Use PFI2/PFI3 or a counter that internally routes to the APFI bus.

Data Storage and Post-Processing

For a 4-cylinder 4-stroke engine at 3000 RPM with 7200 scans/rev, raw AI throughput is 360 kS/s/channel. A typical 30-second run produces:

30 s × 360,000 = 10.8 MSamples × 2 bytes = 21.6 MB per channel

Use TDMS file format for streaming — it provides built-in support for absolute time, channel grouping, and lossless compression. Avoid legacy DAQStream (.dst) on the PCI-6071E; the older DST format is single-channel and writes do not survive driver crashes gracefully.

Post-processing (resampling, angle-domain averaging over N cycles, P-V calculation) is performed in DIAdem or a custom LabVIEW script, not in the real-time acquisition loop.

Alternative: Yokogawa DL708 Scope-Method

Troubleshooting Matrix

Symptom Likely Cause Remediation
Buffer overrun / -10846 error AI rate exceeds disk write throughput or DMA bottleneck Reduce channel count, switch from continuous double-buffered to single-buffered, or move to PXI with RAID-0 storage.
Sample count not equal to pulses × time Encoder signal not reaching PFI0; floating or inverted logic Verify with scope at PFI0; confirm 0–5V swing; check DGND return.
Angle display drifts after several revolutions Z index missed once (jitter, contact bounce) Add 10 µF + 1 kΩ RC debounce on Z; verify optical encoder disk cleanliness.
Pressure trace is single-cycle noise Ground loop on transducer shield Tie shield to amplifier ground only; isolate shield at NI end.
Acquisition does not start on Z Trigger source not mapped to PFI1, or slope inverted Re-check AI Trigger Config; for some E-Series cards the default trigger source is PFI0/AI START, not the dedicated trigger pin.
LabVIEW example VI not visible in examples tree Full LabVIEW development system not installed (only Run-Time) Install LabVIEW with the "DAQ" option selected; the example VIs ship with the development environment, not the runtime.

Verification Procedure

  1. Connect function generator (5V TTL square wave, 1 kHz) to PFI0 and DGND. Run Cont Acq&Graph ExtScanClk D-Trig.vi for exactly 10 seconds. Confirm the acquired sample count is between 9990 and 10010. If not, the external clock is not being sourced correctly.
  2. Connect the encoder to the test bench without the engine running. Hand-rotate the shaft. Confirm a single Z pulse is observed per revolution on a scope at PFI1 and that the AI buffer increments at the expected rate.
  3. Run the engine at idle (typically 800 RPM) for 30 seconds. Plot pressure vs. angular position. Verify 720 pressure samples per revolution (assuming 720 PPR). Look for cycle-to-cycle repeatability; standard deviation across 100 cycles should be < 2% of peak pressure for a healthy engine.
  4. Step the engine to 1500, 2500, 3500 RPM. Confirm the pressure trace does not shift in angle relative to the Z index (indicates timing is purely angle-locked, not time-locked).
  5. Cross-check with a high-speed pressure transducer on a calibrated combustion bomb if available — this validates the entire chain including transducer, charge amp, AI, and reconstruction.
Safety: Engine test cells require exhaust extraction, fire suppression, and a remote E-Stop accessible from outside the cell. Rotating shafts and belts are crush hazards; cylinder pressure transducers must be installed in certified adapters and torqued to the transducer manufacturer specification. Never use plastic-bodied pressure fittings on combustion pressure taps.

FAQ

How do I get exactly 1 scan per degree of crank angle in LabVIEW?

Use a 360-PPR (pulses-per-revolution) encoder in x1 single-channel mode and wire its A output directly to the E-Series card's external AI sample clock pin (PFI0 on most PCI-60xxE boards). The AI subsystem will then perform one ADC conversion per rising edge of the encoder — exactly 360 scans per revolution, or 1.0 °CA per scan.

Will the example VI 'Cont Acq&Graph ExtScanClk D-Trig.vi' actually take one scan per encoder pulse?

Yes. When the AI sample clock is configured to an external PFI source, the ADC is hardware-clocked by every edge on that pin. The driver does not measure the time between the first two pulses and extrapolate. For guaranteed behavior, verify the sample count against a known function-generator signal before connecting the encoder.

Why do I see a different sample count than expected at high RPM?

Common causes are: (1) the encoder signal cannot drive the 50 Ω termination at the PFI pin — add a 470 Ω series resistor at the encoder output, (2) ignition-system EMI causing missed or doubled edges, or (3) the AI subsystem hitting its maximum aggregate sample rate for the number of channels enabled. Verify with an oscilloscope at the PFI pin and a software sample counter to disambiguate.

How do I reset the displayed crank angle to 0 on each revolution?

Route the encoder Z (index) pulse to a counter input gated by the index, count revolutions, and subtract the encoder's TDC offset constant in software. For the display itself, multiply (modulo PPR) by the per-pulse angular increment (360/PPR °CA) to obtain the live angle in degrees.

Can I sample multiple channels at 1 scan/°CA simultaneously?

Yes, provided the aggregate AI rate (channels × scans/rev × RPM/60) does not exceed the E-Series card's maximum sample rate (1.25 MS/s on the PCI-6071E, 200 kS/s on PCI-6024E). The encoder pulse clocks the entire AI scan, so all enabled channels in the task are sampled synchronously on each clock edge — there is no inter-channel skew in the angle domain.

Do I need a separate counter task to measure RPM?

Strictly speaking, no — RPM can be derived in software from the time between successive Z events, since the AI buffer receives one Z-timestamp per revolution. However, a dedicated counter task running in parallel provides a per-revolution tachometer trace without consuming CPU cycles, and is the recommended architecture for production test cells.

Back to blog