LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Why i read data use RS232 only can 0.1sec

Hi all:

       I was wondering if anyone can help me. I try to read some data form device through RS232 (only read no write), but I have one question, I use timer to read data and adjust timer to 0.001sec, but I find every time to read data always need about 0.1sec, so whatever I adjust timer to 0.01s or 0.05s or another one less than 0.1s, the real read time also about 0.1sec. I don’t know why, I use ComRdTerm() to read data, have anyone can help me?

0 Kudos
Message 1 of 3
(3,123 Views)

Have you considered proper transmission time? Serial communication is intrinsically *slow* so that for example transmiting one character at 9600 takes approx. 1 msec. That is: depending on communication speed and amount of data transmitted that 0.1sec interval could be "normal".

Second: which time of timer are you using? For such a fast execution I don't reccommend you use a standard CVI timer: use an asyncronous timer instead, which runs in a separate thread and relies on multimedia timers so to give you the maximum performance. Even so, 1 msec pacing can be difficult to maintain.

And last: have you considered using a com callback instead of a timer? InstallComCallback installs a callback which can be configured to be called on a special character (the one you are using as a terminator in ComRdTerm, for instance). You could test if such a solution is more efficient than the timed one. In any case, both com callback and timer callback must be optimized for speed of execution so that they do not miss one event because they are still handling the previous one.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 3
(3,118 Views)

Thanks for your replySmiley Very Happy, I think maybe I will try to use asynchronous Timer and use InstallComCallback() to do that.

0 Kudos
Message 3 of 3
(3,087 Views)