- Mon Feb 21, 2011 1:56 pm
#120866
I am a bit of a newbie at this so my apologies if I am doing something exceptionally silly.
I am trying to transmit a single ADC channel (a potentiometer) of data between my two xbee modules. One is on an USB explorer the other just a regular board.
I have configured my xbees fine, can open the serial channel in Matlab and get a steady signal through. Using this code:
s = serial('COM3');
fopen(s);
A=fread(s, 100);
However, I tried to parse the A variable as follows and I get 1023 always for valueA despite known changes (measured with a multimeter) in the input voltage from 2V down to as low as 0.1 V. I tried switching to a different input channel and still have the same problem.
n=find(A==126); % find data chunk header
for i=1:length(n) % compensation for change in bit format btwn xbee and computer
eleventh_number=A(n(i)+11);
twelfth_number=A(n(i)+12);
valueA(i)= bitshift(eleventh_number,8) + twelfth_number;
end
%% Conversion into voltage, Very uncertain of this conversion
voltA=(1024.*valueA+600)./1200; % from NorthWesternU website
Any help would be greatly appreciated. I've searched for examples in Matlab to no avail. Thanks!
I am trying to transmit a single ADC channel (a potentiometer) of data between my two xbee modules. One is on an USB explorer the other just a regular board.
I have configured my xbees fine, can open the serial channel in Matlab and get a steady signal through. Using this code:
s = serial('COM3');
fopen(s);
A=fread(s, 100);
However, I tried to parse the A variable as follows and I get 1023 always for valueA despite known changes (measured with a multimeter) in the input voltage from 2V down to as low as 0.1 V. I tried switching to a different input channel and still have the same problem.
n=find(A==126); % find data chunk header
for i=1:length(n) % compensation for change in bit format btwn xbee and computer
eleventh_number=A(n(i)+11);
twelfth_number=A(n(i)+12);
valueA(i)= bitshift(eleventh_number,8) + twelfth_number;
end
%% Conversion into voltage, Very uncertain of this conversion
voltA=(1024.*valueA+600)./1200; % from NorthWesternU website
Any help would be greatly appreciated. I've searched for examples in Matlab to no avail. Thanks!