Hi,
I add the whole code about my previous question.
We made a circuit for reading temperature and GSR. We faced some problems using the NFC reader and mobile application which we made.
1. The NFC reader didn't read our circuit.
We wrote source code at Matlab based on your RF430FRL152H Gui interface, but it didn't work. here's our code.
Pls, figure it out the code problem.
clear all; % clear workspace
close all; % closes all open windows
clc; % clear command window
% reset serial port
instrreset
delete(instrfindall)
command1 = '0108000304FF0000'; %TRF7970AEVM
command2 = '0109000304F0000000';
command3 = '0109000304F1FF0000';
command4 = '010C00030410002101020000'; %Register write request.
%% Skin conductivity + temp sensing
command5 = '011300030418022102001011000000FFFF0000'; %block 2 Oversampling rate 128
command8 = '01130003041802210001000601020101400000'; %block 0 % ADC1, ADC2 on , Freqency: Two times per second, number of passes: 2 (for infinite sampling), using thermistor (p33~p37)
command9 = '010B000304180220090000'; % samples all sensors Request mode.[sample data]
%% port connect
%Set Parameter
s = serial('COM6');
set(s, 'BaudRate', 9600, 'DataBits', 8, 'StopBits',1,'Parity', 'none');
%Communication begin
fopen(s);
% Remove data from input buffer
flushinput(s);
%% command
fwrite(s, command1);
S=fgetl(s); % response
% disp(S);
fwrite(s, command2);
S=fgetl(s); % response
S=fgetl(s); % response
% disp(S);
fwrite(s, command3);
S=fgetl(s); % response
% disp(S);
fwrite(s, command4);
S=fgetl(s); % response
% disp(S);
fwrite(s, command5);
S=fgetl(s); % response
S=fgetl(s); % response
S=fgetl(s); % response
% disp(S);
fwrite(s, command8);
S=fgetl(s); % response
S=fgetl(s); % response
% disp(S);
c=1; % while loop count
while(1)
fwrite(s, command9);
S=fgetl(s);
S=fgetl(s); % response: sensor data
ADC0=[0 0 0 0];
for i=4:11 % Hexadecimal
switch S(i)
case 'A'
ADC0(i)=10;
case 'B'
ADC0(i)=11;
case 'C'
ADC0(i)=12;
case 'D'
ADC0(i)=13;
case 'E'
ADC0(i)=14;
case 'F'
ADC0(i)=15;
otherwise
ADC0(i)=str2double(S(i));
end
end
ADC0V=((ADC0(6)*(16^3)) + (ADC0(7)*(16^2)) + (ADC0(4)*(16^1)) + (ADC0(5)) * 0.9)/((2^14)-1); % Temp data
ADC0V2=((ADC0(10)*(16^3)) + (ADC0(11)*(16^2)) + (ADC0(8)*(16^1)) + (ADC0(9)) * 0.9)/((2^14)-1); % light data
% Temp
TempConv(c)= (ADC0V/0.2795)*100000;
Temp_in_C(c) = (1.0/(((log10(TempConv(c)/100000.0)/log10(2.718))/4330.0)+(1.0 /298.15)))-273.15;
file_h = fopen('Temp_c.txt', 'w');
fprintf(file_h, '%.4f\n',Temp_in_C);
fclose(file_h);
% light
LED(c) = ADC0V2;
file_h = fopen('LED_data.txt', 'w');
fprintf(file_h, '%.4f\n',LED);
fclose(file_h);
figure(1);
plot(Temp_in_C,'r--*');
txt = ['Temperature: ' num2str(Temp_in_C(c)) ' °C'];
text(0,50,txt)
legend('Temp');
ylim([20 40])
drawnow;
figure(2);
plot(LED,'r--*');
legend('LED');
drawnow;
flushinput(s);
c=c+1;
end
LED2 = transpose(LED);
fclose(s);
delete(s);
delete(instrfindall)