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,209
Helped
102
Reputation
206
Reaction score
21
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
 

Antharax

Full Member level 4
Joined
Dec 31, 1999
Messages
208
Helped
14
Reputation
28
Reaction score
1
Trophy points
1,298
Activity points
2,865
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
 

echo47

Advanced Member level 5
Joined
Apr 7, 2002
Messages
3,942
Helped
638
Reputation
1,274
Reaction score
89
Trophy points
1,328
Location
USA
Activity points
33,176
matlab ethernet data access interface

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

yongchai

Junior Member level 1
Joined
Jun 11, 2005
Messages
15
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
1,420
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.
 

ahmad_abdulghany

Advanced Member level 4
Joined
Apr 12, 2005
Messages
1,209
Helped
102
Reputation
206
Reaction score
21
Trophy points
1,318
Location
San Jose, California, USA
Activity points
11,769
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.
 

samcheetah

Advanced Member level 2
Joined
May 25, 2004
Messages
646
Helped
39
Reputation
78
Reaction score
10
Trophy points
1,298
Location
Pakistan
Activity points
6,916
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.
 

ahmad_abdulghany

Advanced Member level 4
Joined
Apr 12, 2005
Messages
1,209
Helped
102
Reputation
206
Reaction score
21
Trophy points
1,318
Location
San Jose, California, USA
Activity points
11,769
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
 

nebisman

Full Member level 4
Joined
Apr 13, 2002
Messages
226
Helped
10
Reputation
22
Reaction score
9
Trophy points
1,298
Activity points
1,849
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
 

elrayes

Full Member level 5
Joined
Jun 3, 2008
Messages
246
Helped
20
Reputation
40
Reaction score
7
Trophy points
1,298
Location
Egypt/Canada
Activity points
2,777
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.
 

dg123

Newbie level 4
Joined
Feb 2, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,312
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.
 

noman4ever

Newbie level 5
Joined
Sep 20, 2008
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,366
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????
 

microKernel

Full Member level 3
Joined
Jul 15, 2005
Messages
171
Helped
34
Reputation
68
Reaction score
12
Trophy points
1,298
Location
NE
Activity points
2,307
Re: using a joystick with matlab

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

philoman

Junior Member level 1
Joined
May 9, 2009
Messages
18
Helped
3
Reputation
6
Reaction score
0
Trophy points
1,281
Activity points
1,368
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

Top