Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

rs232 communication c++

I would like to write a C++ program to communicate (via rs232) with a temperature oven. I will be using a USB to RS232 adapter. I have never done any serial communication so this is my first trip down this road. I need to setup the serial port on my PC (need the syntax and code) also I need to send commands to the oven and read commands from the oven too.

I'm using the IDE (Code::Blocks) with the GNU GCC Compiler, probably a console application, maybe a Win32 application haven't decided yet. I just need the basics I will try and figure out the rest. Any help in this matter would be great.

What I have read from MANY Google searches is that the serial (rs232) communication is similar to reading and writing to a file. Just need to know how to set everything up.

Thanks any and everyone!!

0 Kudos
Message 1 of 5
(4,618 Views)

Before you get ahead of yourself, I would want to be able to communicate to the instrument manually. In other words, I would fire up Hyperterminal and make sure I can command and retrieve information from the oven.

 

 

If you are using a NI USB to RS232 device which I hope you are, it should include example programs, maybe not for C++ but it should give you an idea.

 

 

0 Kudos
Message 2 of 5
(4,610 Views)

Just out of curiosity, what kind of chamber is it ?   I'm having to do the same thing (C++ via RS-232) with a Thermotron chamber.   I can do it with LabVIEW 8.0.1.   (Couldn't get it to work with LabVIEW 2012, so I reverted, and it worked.)

0 Kudos
Message 3 of 5
(4,392 Views)

Hi,

 

a loopback test can be used to troubleshoot serial communications. 

 

How to Do a Serial Loopback Test

0 Kudos
Message 4 of 5
(4,377 Views)

Try this.   It is code that originated from the CVI Examples.   Currently I have the "IDEN?\r" query in it, but it worked and responded with the various commands and queries that I sent it.   This was originally in LabWindows\CVI 2010, but should function as regular C-Code.   (I'm not 100%, though.)

Download All
0 Kudos
Message 5 of 5
(4,372 Views)