I am trying to use Vernier's SensorDAQ to acquire and plot data from a dyanometer in real-time in matlab (see http://www.vernier.com/products/interfaces/sdaq/).
I am using the exact same code as I have previously used with an X-series multifunction DAQ (NI USB-6343 ) connected to a pressure sensor. This worked perfectly.
However, with the SensorDAQ, it will not plot any data until after the code has finished running. I've tried alternative code and so on, but to no avail. I can only conclude there is a difference in the hardware / on-board software. Any suggestions?
Many thanks in advance,
Solved! Go to Solution.
Sorry, I should add the one slight difference in code is you connect to the device using vernier's toolbox:
s = sdaq.createSession; sdaq.addSensor(s,1,sdaq.Sensors.HandDynamometer);
An update from this morning, so I have narrowed it down further:
Dev1 is the SensorDAQ, Dev2 is the X series.
This code plots both datasets at the end of the script:
s = daq.createSession('ni'); ch1 = s.addAnalogInputChannel('Dev1','_sensor0_5V','Voltage'); ch2 = s.addAnalogInputChannel('Dev2','ai0','Voltage'); s.Rate = 100; s.DurationInSeconds = 10; s.NotifyWhenDataAvailableExceeds = 100; lh = addlistener(s,'DataAvailable', @(src,event) plot(event.TimeStamps, event.Data)); startBackground(s); disp('Go') s.wait(); delete(lh)
Whereas, if I comment-out Dev1, this code plots the data from Dev2 in realtime.
s = daq.createSession('ni'); % ch1 = s.addAnalogInputChannel('Dev1','_sensor0_5V','Voltage'); ch2 = s.addAnalogInputChannel('Dev2','ai0','Voltage'); s.Rate = 100; s.DurationInSeconds = 10; s.NotifyWhenDataAvailableExceeds = 100; lh = addlistener(s,'DataAvailable', @(src,event) plot(event.TimeStamps, event.Data)); startBackground(s); disp('Go') s.wait(); delete(lh)
Any idea what in the SensorDAQ might be causing this?
Thanks for getting touch regarding this issue. Can I just confirm, are you using the Vernier toolbox to interface with the sensorDAQ rather than DAQmx?
If so, I believe this issue is best handled by Vernier support as this is their toolbox and is subsequently not supported by National Instruments.
Alternatively, if it's this package you're using - https://uk.mathworks.com/matlabcentral/fileexchange/32636-matlab-support-package-for-vernier-sensord...
Matlab support may be who you're look for. Please see here for the answer forum from Matlab - https://uk.mathworks.com/matlabcentral/answers/?s_tid=hp_ff_s_answers
Thanks for replying, I have tried both. My first reply above is using the Vernier Toolbox:
The second reply is using the normal session based DAQmx functions:
All the vernier toolbox does is call the standard functions.
Both methods connect to the sensor fine (validated using a single scan e.g.data = s.inputSingleScan).
I have tried everything I can think of to get this working! That's why I believe it is something related to the configuration of NI card itself, but that's beyond my technical expertise...
Ah ok, thank you for the clarification. I don't have a particular working familiarity with the usage of the Vernier toolbox however, have you tried creating a session for each of the devices?
Yes, unfortunately that didn't work.
I was initially only using the SensorDAQ so it had it's own session. I only added the other NI card to check my code was correct.
(I'm guessing the SensorDAQ is a modified version of NI myDAQ, if anyone is familiar with whether this issue also exists for this card.)
Also, looking further into this function pack - https://jp.mathworks.com/hardware-support/nidaqmx.html - you should speak with Matlab support regarding this issue.
Apologies for not being able to offer further support.
You are correct in saying that the SensorDAQ is essentially a re branded version of a USB DAQ sold by NI (kind of like this - http://sine.ni.com/nips/cds/view/p/lang/en/nid/201986 although this may not be the specific equivalent).
From the sounds of things, it's likely a software implementation issue and as such, as I mentioned before it's best supported by Matlab. This said, it may be worth taking a look through the specification document (http://www.vernier.com/files/manuals/sdaq-specifications.pdf) to ensure that you're asking the card to operate within specification.
Thanks - I took look through the spec, but I'm not really sure what I can change. I've reduced the sampling rate to 10Hz, which it should be more than capable of. Unfortunately, I've had no response from Matlab, so I might have to admit defeat!