LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control device with RS-232 commands in labview

I have used labview very little and am trying to write a program to control a laser. I want to be able to give it commands such as shutter open and closed for a given time interval. I also would like to be able to give it other commands however I have no clue what all the RS-232 commans are and how they are implemented.The commands seem like they are simple but what do I input them into or how do I use them?

 

Thanks for any help! If you need me to try and provide more information please say so.

0 Kudos
Message 1 of 26
(4,053 Views)

You should start here: Serial Instrument Control Tutorial. It's unfortunately too brief, but it's a start. There are more articles here.

 

The first thing you should do is to try to communicate with your device using HyperTerminal if you're on Windows, or an equivalent serial communication program. This is so you can rule out and debug cabling issues and serial communication configuration issues.

 

 


@ybur wrote:

I also would like to be able to give it other commands however I have no clue what all the RS-232 commans are and how they are implemented.The commands seem like they are simple but what do I input them into or how do I use them?


Well, we can't really tell you because we don't have the manual or the instrument. You would really need to read the manual to understand how you're supposed to program the device.

 

0 Kudos
Message 2 of 26
(4,047 Views)

You have to get the commands from the vendor/manual. Don't understand your statement 'seem like they are simple'. If you have no clue what the RS-232 commands are, how can you say they are simple? Can't tell you specifically how to use them since I have no way of knowing what they are.

 

There are a couple of example programs for serial communication. Just do a search in the Example Finder. I would recomend that you first use a program such as Hyperterminal to debug the com settings, serial cable, and commands.

 

When you get around to writing the LabVIEW code, do a search of the forums for examples. There are hundreds (maybe thousands) of posts on serial communication. If you have any problems, post back and it's pretty likely that you will need to attach the programming manual if you are really stuck.

0 Kudos
Message 3 of 26
(4,046 Views)

Thanks for the quick response I will get right on your suggestions. I have looked at the manual and well it is not detailed I will look over it again though.

0 Kudos
Message 4 of 26
(4,037 Views)

I just did this for an old instrument -- it was absurdly easy!  Most of what you need (besides the User Manual for your instrument, which will tell you how to send it commands, and how to parse what it sends back to you) are the VIs in the Serial palette (look under Instrument I/O, then Serial).  Use Configure Port to set the baud rate, parity, etc., then use the read and write serial VIs as appropriate.  Note the the suggestion to hook your device up to your PC's serial port and "test it" using Hyperterminal (or any other serial communication program) lets you (a) test that you can communicate with the device (i.e. the cable works, you have the communication properties set correctly, and your PC's port is active), (b) test sending the device commands, and (c) see what sort of data it sends back.  Note a very useful function is "bytes at port" which you can use to tell you if there are data in the buffer for you to read (and how much needs to be read).

 

Bob Schor

0 Kudos
Message 5 of 26
(4,017 Views)

Ok so I know all of the commands that I need and want to use. I am just not sure how to get the program to ask for a string and then send that string to the device. I am tring to use the visa to set the communication port. Is there a better way? I am just a little stuck.

 

Thanks for the help

0 Kudos
Message 6 of 26
(4,001 Views)

So, I tried to use the measurement and automation explorer to control the device. However I give it a command and nothing happens. So either my computer isn't sending the right commands to the device or the device isn't doing anything with it. Any ideas? I was also wondering exactly what is this HyperTerminal?

0 Kudos
Message 7 of 26
(3,993 Views)

Or you have the wrong com settings (baud, parity, etc.). Or you have the wrong serial cable (null modem/straight-through). Or you are sending the correct command but you are not terminating if correctly. Or...

 

There are countless ways that serial communication can go wrong. Where your problem is cannot be diagnosed without a lot more information. I already mentioned that you should attach the manual. You also need to provide the command you are sending in MAX.

 

Hyperterminal is a terminal emulation program that shipped with every version of windows up to Vista. Not sure what is needed to install it on Vista or Win7 but there a lot of programs out there that do the same thing. Some are free. MAX can be used in many cases but there are some where you need something more sophisticated. The other thing is that vendors of serial instruments will normally have a lot of experience with Hyperterminal or one of the other major programs such as Procomm. The vendor can often walk a user through successfully communicating with the instrument. Sometimes, a vendor will provide a utilty program that can be used for control.

0 Kudos
Message 8 of 26
(3,982 Views)

I already checked the baud. The command always returns an error message. Only when trying to read however. The error is...   BFFF0015

 

I am trying to give as much information as I can however, as I have already said. I am not too familiar with this stuff and don't know what information I need to provide. I would attach the manual if I could find one online. In MAX I am tring to do the command *idn? that is all...it doesn't work.

 

Is it really called Hyperterminal on the computer? I have terminal but I have a feeling that is not what you are referring to. I only have XP so I should have it according to your description. Do you know where it is located on the computer?

 

I have tried to contact the vendor about a program and they are still getting back to me.

0 Kudos
Message 9 of 26
(3,978 Views)

On my XP machine, I click "Start", choose "Programs", then "Accessories", then "Communications", and there is HyperTerminal.

0 Kudos
Message 10 of 26
(3,966 Views)