My project is AVR Based Temperature Controller.
Show older comments
I'm using serial communication for interfacing the hardware with Matlab Simulink. I'm suppose to Receive & Transmit the data, but I'm only able to receive it, while transmitting simulink shows some error.
function
temp_val=Serial_out(Temp_val)
% portno = input('Port No = ');
% if portno==1
% Port = 'COM1'
% else
% display('Use 1 for Com1 port');
% end
s = serial(
'COM1','BaudRate',4800,'DataBits',8);
fopen(s)
%A=[34,0]
c_data(1)=mod(Temp_val,10)
c_data(2) = c_data(1)+48;
c_data(2)=(Temp_val-c_data(1))/10
c_data(2) = c_data(2)+48;
c_data=Temp_val
%temp_str = num2str(c_data);
c_data=c_data'
%c_data = circshift(c_data,1)
c_data = Temp_val;
fprintf(s,'%d',c_data)
fclose(s)
% clear s
1 Comment
Walter Roberson
on 22 Apr 2012
What error is shown?
Answers (0)
Categories
Find more on Use COM Objects in MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!