Prev: Compile to Stand-Alone Application
Next: How do I avoid errors using Seek on ADODB.Recordset with composite key?
From: Renhao on 5 Jul 2010 18:28 i want to use matlab to talk to one sensor, before using matlab, i already use hyper terminal program to get the data from sensor to Pc, the requested protocol is to send instruction"00 02 3B AA", however i can not get the responce of the sensor. can somebody help me?the matlab code is listed below, g = serial('COM3'); %set(s,'BaudRate',19200); %s = serial('COM3','BAUD',19200); !mode com3:19200,n,8,1 fopen(g); as=['00','02','3B','AA']; fwrite(g,as,'uint8'); mydata=fread(g,7,'uint8'); fclose(g) delete(g) clear g
From: Walter Roberson on 5 Jul 2010 18:32
Renhao wrote: > i want to use matlab to talk to one sensor, before using matlab, i > already use hyper terminal program to get the data from sensor to Pc, > the requested protocol is to send instruction"00 02 3B AA", however i > can not get the responce of the sensor. can somebody help me?the matlab > code is listed below, > g = serial('COM3'); > %set(s,'BaudRate',19200); > %s = serial('COM3','BAUD',19200); !mode com3:19200,n,8,1 fopen(g); > as=['00','02','3B','AA']; > fwrite(g,as,'uint8'); > mydata=fread(g,7,'uint8'); > fclose(g) > delete(g) > clear g If you are to literally send the ASCII characters 0 0 space 0 2 and so on, then your "as" array is missing the spaces. Possibly though you need to send the binary equivalent of those four bytes. If so, then as = hex2dec({'00','02','3B','AA'}); |