LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication with RS232

I start new with Labview and Iwould to make communication with serial port but the problem it is I can't stop it on writing and reading, this communication it is with microcontroller and I want to force the serial when I want to read or to write if anyone can help me
Thank you
0 Kudos
Message 1 of 9
(8,562 Views)
LabWindows CVI includes two samples projects for serial communication. Look at serial.prj and comcallback.prj in ...\CVI\samples\rs232
0 Kudos
Message 2 of 9
(8,545 Views)
Thank you for your help but my problem I am working in labview and I don't have any Idea hoe I can link labwindows with lab view.
0 Kudos
Message 3 of 9
(8,541 Views)
Sorry: you posted this queation to the LabWindows group, so that's how I answered.
LabView also includes serial port examples. You don't need CVI to do serial if the rest of your program is in LabView.
If you do need to link CVI code and LabView, create a DLL in one and call the DLL functions in the other (but you don't need to do that unless there's more to it than just running RS232).
0 Kudos
Message 4 of 9
(8,536 Views)
Hello Zamjir,

AI S is absolutely correct. There are several RS232 examples for LabVIEW in the NI Example Finder. In order to open the examples, follow these steps:
1) Select "Help>>Find Examples..." from the menu bar in either the front panel window or block diagram window of a VI to open the NI Example Finder.
2) In the NI Example Finder, select the Search tab and type in "serial" for your keyword.
3) Double-click on "serial" in the box labeled "Double-click keyword(s)".
4) A list of examples should appear.

I recommend that you take a look at "Basic Serial Write and Read.vi" or "Advanced Serial Write and Read.vi".

I hope this helps.

E.Lee
Applications Engineer
National Instruments
Eric
DE For Life!
0 Kudos
Message 5 of 9
(8,517 Views)
HI E.LEE
thank you about your help, I looked on the serial communcation examples, also I made serial connection read /write just I need to force this to read or to write when I want to do that?

Thank you
Zamjir
0 Kudos
Message 6 of 9
(8,494 Views)
Hello Zamjir,

You are absolutuley correct. If you want to do a serial read from the com port, then make sure you have the "read" control turned on. If you want to do a serial write to the com port, then make sure you have the "write" control turned on. If you want to do a write followed immediately by a read, then turn both controls on.

Take care,
E.Lee
Applications Engineer
National Instruments
Eric
DE For Life!
0 Kudos
Message 7 of 9
(8,471 Views)
Hi:

I try to use the RS232C port to remotely to initializing and download data from a meter. I have no problem to send in command for initialize and the meter sent back the correct response in ASCII. However when I try to send in command to read the clock, the meter return back with some strange character instead of the BCD format as it should be. I wonder is there anyway I can translated ther result into proper format.

The method I use to receive the response from the meter is the same as the sample program
"serial.prj":
bytes_read = ComRdTerm (comport, read_data, read_cnt,read_term)

when I use the stepinto function to debug, the "read_data" that supposed content the data ( in BCD format) give response as "44||||49".

Q1. Can you give me some hint/example to solve the above problem?

Q2. Accorinding to the paramater for the COmRdTerm, read_data should be declare as char, How should I declare the read_data if I want to receive response in some other format e.g. Hex or integer?

Looking forward to your prompt reply. Thank You

Vicky Lai
0 Kudos
Message 8 of 9
(8,315 Views)
Hi Vicky,

You will have to define this variable as a char initially, because the VISA functions which are called can only input and output ASCII character data. Once this data is in the CVI environment, however, you can transfer it to other data types if you would like. Some functions that have this capability are in the ANSI C library, under General Utilities and String to Arithmetic Expression.

Also, you may have better success getting your questions answered more quickly by starting a new thread rather than adding to a post that has already been resolved. I almost didn't see your addition to this post at the bottom, and others may have had the same problem.

Have a great day!

john
0 Kudos
Message 9 of 9
(8,235 Views)