Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

rs232 speed

Hi,
 
I have a home-made RS232 device, and I want to fetch data from it as fast as possible. When I use Tera Term, I get 30 data pts/second. But when I use my cvi program, send a command, and then read it, the speed is about 1pt/second.
 
The problem is that when I send a command out, I need to wait for a while to read the response, otherwise, the Input Queue is empty or not complete return from the device. I also try put the reading into another thread, the delay between readable and send-out is still long... (~0.4s).
 
Any good suggestion?
 
Thanks
ToooooooooopHiiiiiiiiiiiiiiiiint
0 Kudos
Message 1 of 7
(4,916 Views)
TopHint,

not knowing anything about Tera Term, I can say for sure that your problem can just be solved by improved communication with your device. If, as you say, it has a processing time of about 0.4 s, that you're limited to about 2.n transactions per second. You might try (if the device supports that) to ask for the next data point while before the preceding data point was deliverred. Finally this is a kind of duplex comm.  This is what I suspect Tera Term is doing.

Just my Euro 0.02!
Greetings from Germany!<br>-- <br>Uwe
0 Kudos
Message 2 of 7
(4,888 Views)

Hi, Lul,

Thank you for your reply.

TeraTerm is similar to windows HyperTerminal. I tried both program, they are faster in terms of response.

In my case, I use one thread to send out command, and install a ComCallback in another thread. So I think the send and receive are seperated. It works fine when I set slower update rate on my hardware (even that, it only gets 10pts/s). If I set my hardware to higher update rate, the read/write response slows down. But 'TeraTerm' and HyperTerminal are not affected.

This make me think if LabWindow/CVI rs232 library has some speed limit? My CVI version is 6.0. Will higher version be faster?

Thank you in advance!

 
ToooooooooopHiiiiiiiiiiiiiiiiint
0 Kudos
Message 3 of 7
(4,877 Views)
I haven't used RS232 communication in CVI in a long while. I do all of that in LabVIEW now and I don't see any diffreence between using VISA in LabVIEW or Hyperterminal/TerraTerm/ProComm. It would help if you could post your code here or in the CvI forum.
0 Kudos
Message 4 of 7
(4,869 Views)
Hi, All, Here is part of the code:
 
// Call this function in startup
int CVICALLBACK ThreadFunction (void *functionData)
{
 FlushInQ (comport);
 FlushOutQ (comport);
 
 InstallComCallback (comport, LWRS_RXFLAG|LWRS_BREAK, 1, '>', ComCallback, NULL);
   
    while (QuitFlag == 0) {
  ProcessSystemEvents ();
  Delay(0.01);
 }
    QuitFlag=0;
 return 0;
}

 

/* Callback Function */
void ComCallback(int portNo, int eventMask, void *data)
{
 if(inComCallback) return;
 inComCallback=1;
    inqlen = GetInQLen (portNo);
    if(inqlen>0) ReadRS232Data();
    inComCallback=0;
    WaitFlag=0;
}

 
void ReadRS232Data(void)
{
 char *ptr;
 LineEnded=0;
 FillBytes(read_data,0,2000,0);
 inqlen = GetInQLen (comport);
 if(inqlen>0)
     {
        GetCtrlIndex (panel_handle, SERIAL_READTERM, &read_term_index);
        switch (read_term_index)
            {
            case 0:
                read_term = 0;
                break;
            case 1:
                read_term = 13;
                break;
            case 2:
                read_term = 10;
                break;
            }
        read_cnt = inqlen;
        if (read_term)
            bytes_read = ComRdTerm (comport, read_data, read_cnt,read_term);
        else
            bytes_read = ComRd (comport, read_data, read_cnt);
        if(!DisableShowText)
         {
         CopyString (tbox_read_data, 0, read_data, 0, bytes_read);
            SetCtrlVal (panel_handle, SERIAL_TBOX_READ, tbox_read_data);
            }
  FlushInQ (comport);
  ptr = strstr(read_data,">");
  if(ptr!=NULL) LineEnded=1;
        }
    else
     {
     }
       
    RS232Error = ReturnRS232Err ();
    if (RS232Error)
        DisplayRS232Error ();
}
ToooooooooopHiiiiiiiiiiiiiiiiint
0 Kudos
Message 5 of 7
(4,863 Views)

can function InstallComCallback be used for checking number of bytes in output queue ?

 

br

milan.

0 Kudos
Message 6 of 7
(4,228 Views)
STOP posting the same question so many times and to so many boards. It does not help.
0 Kudos
Message 7 of 7
(4,226 Views)