This example shows how to acquire bridge circuit voltage ratio data, then compute and plot strain values.
Discover Devices that Support Bridge Sensor Measurements
To discover a device that supports bridge sensor measurements, click the name of the device in the list in the Command window, or access the device in the array returned by
daq.getDevices command. For this example use National Instruments® CompactDAQ Chassis NI cDAQ-9178 and module NI 9219 with ID
devices = daq.getDevices devices(7)
devices = Data acquisition devices: index Vendor Device ID Description ----- ------ --------- -------------------------------- 1 ni cDAQ1Mod1 National Instruments NI 9205 2 ni cDAQ1Mod2 National Instruments NI 9263 3 ni cDAQ1Mod3 National Instruments NI 9234 4 ni cDAQ1Mod4 National Instruments NI 9201 5 ni cDAQ1Mod5 National Instruments NI 9402 6 ni cDAQ1Mod6 National Instruments NI 9213 7 ni cDAQ1Mod7 National Instruments NI 9219 8 ni cDAQ1Mod8 National Instruments NI 9265 9 ni Dev1 National Instruments PCIe-6363 10 ni Dev2 National Instruments NI ELVIS II ans = ni: National Instruments NI 9219 (Device ID: 'cDAQ1Mod7') Analog input subsystem supports: 9 ranges supported Rates from 0.1 to 100.0 scans/sec 4 channels ('ai0','ai1','ai2','ai3') 'Voltage','Current','Thermocouple','RTD','Bridge' measurement types This module is in slot 7 of the 'cDAQ-9178' chassis with the name 'cDAQ1'.
Create an Analog Input Channel
Create a session, and add an analog input channel with the
Bridge measurement type. There are two strain gauges connected to the NI 9219 in half bridge configuration.
s = daq.createSession('ni'); addAnalogInputChannel(s,'cDAQ1Mod7', 0, 'Bridge');
Warning: The Rate property was reduced to 100 due to changes in the session configuration.
Set Channel Properties
You must set the bridge mode according to the bridge circuit configuration and the nominal resistance to the specified value in the strain gauge data sheet. In this example, the strain gauges used are the SGD-3/350-LY13 linear strain gauges from Omega®.
Set bridge mode to
Set nominal resistance of 350 ohm.
s.Channels.BridgeMode = 'Half'; s.Channels.NominalBridgeResistance = 350;
Set Scans Rate
Set the session to acquire 10 scans per second. By default, the ADC timing mode
ADCTimingMode of the channel is set to
'HighResolution'. Dealing with high resolution acquisition requires longer processing time; module NI 9219 restricts the data acquisition rate to a maximum of 2. In order to increase the rate the
ADCTimingMode is set to
s.Channels.ADCTimingMode = 'HighSpeed'; s.Rate = 10;
Set the data acquisition duration to 10 seconds.
Display the session object.
s.DurationInSeconds = 10; s
s = Data acquisition session using National Instruments hardware: Will run for 10 seconds (100 scans) at 10 scans/second. Number of channels: 1 index Type Device Channel MeasurementType Range Name ----- ---- --------- ------- --------------- --------------------------- ---- 1 ai cDAQ1Mod7 ai0 Bridge (Half) -0.50 to +0.50 VoltsPerVolt
startForeground to acquire data.
[data,time] = s.startForeground;
Calculate Strain from Voltage Ratio
The acquired data is the ratio of measured voltage to excitation voltage.
Use this output to compute strain values. Your bridge configuration determines the conversion formula.
For half bridge configuration use,
strain = - 2 * Vr/ GF
where GF is gauge factor provided in sensor data sheet and Vr is the voltage ratio output as measured by your bridge channel.
Note that we have assumed negligible lead wire resistance in this case. For the strain gauge used in this example the GF = 2.13.
strain = -2 * data/ 2.13; plot(time,strain); xlabel('Time (secs)'); ylabel('Strain');