serial port programming using matlab GUI

Status
Not open for further replies.

neesha

Newbie level 4
Joined
Jul 19, 2013
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
43
This is my codes for base workspace in MATLAB. the codes turns ON the pump. BUT it does not work when i used this is GUI. can anyone help me on what modification should i do in order to make the pump to turn ON when it is controlled using GUI?

s = serial ('COM7');
set (s,'Baudrate',1200,'Parity','even');
set (s,'DataBits',8);
set (s,'Stopbits',1);
fopen(s);
txdata = ['E9';'01';'06';'58';'4C';'00';'C8';'01';'01';'DB'];
txdata_dec = hex2dec(txdata);
fwrite(s,txdata_dec,'unit8')
 

try set (s,'Stopbits',2);
 

try set (s,'Stopbits',2);


Its still not working. I think there might be smtg wrong with the commands, because the hex codes are the protocols for the pump.it is fixed.There are different commands for MATLAB GUI. they are not the same with base workspace commands. But i cant figure out which line. :-(
 

I did this ... I can send and recieve it.
s = serial ('/dev/ttyUSB0');
s.BaudRate = 9600;
s.Terminator = 'LF/CR';
fopen(s);
fprintf(s,'ls');
out = fscanf(s);
fclose(s)
delete(s)
clear s
 

 

What do you mean by GUI?
 

as standalone application?
 

as standalone application?


it is together with matlab..but the codes are lil bit different from the codes that i have posted before.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…