Author Topic: Problem working with Phidget+Matlab  (Read 437 times)

0 Members and 1 Guest are viewing this topic.

Offline pamecool2Topic starter

  • Beginner
  • *
  • Posts: 1
  • Helpful? 0
Problem working with Phidget+Matlab
« on: September 08, 2011, 07:04:17 AM »

Hi!

I'm new in the forum, I have the following problem:

I'm working with a Phidget (0/0/3) sensor, I’m obtaining the data (acceleration in x, y, z) trough Mat lab, currently I’m plotting a vector where the position sensor is pointing, also an Cartesian coordinate system  right in the middle of the plot.

My problem is that I want to stick the axis z direction to the movement of the sensor (position vector)

I hope I explain myself; I’m attaching the code and some images.

Thanks in advance  ;)



_____________


close all
t=(0:0.5:50);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%Eje de Coordenadas%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

TA=[0 1 0 0;
    1 0 0 0;
    0 0 1 0;
    0 0 0 1];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%Cosenos Directores%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

mod=sqrt(ax^2+ay^2+az^2);

ang1=acos(ax/mod);
ang2=acos(ay/mod);
ang3=acos(az/mod);

for i=1:length(t)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%Aceleración%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

error=calllib('phidget21', 'CPhidgetSpatial_getAcceleration', handle, 0,Acceleration);
ax=(Acceleration.Value);
 
error=calllib('phidget21', 'CPhidgetSpatial_getAcceleration', handle, 1,Acceleration);
ay=(Acceleration.Value);

error=calllib('phidget21', 'CPhidgetSpatial_getAcceleration', handle, 2,Acceleration);
az=(Acceleration.Value);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%Vector de Posición%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

x=(ax*t)/mod;
y=(ay*t)/mod;
z=(az*t)/mod;

pause(.01) % Rate de toma de muestras

col=hsv(150);
plot3(x,y,z,'color',col(i,:));
axis([-2 2 -2 2 -2 2]);
frame(TA,'w',1.5); %Eje de coordenadas
view(128,26);
grid on
title('Vector dirección Phidghet');
drawnow

end

 

Related Topics

  Subject / Started by Replies Last post
3 Replies
1560 Views
Last post December 11, 2007, 06:00:11 PM
by benji
6 Replies
6730 Views
Last post January 30, 2011, 11:25:10 AM
by S2L
1 Replies
2896 Views
Last post August 22, 2008, 12:05:08 PM
by Admin
matlab

Started by bob Software

10 Replies
1289 Views
Last post November 13, 2009, 08:14:36 PM
by Spoil9


Get Your Ad Here