Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to interface PORTs using MATLAB ??

Status
Not open for further replies.

ahmad_abdulghany

Advanced Member level 4
Joined
Apr 12, 2005
Messages
1,206
Helped
102
Reputation
206
Reaction score
22
Trophy points
1,318
Location
San Jose, California, USA
Activity points
11,769
ports in matlab

Assalamo Alaykom

How are you all my Matlab friends :)

here you are another problem in matlab :

I wanna learn how to communicate with PORTs ?

Please help as strong as you did before .. thank you
 

gpib parallel matlab

using a Serial Port in matlab is similar to using files.

Code:
s = serial('COM1');
fopen(s)
fprintf(s,'*IDN?')
idn = fscanf(s);
fclose(s)

and there are many other usefull routines in matlab for serial port communication
see matlab online help:
**broken link removed**
and searching for "Serial Port" gives you:
**broken link removed**
and a good startpoint is the fopen page:
**broken link removed**
with links to related functions below.

Matlab help is pretty good! With lots of usefull examples, good and relevant hyperlinks on all pages, ... You should try it and learn to use it. You'll become an expert in no time ;-)

Antharax
 
matlab ethernet data access interface

What type of ports are you interested in? Serial, parallel, USB, PS2, firewire, ethernet, joystick, audio, GPIB, ... ?
 

using a joystick with matlab

echo47 said:
What type of ports are you interested in? Serial, parallel, USB, PS2, firewire, ethernet, joystick, audio, GPIB, ... ?
Do you have idea how MATLAB communicates with USB port? Thanks.
 

gpib with matlab

echo47 said:
What type of ports are you interested in? Serial, parallel, USB, PS2, firewire, ethernet, joystick, audio, GPIB, ... ?

:arrow: Currently, I am interrested with Parallel and serial port interfacing ..
But, it will be also very useful to learn how to interface with other ports.
 

matlab usb

yongchai said:
echo47 said:
What type of ports are you interested in? Serial, parallel, USB, PS2, firewire, ethernet, joystick, audio, GPIB, ... ?
Do you have idea how MATLAB communicates with USB port? Thanks.

i have heard that matlab cannot communicate with the USB port directly. but it can communicate with it through a driver. i dont know the details. by the way what is you application. maybe a serial connection will be enough for what you want to do.
 

echo47 said:
What type of ports are you interested in? Serial, parallel, USB, PS2, firewire, ethernet, joystick, audio, GPIB, ... ?

you asked me about needed ports .. and i told you that i wanna interface matlab with serial and parallel ports.. and you didnt post any reply after this ..

Please reply if you dont mind ..

Thank you very much
 

you can use three utilities

DAQ (data acquisition toolbox , which has parallel port interfacing)
SIMULINK REAL TIME WINDOWS TARGET
SIMULINK XPC TARGET

these utilities has blocks for interfacing with any port including parallel port
 

to use USB in matlab you either use MATLAB VISA object, but only supports specific products from TI, NI and some other companies.
or use virtual COM port to interface it, then you can use serial interface from matlab.
 

If you are trying to communicate with Matlab in real-time, check out **broken link removed**. As far as I know, this is the only platform that allows real-time communication with external hardware through the serial port.
 

I am communicating with ehternet using UDP

My transmitter code is:

u1=udp('192.168.1.55', 9091,'LocalPort', 9090);
set(u1, 'OutputBufferSize', 8192)
set(u1, 'TimeOut', 10)
fopen(u1)
get(u1, 'Status')
while(1)
fwrite(u1, ubuffer(1, : ), 'double'); %ubuffer is of size 1x1024
end
fclose(u1)
delete(u1)

My receiver code is:

u=udp('192.168.1.166', 9090, 'LocalPort', 9091, 'InputBufferSize', 8192, 'TimeOut', 10);
fopen(u);
while(1)
[a,count]= fread(u, 1024, 'double');
end
fclose(u)
delete(u)

My problem is that as soon as i increase the number of elements transmitted past 64, i can only receive 64 elements at receiver. Like if i transmit 1x1024 element array, at receiver i get first 64 elements only. Like at this line of code at receiver:

[a,count]= fread(u, 1024, 'double');

i only get 'a' of size 64x1, although i should get 1024x1 size of 'a'. The value of count is also 64, it should be 1024.

To rectify this i have to use a loop and make a 2d array at receiver like 64x16 for 1024 element transmitted array. Also i get a warning "The specified amount of data was not returned in time" after reading every 64 elements. Is there any solution to receive all elements like 1024 in one go??? like i dont have to use loop just
[a,count]= fread(u, 1024, 'double');
and i get all the transmitted elements.

My second problem is that i cannot transmit complex numbers using UDP. I transmit 3 complex numbers and at receiver i only get real part of these complex numbers. Any ideas????
 

Re: using a joystick with matlab

yongchai said:
Do you have idea how MATLAB communicates with USB port? Thanks.
 

with instrument control toolbox installed, matlab can commumicate with many devices, such as serial/parallel ports, ethernet, GPIB and so on.
refer to Mathworks' site for more details, or type "help instrument" in matlab command window.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top