From: Sean on
"Attila Kovacs" <kovacsek71.removeThis(a)gmail.com> wrote in message <hr4kgo$s06$1(a)fred.mathworks.com>...
> "Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <hr4ghp$253$1(a)fred.mathworks.com>...
> > "Attila Kovacs" <kovacsek71.removeThis(a)gmail.com> wrote in message <hr4d89$o3h$1(a)fred.mathworks.com>...
> > > I am collecting signal from two potentiometers via an NI A/D board. I would like to present real-time feedback by plotting one signal against the other (lissajous figure)always using one pair of datapoints. To this end I use peekdata function and plot the returned values. The problem I run into is that peekdata does not return every single value and therefore the display is jumping between the values returned by peekdata. I would appreciate any suggestions on how to make the display move smoother. This occurs regardless the sampling frequency.
> >
> > Look at the second input argument to peekdata:
> > you're running:
> > >>peekdata(obj, 1); %Here ai is your obj
> > if you want 1000 samples:
> > >>peekdata(obj, 1000);
> >
> > Of course this will return an error if there are <1000 samples.
> > You can ensure available samples with:
> > obj.SamplesAvailable
> >
> > Good Luck!
>
>
>
> Thanks for your input Sean. Unfortunately this doesn't solve my problem as it will plot the number of datapoints I specify in the argument:
> > >>peekdata(obj, 1000);
> thus creating the effect of leaving a trail.
> My goal is to always represent one point in time that continuously is updated by the peekdata function.
> Any other ideeas? Thanks.


Ok gotcha:
This should get close to what you want. It will never be 'true real time' but can approach the limits of the data acquisition toolbox and your machine.

%%%%In the main function:
%Set timer parameters.
tperiod = 0.2; %It will update every 0.2s. You can make this smaller but you're constrained by the speed of the machine, time to execute this TimerFcn, time to plot, and other overhead. Play with it and see how small you can get! It will never be complete real time.
set(ai, 'TimerPeriod', tperiod);
set(ai, 'TimerFcn', @daq_peek);
set(ai, {'StartFcn', 'StopFcn', 'TriggerFcn'}, {'','',''});

start(ai);

%%%% daq_peek function
function daq_peek(obj, event)
data = peekdata(obj, 1); %Preview data in acquisition toolbox buffer.
figure(1); %assuming you're using a figure and have no others of importance, you'll have to play with axis handles if it's in a gui etc.
plot(data(1), data(2) 'rs','MarkerSize',5); %data(1)= 1st channel, data(2) = 2nd
axis([xmin xmax ymin ymax]);%anticipated ranges or you could make them dynamic.
drawnow;
end
 | 
Pages: 1
Prev: dashed line in high resolution
Next: image mosaic