Why Is my Square Wave Being Read as a Sine Wave?

Updated Mar 10, 2023

Reported In

Hardware

  • PXI Analog Input Module
  • PXI Multifunction I/O Module

Software

  • Measurement & Automation Explorer (MAX)
  • LabVIEW

Driver

  • NI-DAQmx

Issue Details

I'm using a high enough sample rate and I'm trying to read a square wave or digital signal with sharp edges using my analog input DAQ device and the measured signal seems to be showing up as a sine wave instead of the expected square wave.

Solution

Assuming a high enough sample rate is being used to read a signal and accurately represent its frequency and shape characteristics, this behavior can sometimes be caused by an enabled lowpass filter on cards with software selectable filters. 

When a lowpass filter is enabled, it effectively filters out all the frequencies above the selected cutoff frequency. In the case of a square wave, this results in a filtered signal which looks closer to a sine wave since the expected signal to be measured now only contains the lower frequency components below the filter cutoff frequency, and no longer contains the higher frequency components which make it a square wave.

This is mostly seen with square waves or digital signals with sharp edges because those types of signals largely consist of high frequency components or harmonics. With cards that have software selectable lowpass filters, this can be fixed by simply disabling the filter. Please see the article below in the Related Links section for more information on how to enable and disable these filters.

Additional Information

DAQ devices such as some of our SC Express modules (ex: PXIe-4300) have onboard lowpass filters with software selectable modes (for example: 10 kHz, 100 kHz, disable). However, not all cards have software selectable filters, and some actually have filters that automatically adjust their cutoff frequency based on the sample rate and are not user configurable or software selectable. Please refer to your device's specifications to check the exact type of filtering it supports.