Thanks,
Vikram
Hi
The MATLAB Serial external interface is suitable for communication with any
EIA232 device. Note that if you want to send precise bytes to the device,
it is often easier to start with FWRITE and FREAD at first. FPRINTF and
FSCANF use a Terminator character that can cause confusion in more generic
communication.
The VISA interface provided by the Instrument Control Toolbox product also
uses Terminator characters which may be related to your comment. FWRITE and
FREAD don't do anything unusual though.
s=serial('COM3');
fopen(s);
Sometimes it accepts this and sometime I get the following error
Port: COM3 is not available. No ports are available.
Use INSTRFIND to determine if other instrument objects are connected to the
requested device.
Can you help please. Is there something wrong the way I'm trying to communicate? I'm going by the manual.
-Thanks.
Virkam
priorPorts = instrfind % finds any existing Serial Ports in MATLAB
delete(priorPorts) % and deletes them
I can think of two possible problems.
MATLAB serial does not support hot plug events. That means the first time
you try to use serial ports, MATLAB looks at whats available and assumes
that is the case in the future. To avoid this issue, plug the serial port
in prior to your MATLAB session and do not remove it during your session.
The second possible issue is that you already have a serial port open. In
this case, the suggestsd solution of deleting the prior serial object will
resolve the problem. If you have the Instrument Control Toolbox product
installed, there is a handy 'INSTRRESET' command that will clean up all
those objects. Otherwise you can use INSTRFIND and delete the objects
found.
I have seen an analogous fault - with a FORTH development board. It normally defaults to COM3 , but if you reset the board, and don't reset the development environment, the board renegotiates a new virtual com port and becomes COM4; and of course you end up wih an error message almost identical to the one you are describing. You should check this on Control Panel. The solution is to reset the Com ports as discussed in the previous responses.
Regards
Dave Robinson