Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Communication by VISA: what' s wrong ?

Hi, I stll trying to communicate with my multimeter using Labview 8.2 (I'm a beginner of this software). Now I 've got all the settings and I 'm able to receive data with this math code that works perfectly:
 
s = serial('COM4');
s.BaudRate=600;
s.StopBits=2;
s.Timeout=10;
s.Terminator='';
s.DataBits=7;
s.ReadAsyncMode = 'continuous';
get(s,{'BaudRate','DataBits','Parity','StopBits','Terminator'})
fopen(s);
fprintf(s,'D');
s.BytesAvailable
out = fscanf(s)    % es DC -0.000   V
fclose(s);
 
Troubles come when I try to use the "Basic Serial Write and Read.vi". I always get a framing error due probably to the Reading part.
I also tried to make things easier with the following start.vi , (see attachment) much simpler to me. But I still get back the framing error.
Has someone time and wish to see where I'm wrong ? I'm sure someting is wrong in he way I receive data. For istance, I don't know how to tell to Labview that the communication is Asynchronous and continous. Maybe this is the problem but I've got lost in the software help.
Thanks. 
 
0 Kudos
Message 1 of 34
(5,425 Views)
Hi

I guess this is the same problem you posted in another post.
Now I opened your start vi and saw that you was using com4. Is that maybe a usb adapter that happens to have problems?
Also try com1 if you have that.

Another change I made is that I added a flush buffer (that should not make much difference) but also made the enable endchar FALSE.
Furthermore I removed the sequence frame and adde the errorIO as intended in IO.
If an error occurs the error  propagates thhrough the wire, stops the while loop and reports in the error cluster.

I insist that you try other baudrates as wel and try to look with an oscilloscope

succes
greetings from the Netherlands
0 Kudos
Message 2 of 34
(5,394 Views)

Yes, I still trying to go out of this problem.  About the question:

- yes I have an adapter usb-serial that normally works.

- I tried all the baud rates that are possible starting from 75 up to 9600. Always the same framing error.

- unfortunately I haven't any oscilloscope. I' ll to get one from someone but I'm not very expert.

What I don't understand is why with the mat-code and its software can I get easily the connection using the same VISA driver and the same hardware.

thanks for your suggestion.

0 Kudos
Message 3 of 34
(5,387 Views)
If the same hardware works with other software. It definitely is not the hardware but, I still guess that something is done wrong.
Maybe you can start up portmon. search for it on internet. http://www.sysinternals.com

start this portmon before you start your program that communicates with the hardware
then enable logging
than start your working program and look what is logged.

succes


greetings from the Netherlands
0 Kudos
Message 4 of 34
(5,385 Views)
Fully agree. So I did my homework as you suggested. Please find in attachment the reports of portcom: at the beginning, the working comm. ; at the end the other with the start.vi modified by you.
Looking at the initial protocols in my opion something is wrong in the settings of "Replace:0 XonLimit:0 XoffLimit:4096" but how to modify them in Labview ?
Thanks a lot !
Gianmarco
 
0 Kudos
Message 5 of 34
(5,381 Views)
To change the settings for serial handshake Xon/Xoff you can open the configure serial port vi and save it under a new name in your own directory that handles the Velleman multimeter

Then add another property (make the property settings longer) and select Serial settings:Flow control XOn character
Do the same for the XOff character.

In Portmon you can check to display HEX characters. All are "readable" then.
And portmon can export this to a .t.xt file with all info.

But I would also measure the other pins like DTR and CTS if they have the same value (use the dmm) in both programs.

the pinning of the 9 pole connector is:

connection 9 polige sub D connector  (male)             25 polig

            1          DCD    Data Carrier Detect                    8                    to pc

            2          RXD    Receive Data                              3                    to pc

            3          TXD     Transmit Data                             2                    from pc

            4          DTR     Data Terminal Ready                20                   from pc

            5          SG        Signal Ground                             7                    both

            6          DSR     Data Set Ready                           6                    to pc

            7          RTS     Request to Send                         4                    from pc

            8          CTS     Clear to Send                              5                    to pc

            9          RI        Ring Indicator                             22                   to pc


greetings from the Netherlands
0 Kudos
Message 6 of 34
(5,379 Views)

Hi I'm still trying to get back some answers from my Multimeter. After one week of bad trials, I have now groupped some info. Maybe someone already faced this problem before.

This is the sistuation, with Matlab I get the right feedback from the instrument. I used Portmon to monitor the communication.

I tried to reproduce the same settings with Labview but something is still missetted. I used also Portmon for this communication.

 

Both reports are in the two sheets of excell file.

My impression is that the instrument gives a couple of bytes of feedback when connect with Matlab and doesn't do the same with Labview. It seems that this stacks Labview  to start reading. Maybe is flow controll ? But in both cases it is fix to none.

Thanks for answers.

Gianmarco

Download All
0 Kudos
Message 7 of 34
(5,316 Views)
Hi

I'm missing the Configure Serial Port for Velleman multimeter.vi
LabVIEW misteriously opens the original VISA Configure Serial Port (Instr).vi

I was wondering what you changed to get the Xon and Xoff like the other program
greetings from the Netherlands
0 Kudos
Message 8 of 34
(5,310 Views)
0 Kudos
Message 9 of 34
(5,301 Views)
Hi Gianmarco

The config serial port now can fill in the Xon Xoff characters but stiil uses the default characters for those
Changing on the frontpanel of the subvi is not guaranteed to work. Best is to change them to constants on the blockdiagram and make them zero.
I made the default value on the frontpanel equal to zero so now it is and stays zero
I do not believe that the handshake should be Xon/Xoff, I only was wondering why these xon/xoff characters were set to 0 by mathlab

However I saw something else. You are asking for 1024 characters and defined the endchar to zero,
Is really a zero character available in the characters received from the DMM?
Or is there no endchar.

And how about the voltages, maybe DTR or CTS is wrong 


Please set portmon in hex mode (it will display all characters received from that moment in hex) and makes it possible to see all communication.
Now it is impossible to see what protocol in sending is used by matlab.


greetings from the Netherlands
0 Kudos
Message 10 of 34
(5,297 Views)