This is a part of the code we are making. At function psdb an error occurs when we try to execute it. The program call a form which the user gives the parameters for the filter measurment in pass band and after that the procedures which called are the setup to preset the machine and follows the psdb with the proper parameters. In that procedure and when we try to read the bandwidth we receive an error which inform that the target value not found or we have an real time error. Has anyone any idea why that could happened?

We try it with a filter on the machine and without. In both cases we receive the same error.

Thanks for your time.

Here is the code

Public Sub setup()

Dim i As Integer

SCPI.System.PRESet

SCPI.INITiate(1).CONTinuous = True

SCPI.TRIGger.SEQuence.Source = "bus"

SCPI.CALCulate(1).PARameter(1).DEFine = "S21"

SCPI.CALCulate(1).Selected.Format = "MLOG"

SCPI.CALCulate(1).PARameter(1).Select 'activate trace 1

SCPI.SENSe(1).SWEep.Points = 401

SCPI.SENSe(1).BANDwidth.RESolution = 1000

SCPI.Source(1).POWer.Level.IMMediate.AMPLitude = -10

SCPI.CALCulate(1).PARameter.Count = 1 'number or traces

'refernece for marker at 10db

End Sub

Public Sub pslimit(center, span, ripple, il, limit As Double) 'segments

Dim x, upper, lower, center1 As Double

center1 = center

SCPI.SENSe(1).Frequency.center = center

SCPI.SENSe(1).Frequency.span = span

SCPI.DISPlay.WINDow(1).TRACe(1).Y.Scale.PDIVision = 1 'change to pdivision etc

SCPI.CALCulate(1).Selected.MARKer(1).STATe = True

SCPI.CALCulate(1).Selected.MARKer(1).Function.Type = "Maximum"

SCPI.CALCulate(1).Selected.MARKer(1).Function.Execute

Mkrval = SCPI.CALCulate(1).Selected.MARKer(1).Y 'insertion loss relative to maximum

center = SCPI.CALCulate(1).Selected.MARKer(1).x 'center = insertion loss point (frequency)

SCPI.CALCulate(1).Selected.MARKer.REFerence.STATe = True 'REFERENCE MARKER

SCPI.CALCulate(1).Selected.MARKer(1).Function.Target = -limit

SCPI.CALCulate(1).Selected.MARKer(1).Function.Type = "LTARget"

SCPI.CALCulate(1).Selected.MARKer(1).Function.Execute

low = SCPI.CALCulate(1).Selected.MARKer(1).x

SCPI.CALCulate(1).Selected.MARKer(1).Function.Target = -limit

SCPI.CALCulate(1).Selected.MARKer(1).Function.Type = "RTARget"

SCPI.CALCulate(1).Selected.MARKer(1).Function.Execute

upper = SCPI.CALCulate(1).Selected.MARKer(1).x

'ECHO "##Measurement Result##"

'ECHO "insertion loss " & mrkval

'ECHO "upper " & upper - center

'ECHO "lower " & center - lower

'ECHO "center max " & center

'ECHO "real center " & center1

'SCPI.display.Table.Type = "ECHO"

'SCPI.display.Table.State = True

End Sub

Public Function psdb(center, span, il, ripple, choise, ByVal band As Double) As Double 'auto, -x db

Dim cent, qfac, loss, cutlow, cuthigh As Double

Dim Mkrval, BwData As Variant

SCPI.SENSe(1).Frequency.center = center

SCPI.SENSe(1).Frequency.span = span

SCPI.DISPlay.WINDow(1).TRACe(1).Y.Scale.PDIVision = 1 'change to pdivision etc

SCPI.CALCulate(1).Selected.MARKer(1).STATe = True

'SCPI.CALCulate(1).SELected.MARKer(1).x = center

Mkrval = SCPI.CALCulate(1).Selected.MARKer(1).Y

If choice = 0 Then

SCPI.CALCulate(1).Selected.MARKer(1).BWIDth.THReshold = -3

Else

SCPI.CALCulate(1).Selected.MARKer(1).BWIDth.THReshold = -band

End If

SCPI.CALCulate(1).Selected.MARKer(1).BWIDth.STATe = True

SCPI.CALCulate(1).PARameter(1).Select

BwData = SCPI.CALCulate(1).Selected.MARKer(1).BWIDth.Data

'BwData = SCPI.CALCulate(1).Selected.MARKer(1).BWIDth.Data 'error occurs why?

bw = BwData(0)

cent = BwData(1)

qfac = BwData(2)

loss = BwData(3)

cutlow = cent - bw / 2

cuthigh = cent + bw / 2

ECHO "##Measurement Result##"

ECHO "bandwith " & bw

ECHO "Center " & cent

ECHO "Loss" & loss

ECHO "lower center " & cutlow

ECHO "high center " & cuthigh

