LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

rs232

I want to control hp34401a using rs232.Now,I can command the instrument to start measuring.But, the result can't send back to computer.The number of datas coming back is zero.I use the serial write and read function and don't use visa.please help me with this problem.
0 Kudos
Message 1 of 11
(4,593 Views)
Hi,

Did you try to use *IDN? to ask for the instrument name? The return path is OK if it can send back the instrument name. Are you make sure ":MEAS:RES? DEF, DEF" is a valid command? You can try :READ? to query reading.

Besides, serial port read/write vi are also using VISA if you look at their sorce code.

Bill
0 Kudos
Message 2 of 11
(4,582 Views)
Thank you for your advice.I have tried send "*IDN?" to inquery the instrument's name.But there 's not an answer.what's wrong in it?please help me ,thanks.
0 Kudos
Message 3 of 11
(4,573 Views)
You are not sending a termination character with your writes. This needs to be a CR or LF character (check your manual). I also question why you are trying to write your own driver. LabVIEW has shipped with a 34401 driver for the past several versions at least. On the functions palette, go to Instrument I/O>Instrument Drivers and see if you have an HP34401 palette. If it's not there, download the latest version from here. Even if you don't wnat to use VISA for some reason, you should look at how the NI driver is written and copy the style of it.
0 Kudos
Message 4 of 11
(4,562 Views)
Hi,I have send a termination character with my writes. In the string which write to rs232,I choice '\'code display.At the end of the command,I add "\r\d".
I known there is hp34401a's driver in the web. But I have to write other instrument's driver using rs232, if I can control hp34401a,it will be easy for me to write other's driver.
0 Kudos
Message 5 of 11
(4,537 Views)
Quote: "At the end of the command,I add "\r\d"."

This should be "\r\n", not "\r\d". If this really is the case, maybe the problem lies here?

Hope this helps

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 6 of 11
(4,530 Views)
wo,I make a mistake.In my programme,it is "\r\n".So,it is ok.
0 Kudos
Message 7 of 11
(4,524 Views)
If "*IDN?/n" failed, that means either your instrument did not understand this command or there is no communication at all at the Serial port. Since you can reset and start measurement with the instrument, I think the instrument does not understand this command. For some instruments, "*ID?" is used instead.

About your code, there are several things you can consider:

1. You do not need to use sequence structure for this communication. The data flow will make sure "Write" happens before "Read".

2. Have the "Close Port" at the end of the code, not the beginning.

3.You have a wait between read and write, try increase this value.

4. In your 5th sequence, instead using camparison vis, just increase the timeout value.

5. Put an indicator at the output of the "Bytes At Port" vi see if there is anything coming in at all.

What version of LabVIEW are you using? If you are using version 6.0 and higher, all the serial vis are built on VISA, you can use NI-VISA instead to program the device.

Can you verify that you can read anything back from the instrument? You can try with Hyper Terminal.
0 Kudos
Message 8 of 11
(4,509 Views)
Sorry I missed those termination characters. When you do something like this, you should turn on \ code display and leave it on to avoid confusion by others. First of all, do you have communication with the instrument in Hyperterminal? This will verify that your cable and com port settings are correct. Second, The old serial port drivers were a bit goofy. If you specify port 0, that really meant com1, port 1 was com2, etc. so make sure this is correct. Thirdly, I don't have a manual for the meter so I can't double check the syntax for your measure command. The driver from NI doesn't use this so you might want to double check the command. Lastly, after you do the reset, is the instrument in the correct mode? Could it be in external or internal trigger mode and the measurement is timing out because a trigger is missing? There are the sort of things that I recomend you look at the NI driver. Someone has already worked out these kinds of issues.
0 Kudos
Message 9 of 11
(4,500 Views)
I have tried some ways to control the instrument. Even, I used VB to write the program. But it didn't success. I think there maybe some programes in my command.Or, I don't configure the instrument in the correct mode.Now ,I give you the manual of hp34401a.Please help me. Thanks.
0 Kudos
Message 10 of 11
(4,465 Views)