acquire bridge measurements
this example shows how to acquire and plot data from an ni usb-9219
device. the device id is cdaq1mod7
.
create a dataacquisition object assigned to the variable
d
:
d = daq("ni");
add an analog input channel for bridge
measurement type,
assigned to the variable ch
:
ch = addinput(d,"cdaq1mod7","ai1","bridge");
you might see this warning:
warning: the rate property was reduced to 2 due to the default adctimingmode of this device, which is 'highresolution'. to increase rate, change adctimingmode on this channel to 'highspeed'.
to allow a higher acquisition rate, change the channel
adctimingmode
to 'highspeed'
:
ch.adctimingmode = "highspeed"
you might see this warning:
warning: this property must be the same for all channels on this device. all channels associated with this device were updated.
change the acquisition rate to 10
scans per second.
d.rate = 10;
set the channel bridgemode
to 'full'
, which
uses all four resistors in the device to acquire the voltage values:
ch.bridgemode = "full"
ch = data acquisition analog input channel 'ai1' on device 'cdaq1mod7': bridgemode: full excitationsource: internal excitationvoltage: 2.5 nominalbridgeresistance: 'unknown' range: -0.063 to 0.063 voltspervolt name: empty id: 'ai1' device: [1x1 daq.ni.compactdaqmodule] measurementtype: 'bridge' adctimingmode: highspeed
set the resistance of the bridge device to 350 ohms:
ch.nominalbridgeresistance = 350
ch = data acquisition analog input channel 'ai1' on device 'cdaq1mod7': bridgemode: full excitationsource: internal excitationvoltage: 2.5 nominalbridgeresistance: 350 range: -0.063 to 0.063 voltspervolt name: empty id: 'ai1' device: [1x1 daq.ni.compactdaqmodule] measurementtype: 'bridge' adctimingmode: highspeed
save the acquired data to a variable and start the acquisition:
data = read(d,seconds(1),"outputformat","matrix")
plot the acquired data:
plot(data)