SCPI.DISPlay.Table.Type = "ECHO"

SCPI.DISPlay.Table.STATe = True

End Function

We try it with a filter on the machine and without. In both cases we receive the same error.

Thanks for your time.

Here is the code

Public Sub setup()

Dim i As Integer

SCPI.System.PRESet

SCPI.INITiate(1).CONTinuous = True

SCPI.TRIGger.SEQuence.Source = "bus"

SCPI.CALCulate(1).PARameter(1).DEFine = "S21"

SCPI.CALCulate(1).Selected.Format = "MLOG"

SCPI.CALCulate(1).PARameter(1).Select 'activate trace 1

SCPI.SENSe(1).SWEep.Points = 401

SCPI.SENSe(1).BANDwidth.RESolution = 1000

SCPI.Source(1).POWer.Level.IMMediate.AMPLitude = -10

SCPI.CALCulate(1).PARameter.Count = 1 'number or traces

'refernece for marker at 10db

End Sub

Public Sub pslimit(center, span, ripple, il, limit As Double) 'segments

Dim x, upper, lower, center1 As Double

center1 = center

SCPI.SENSe(1).Frequency.center = center

SCPI.SENSe(1).Frequency.span = span

SCPI.DISPlay.WINDow(1).TRACe(1).Y.Scale.PDIVision = 1 'change to pdivision etc

SCPI.CALCulate(1).Selected.MARKer(1).STATe = True

SCPI.CALCulate(1).Selected.MARKer(1).Function.Type = "Maximum"

SCPI.CALCulate(1).Selected.MARKer(1).Function.Execute

Mkrval = SCPI.CALCulate(1).Selected.MARKer(1).Y 'insertion loss relative to maximum

center = SCPI.CALCulate(1).Selected.MARKer(1).x 'center = insertion loss point (frequency)

SCPI.CALCulate(1).Selected.MARKer.REFerence.STATe = True 'REFERENCE MARKER

SCPI.CALCulate(1).Selected.MARKer(1).Function.Target = -limit

SCPI.CALCulate(1).Selected.MARKer(1).Function.Type = "LTARget"

SCPI.CALCulate(1).Selected.MARKer(1).Function.Execute

low = SCPI.CALCulate(1).Selected.MARKer(1).x

SCPI.CALCulate(1).Selected.MARKer(1).Function.Target = -limit

SCPI.CALCulate(1).Selected.MARKer(1).Function.Type = "RTARget"

SCPI.CALCulate(1).Selected.MARKer(1).Function.Execute

upper = SCPI.CALCulate(1).Selected.MARKer(1).x

'ECHO "##Measurement Result##"

'ECHO "insertion loss " & mrkval

'ECHO "upper " & upper - center

'ECHO "lower " & center - lower

'ECHO "center max " & center

'ECHO "real center " & center1

'SCPI.display.Table.Type = "ECHO"

'SCPI.display.Table.State = True

End Sub

Public Function psdb(center, span, il, ripple, choise, ByVal band As Double) As Double 'auto, -x db

Dim cent, qfac, loss, cutlow, cuthigh As Double

Dim Mkrval, BwData As Variant

SCPI.SENSe(1).Frequency.center = center

SCPI.SENSe(1).Frequency.span = span

SCPI.DISPlay.WINDow(1).TRACe(1).Y.Scale.PDIVision = 1 'change to pdivision etc

SCPI.CALCulate(1).Selected.MARKer(1).STATe = True

'SCPI.CALCulate(1).SELected.MARKer(1).x = center

Mkrval = SCPI.CALCulate(1).Selected.MARKer(1).Y

If choice = 0 Then

SCPI.CALCulate(1).Selected.MARKer(1).BWIDth.THReshold = -3

Else

SCPI.CALCulate(1).Selected.MARKer(1).BWIDth.THReshold = -band

End If

SCPI.CALCulate(1).Selected.MARKer(1).BWIDth.STATe = True

SCPI.CALCulate(1).PARameter(1).Select

BwData = SCPI.CALCulate(1).Selected.MARKer(1).BWIDth.Data

'BwData = SCPI.CALCulate(1).Selected.MARKer(1).BWIDth.Data 'error occurs why?

bw = BwData(0)

cent = BwData(1)

qfac = BwData(2)

loss = BwData(3)

cutlow = cent - bw / 2

cuthigh = cent + bw / 2

ECHO "##Measurement Result##"

ECHO "bandwith " & bw

ECHO "Center " & cent

ECHO "Loss" & loss

ECHO "lower center " & cutlow

ECHO "high center " & cuthigh

SCPI.DISPlay.Table.Type = "ECHO"

SCPI.DISPlay.Table.STATe = True

End Function

I did not see code to trigger a measurement, so I will assume that you have that somewhere else in your code.