Discussion Forums are temporarily in read only mode. All forums are visible but posting is not possible. Please check back shortly.

Thread: Is it possible to run VB5 code using PC in a PNA


Permlink Replies: 3 - Pages: 1 - Last Post: Jan 25, 2012 7:15 AM Last Post By: Thomas Dylan Threads: [ Previous | Next ]
Thomas Dylan

Posts: 6
Registered: 01/24/12
Is it possible to run VB5 code using PC in a PNA
Posted: Jan 24, 2012 4:14 PM
Click to report abuse...   Click to reply to this thread Reply
We have an old product coming back into production. Testing of this product was done using a program written in VB5 on an external PC with a National Instruments GPIB card connected to an 8510. Is it possible to run VB5 code on the internal PNA's PC? Do I use a USB to GPIB convertor to operate the PNA, using the USB and GPIB port in the back of the PNA? The problem I see is I don't believe VB5 had very good support for USB. I realize I may have to rewrite some of the code but I'm hoping to avoid a complete rewrite.
daras


Posts: 873
Registered: 12/01/05
Re: Is it possible to run VB5 code using PC in a PNA
Posted: Jan 24, 2012 4:39 PM   in response to: Thomas Dylan in response to: Thomas Dylan
Click to report abuse...   Click to reply to this thread Reply
you can, but you have to change all the calls to the NI_VISA libraries, since you cannot install NI VISA on a PNA. it will conflict with the Agilent VISA installation that is already on the PNA. So if you have to change those anyways, then you can use Agilent VISA IO libraries and can actually address the PNA from an internal program using the TCPIP0 interface. for example my PNA's hostname is "a-n5242a-90069" and if I wanted to open a VISA connection to that PNA from a program running inside the PNA, I could use the following address string:

"TCPIP0::a-n5242a-90069::inst0::INSTR" or simply "TCPIP0::a-n5242a-90069"

I could also substitute the IP address for the hostname. this is possible on any PNA that is LXI compliment, which is any PNA shipped or upgraded in 2008 or later. using this approach, you do not have to have any USB-GPIB adapters.
odanzy

Posts: 1,543
Registered: 11/16/05
Re: Is it possible to run VB5 code using PC in a PNA
Posted: Jan 24, 2012 6:06 PM   in response to: Thomas Dylan in response to: Thomas Dylan
Click to report abuse...   Click to reply to this thread Reply
I would recommend posting a section of your code that does the instrument control. It may not require any changes or possibly a few changes.
Thomas Dylan

Posts: 6
Registered: 01/24/12
Re: Is it possible to run VB5 code using PC in a PNA
Posted: Jan 25, 2012 7:15 AM   in response to: Thomas Dylan in response to: Thomas Dylan
Click to report abuse...   Click to reply to this thread Reply
We rewrote this code recently to run a N5230C PNA using an external PC with an NI GPIB card to check it out, it works. We would like to run this software on a E8362B (or similar PNA) PNA's internal PC as a standalone test set. Here is some sample code.

Regards,
Thomas

'*
Public Sub Initialize_NWA()

Const BDINDEX = 0 ' Board Index
Const PRIMARY_ADDR_OF_DEV = 16 ' Primary address of device
Const NO_SECONDARY_ADDR = 0 ' Secondary address of device
Const TIMEOUT = T30s ' T10s was Timeout value = 10 seconds now 30s for 13s sweep
Const EOTMODE = 1 ' Enable the END message
Const EOSMODE = 0 ' Disable the EOS mode

Dev = ildev(BDINDEX, PRIMARY_ADDR_OF_DEV, _
NO_SECONDARY_ADDR, TIMEOUT, EOTMODE, EOSMODE)
If (ibsta And EERR) Then
gFlag_NWA_Connection = False
GpibErr (gGBIB_Startup_Error)
End If

ilclr Dev
If (ibsta And EERR) Then
gFlag_NWA_Connection = False
GpibErr (gGBIB_Startup_Error)
End If

End Sub


