11-18-2010 10:37 AM
I am tring to interface to an old HP 3314A funtion genterator. I am using VB to send and read data to the instrument. I know that I am sending information properly because the instrument responds as expected. However if I to a query command I get nothing but garbage back.
I am totally new to GPIB and I am using the Power Supply/Write sample code to do this. Maybe it is just the read code that is incorrect for the function gerneator?
11-18-2010 01:10 PM
I am able to communicate with the 3314A by using the NI Interactive control.
Actually I have now determined that the problem is that when VB display the message it is imbedded with what I will call "garbage" and get displayed incorrectly. For example:
If I request the current frequency the Generator is set for I get:
|FR 0000001000.HZ||||||||
Where | is a dark bar. I would like it to simply be FR 00000001000.HZ
11-18-2010 02:25 PM
Hi
The bars you're seeing are asii characters. Probably space, tab or carriage return values.
Yuo just need to parse or splir the string to find the frequency
try this if your using VB.NET. if you're using VB6 let me know I'll post that code
Try Dim strFrequency As String = "FR 12345.345HZ" Dim strArray() As String = Nothing Dim Frequency As Double Dim arrSeparators() As Char = {"R", "H"} strArray = strFrequency.Split(arrSeparators) Debug.WriteLine(strArray(0)) 'output F Debug.WriteLine(strArray(1)) ' 12345.34 Frequency = Convert.ToDouble(strArray(1)) Debug.WriteLine("F= " & Frequency.ToString) 'F= 12345.345 Catch ex As Exception Debug.WriteLine(ex.Message) End Try
Hope this helps
Curt
12-08-2010 02:32 PM
Thanks for the reply and slow response. I am using VB6, but I should be able to get the code to work on that.