KEITHLEY kusb data acquisition box input problem (real time plotting and data analysis)

1 view (last 30 days)
Hi all, I am having some problems with this hardware, more specific with data input and processing. Let me quickly explain a set up. I have a small shaft on which I have small magnet mounted which passes next to a hall sensor. Every time the magnet passes to the hall sensor voltage drops. Constant voltage of 5 volts is applied to the sensor. So this is what I am trying to do. By using daq system I want to receive analog input (voltage) that ranges from 0 - 5 and then plot it in the real time while also extracting that data from the engine. This is the code I tried using:
%create a device object
AI = analoginput('dtol');
ain.inputtype='differential';
%addin a chant(AI, 'Timeout', 60);
duration = 10; %seconds - this can be user input
set(AI, 'SampleRate', 500);
ActualRate = get(AI, 'SampleRate');
addchannel(AI,0);
%configure
set(AI,'SamplesPerTrigger',duration*ActualRate)
preview = duration*ActualRate/100;
subplot(211)
P = plot(zeros(preview,10000)); grid on
title('Preview Data')
xlabel('Samples')
ylabel('Signal Level (Volts)')
%acquire data
start(AI)
%while AI.SamplesAcquired < preview
%end
while AI.SamplesAcquired < duration*ActualRate
data = peekdata(AI,preview);
set(P,'ydata',data)
drawnow
end
wait(AI,duration+1)
data = getdata(AI);
subplot(212), plot(data), grid on
title('All Acquired Data')
xlabel('Samples')
ylabel('Signal level (volts)')
delete(AI)
clear all
so by using this code I am trying to plot some samples for 10 seconds and then also store that acquired data in a vector for further analysis. These are the problems that I am having:
The data input never stops by its self. I have to ctrl-c it to stop it. While the program is running this is the message I receive:
Warning: The number of samples requested is not available.
The number of samples returned will be reduced.
Also I don't get any variable containing data. Plot shoes up but there is no data plotting on it, and my axis are x:-1,1 and y:-1,1 even though I specified them differently. Honestly I have no idea what is going on here. This is my first time using this system but I understand the code completely. If someone can help out with this I would be very thankful.
Thank you,
Uros
  2 Comments
Walter Roberson
Walter Roberson on 26 Jun 2012
Does this imply that you solved the driver and GPIB problems you described in previous questions?
Have you determined that you are able to communicate with the device ?
Uros
Uros on 26 Jun 2012
After rebooting Matlab and creating a new input, channel and run it for 10 seconds I get a plot of correct values which means I can communicate with the device.

Sign in to comment.

Answers (0)

Categories

Find more on Instrument Control Toolbox Supported Hardware in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!