'--------------------------------------------------------------
' SSSSSSSSS 1 1
' S 111 111
' S 1 1
' SSSSSSSSS 1 1
' S 1 1
' S 1 1
' SSSSSSSSS 11111 11111
'--------------------------------------------------------------
On Error GoTo Error_S11
'Call Cal state
Dim NWA_Cal_String As String
NWA_Cal_String = "MMEMory:LOAD:CSARchive " + "'" + Sweep_Cal + "';*wai"
Call OUTPUT_NWA(NWA_Cal_String)

Call OUTPUT_NWA("SENSe:FREQuency:STARt?;*wai")
mFStart = (CDbl(Left$(ENTER_NWA(25), 24))) / 1000000000
Call OUTPUT_NWA("SENSe:FREQuency:STOP?;*wai")
mFStop = (CDbl(Left$(ENTER_NWA(25), 24))) / 1000000000
Call OUTPUT_NWA("SENS:SWE:POIN?;*wai")
mNumber_of_Points = CInt(Left$(ENTER_NWA(25), 24))
'Test Cal settings
If mNumber_of_Points <> 401 Then GoTo Error_Number_of_Points

Call OUTPUT_NWA(":CALC:PAR:DEL:ALL")
Call OUTPUT_NWA(":CALC1:PAR:DEF 'CH1_S11_1',S11")
Call OUTPUT_NWA(":DISP:WIND:TRAC:FEED 'CH1_S11_1'")
Call OUTPUT_NWA(":CALC:PAR:SEL 'CH1_S11_1'")

Call OUTPUT_NWA(":CALC:FORMat SWR")
Call OUTPUT_NWA(":DISP:WIND:TRAC:Y:RLEV 1")
Call OUTPUT_NWA(":DISP:WIND:TRAC:Y:RPOS 0")
Call OUTPUT_NWA(":DISP:WIND:TRAC:Y:PDIV .1")

Call OUTPUT_NWA(":INIT:CONT OFF")
Call OUTPUT_NWA(":INIT:IMM;*wai")

Call OUTPUT_NWA(":CALC:DATA? FDATA")
For i = 1 To 401
mS11_Array(i) = Val(ENTER_NWA(20))
Next i

On Error GoTo 0




'Write to NWA
Public Sub OUTPUT_NWA(wrtbuf$)
ilwrt Dev, wrtbuf$, Len(wrtbuf$)
If (ibsta And EERR) Then
GpibErr (gGBIB_Write_Error)
End If
End Sub

'Read NWA
Public Function ENTER_NWA(Number_of_Chars)
Dim rdbuff As String

rdbuff$ = Space$(Number_of_Chars)
ilrd Dev, rdbuff$, Len(rdbuff$)
If (ibsta And EERR) Then
GpibErr ("Error reading from device, NWA may not be connected. Connect NWA then press YES , NO to exit program, CANCEL to use program without NWA. ") 'Msg$ + AddIbsta() + AddIberr() + AddIbcnt() + Chr$(13) + Chr$(13) + "No Nwa Check Connection Press OK I'm quitting!")
End If
ENTER_NWA = rdbuff$

End Function

Public Function Get_NWA_IDN() 'ID the NWA Determine the model of NWA
Dim rdbuf As String
Dim wrtbuf As String

Call Initialize_NWA
wrtbuf$ = "*IDN?"
Call OUTPUT_NWA(wrtbuf$)

If (ibsta And EERR) Then
gFlag_NWA_Connection = False
Exit Function
End If

rdbuf$ = ENTER_NWA(100)

If rdbuf$ > "" Then gFlag_NWA_Connection = True ' If NWA returns words from the *IDN? then there's a connection

If (ibsta And EERR) Then
gFlag_NWA_Connection = False
Exit Function
End If

gIDN$ = Left$(rdbuf$, 27) ''' ibcntl - 1)

'*************
Call Take_NWA_Offline
Get_NWA_IDN = gIDN$

End Function


Point your RSS reader here for a feed of the latest messages in all forums