Vihang Patil
unread,Apr 13, 2012, 10:28:18 AM4/13/12You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Hello
I am getting an array of values from an encoder which is attached to an Data Acquisition Device. The values that I get are in 2 arrays of LSW's amd MSW's
I want that the data to be converted in to floating point representation so that I can use it later for plotting data
I have also made a function to achieve this but the problem is that the function contains bin2dec() which is very slow and due to this my Data Acquisition device throws me an error of Buffer OverRun
function angle = encoder_angle(val)
%Function to calculate Angle from encoder
MSB = val(:,1);
LSB = val(:,2);
LSB = dec2bin(LSB,16);
MSB = dec2bin(MSB,16);
quad_angle = bin2dec([MSB LSB]); % this is slowing my DAQ device
[quad_angle] = TwosComplement(quad_angle, 32);
angle = quad_angle*360/144000; % encoder PPR is 36000, my DAQ sends (36000* 4)
angle = angle';
example:
Q1 =[0,65497;0,65503;0,65509;0,65517;0,65523;0,65529;1,1;1,7;1,13;1,21;1,27;]
angle = encoder_angle(Q1)
angle =
163.7425 163.7575 163.7725 163.7925 163.8075 163.8225 163.8425 163.8575 163.8725 163.8925 163.9075
I need the above function to operate much faster..
Thanks
Vihang Patil