LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

What efford to write a RS422 Reader in LabWindows/CVI (Beginner)

Hello,
 
as I am completely new to LabWindows and serial programming I wonder how much time I will need to write a simple RS422 Reader (128byte every 5ms) with some basic visualization (Graphs). I know some C so I hope it won´t take me too long.
 
I´d also appreciate if you can give me some "buzzwords" to look into.
 
Thanks & Ciao
 
Kai
0 Kudos
Message 1 of 5
(4,151 Views)

Hi Kai,

If you setup and code your application correctly, that is an half-hour project to read constant number of bytes from a periodic data feed.
Just call the ComRd function (with the port number your data array and packet size (128 in your case) as input) in a loop.
Of course, you have to open the COM port first using OpenComConfig function, where you can specify the communication parameters like baud rate, number of data bits, parity, etc.

Hope this helps.

S. Eren BALCI
IMESTEK
0 Kudos
Message 2 of 5
(4,121 Views)
Hi Kai,

S. Eren BALCI is correct, and here are a few additional starting points:
Serial Communication Overview
Serial Communication Starting Point

Also, this thread has a good discussion on RS232 versus RS485:
Which library functions to use in CVI for rs485 operations?

Regards,
0 Kudos
Message 3 of 5
(4,108 Views)

Thanks to both of you!

I finally had some time for this little project. After using standard COM I played around a little and ended up using the VISA drivers/functions, as i got them working correctly first. I guess some setting issues of my COM port. Anyway, I can reliable read my RS422.

I´d appreciate if somebody could give me hints on the remaining issues:

- To read 128byte every 5ms I got a 5ms timer. The read/display (i just put it in a textbox) is done in the timer callback function. This way my userinterface gets unuseable. (I can´t even click "exit"). Any hints on how to overcome this problem?

- there seems to be a minimum limit to the size of the readbuffer handed to viRead (i used it on two different systems (WinME and WinXP) where the limits were 512byte / 2000byte) I only want to read 128 byte at a time only so i would prefer to keep the buffer small. Any workarounds? I didn´t even find the limit in my documentation.

Ciao

Kai

0 Kudos
Message 4 of 5
(4,017 Views)
At the end of your timer callback function, call ProcessSystemEvents() just before you exit. This will force CVI to service any outstanding events, including clicking on controls, before it will go back to processing the next timer callback. Although this will give you back the user interface responsiveness, it will also potentially delay the timer callback, as you will not be able to rely on it occurring exactly when you expect. You might need to investigate putting the serial data capture part of your software into a separate capture thread and using multi-threading techniques (including CVI thread safe queues) to pass the data for processing into your display thread.
 
JR
0 Kudos
Message 5 of 5
(4,014 Views)