Main Content

Acquire Sound Pressure Data

This example shows how to acquire sound data from an NI 9234. The device is in an NI cDAQ-9178 chassis, in slot 3 with ID cDAQ1Mod3.

Create a DataAcquisition object, and add an analog input channel with Microphone measurement type:

d = daq('ni');
ch = addAnalogInputChannel(d,"cDAQ1Mod3",0,"Microphone");

Set the channel sensitivity to 0.037 v/pa.

ch.Sensitivity = 0.037
ch = 

Data acquisition analog input microphone channel 'ai0' on device 'cDAQ1Mod3':

          Sensitivity: 0.037
MaxSoundPressureLevel: 136
    ExcitationCurrent: 0.002
     ExcitationSource: Internal
             Coupling: AC
       TerminalConfig: PseudoDifferential
                Range: -135 to +135 Pascals
                 Name: ''
                   ID: 'ai0'
               Device: [1x1 daq.ni.CompactDAQModule]
      MeasurementType: 'Microphone'
        ADCTimingMode: ''

Change the maximum sound pressure level to 100 dB.

ch.MaxSoundPressureLevel = 100
ch = 

Data acquisition analog input microphone channel 'ai0' on device 'cDAQ1Mod3':

          Sensitivity: 0.037
MaxSoundPressureLevel: 100
    ExcitationCurrent: 0.002
     ExcitationSource: Internal
             Coupling: AC
       TerminalConfig: PseudoDifferential
                Range: -135 to +135 Pascals
                 Name: ''
                   ID: 'ai0'
               Device: [1x1 daq.ni.CompactDAQModule]
      MeasurementType: 'Microphone'
        ADCTimingMode: ''

Acquire 4 seconds of data and save it in a variable.

[data,time] = read(d,seconds(4),"OutputFormat","Matrix");

Plot the data.

plot(time,data)

Plot of 4 seconds of acquired data

Related Topics