Shop OBEX P1 Docs P2 Docs Learn Events
Use MATLAB to monitor and change spin variables/arrays — Parallax Forums

Use MATLAB to monitor and change spin variables/arrays

HannoHanno Posts: 1,130
edited 2009-08-20 03:02 in Propeller 1
Thanks to the inspiration and help from Henry, the latest ViewPort Client Kit now includes sample code for:

MATLAB
python
C#
vb.net
Excel

The documentation describes how to use either DDE (built into many Windows applications), or the vpClient.DLL to monitor variable and arrays, change variables, set trigges, load spin files, and more.

Henry's MATLAB program graphs the measurements taken from the Demoboard's microphone against time and also displays the fourier analysis.

See attached screenshot, or check out the video and kit with all samples, documentation, and source code to the vpclient.dll at: mydancebot.com/viewport/clients.php

Here's the full MATLAB code:
NET.addAssembly('C:\propeller\dde\dotNetDll\vpClient.dll') %Open the Propeller Viewport DLL

vpObj=vpClient.Main(); %create the viewport .Net object
vpMsg=vpObj.connect;  %connect to the VP server, vpMsg holds any messages
vpMsg=char(vpMsg); %We always need to convert from .Net datatypes to Matlab types
x=vpObj.request('marray',12); %get the data from Viewport
x=double(x); %convert from .Net object to Matlab array of doubles

%plot our results
figure, subplot(2,1,1)
plot(x);
title('Sample vs t')
xlabel('Index (t)')
ylabel('Sample Value')

subplot(2,1,2)
plot(abs(fft(x)));
title('Magnitude of FFT vs Freq');
xlabel('Freq');
ylabel('Abs(fft(x))');



Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!
1863 x 1190 - 195K

Comments

  • Mike HuseltonMike Huselton Posts: 746
    edited 2009-08-20 03:02
    Slow down, ya darn whippersnapper! Ya want the Singularity to eat you up?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
Sign In or Register to comment.