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, on slot 3 with ID cDAQ1Mod3.

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

s = daq.createSession('ni');
addAnalogInputChannel(s,'cDAQ1Mod3', 0, 'Microphone');

Set the channels sensitivity to 0.037 v/pa.

s.Channels.Sensitivity = 0.037;

Examine the channel properties:

s.Channels(1)
ans = 

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 100db and examine channel properties.

s.Channels.MaxSoundPressureLevel = 100;
s.Channels(1)
ans = 

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: ''

Set acquisition session duration to 4 seconds.

s.DurationInSeconds = 4;

Acquire the data against time and save it in a variable.

[data,time] = startForeground(s);

Plot the data.

plot(time, data)

Related Topics