06-05-2006 10:53 PM
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?
06-05-2006 11:37 PM
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.
06-07-2006 05:21 AM
Thanks for your reply, I think maybe I will try to use asynchronous Timer and use InstallComCallback() to do that.