02-16-2010 10:53 AM
I'm having trouble reading from my device. Can anyone give me an example so I can correct my code?
Solved! Go to Solution.
02-16-2010 11:05 AM
02-16-2010 11:08 AM
Hi,
I don't know what type of instrument you're using, but you probably need to send it a read or measure command, then wait for the command to to be processed and then get the data.
maybe something like...
PowerMeter.Write("Read?")
PowerMeter.WaitForCommandComplete
PowerMeter.ReadString(strData)
Try that
Curt
02-18-2010 10:28 AM
Thanks for your help, I have been working with this some more. The device is a Hewlett Packard model 431B microwave power meter. The signal source is the reference (calibration) oscillator which is turned on by “OC1”. At this time the device is in remote-LISTEN. As soon as the PowerMeter.ReadString (PowerLevel) cmd is sent the device switches to TALK but when the MsgBox comes up the power level string is not displayed. I have been through the manual and reviewed the command set. There is no actual “READ” command that I can discover. If I try to send PowerMeter.Write (“READ”) the device thinks it’s the REsolution command and responds accordingly.
I have addressed the device in the Interactive Control mode of the NI488.2 with the ibrd 11 command and the display string is returned perfectly, so that works. I just don’t know what is different.
The PowerMeter.Wait command causes problems. I can’t get the syntax right so I left it out. Please see example.
02-18-2010 11:28 AM
Hi,
You need to send some sort of trigger command to the device to start a measurement and load data into the output buffer so you can then read it.
Try writing one of these commands before you use the ReadString method...
"GET"
"GT1"
"GT2"
or
"TR1"
"TR2"
"TR3"
Hope this helps
Curt
02-18-2010 11:34 AM
02-19-2010 02:33 PM
Hi – I have followed your advice.
The power meter does have trigger commands. TR0 is standby, TR1 is trigger immediate, TR2 is trigger with delay and TR3 is trigger free run. According to the manual when TR1 or TR2 is called a measurement is taken and the display and the HP-IB bus data are updated. When TR3 is called the power meter makes continuous measurements and updates the display until placed back in standby. I placed the trigger command in the line before the PowerMeter.ReadString(PowerLevel) is called and tried each one (including GET) but the string is still not returned in the MsgBox. I also ran a short version through NI-SPY (attached) but am unable to understand why the VB version doesn’t work. Do you have any other suggestions?
02-19-2010 02:46 PM
02-19-2010 03:21 PM
Sorry.
I have the files of course but being new to the forum concept I don't know how to attach them.
Can you tell me how?
02-19-2010 03:34 PM
Hi,
I should have caught this on your first post
Try
Dim strRead as String
strRead = PowerMeter.ReadString()
MessageBox.Show(strRead)
or
MessageBox.Show(PowerMeter.ReadString())
Curt