Author Topic: Modified Behavior of Remote.RemoteGetCountStatus for 8230/8530  (Read 4181 times)

Probeman

  • Emeritus
  • *****
  • Posts: 2839
  • Never sleeps...
    • John Donovan
Modified Behavior of Remote.RemoteGetCountStatus for 8230/8530
« on: September 28, 2016, 01:44:42 PM »
All,
I had to make a small mod of the RemoteGetCountStatus call to deal with an issue on JEOL 8230/8530 instruments.

An example of calling the spectrometer counting functions are shown here:

Code: [Select]
Sub TestRemoteCountTest()
' Performs a counter test using the remote counter interface

ierror = False
On Error GoTo TestRemoteCountTestError

Dim maxtunable As Integer
Dim scaler As Integer
Dim alldone As Boolean

Dim done() As Boolean
Dim counts() As Single

Dim counttime As Single, maxcounts As Long
Dim outputfile As String, astring As String

' Define output file
outputfile$ = App.Path & "\TESTREMOTE.DAT"

' Get number of scalers
maxtunable% = Remote.RemoteNumberofTunableSpecs

' Dimension array for counts
ReDim done(1 To maxtunable%) As Boolean
ReDim counts(1 To maxtunable%) As Single

' Unblank beam
Remote.RemoteFaraday Int(2)

' Start counters
counttime! = 10#
maxcounts& = 100000000
alldone = False
For scaler% = 1 To maxtunable%
Remote.RemoteStartCounts scaler%, counttime!, maxcounts&
Next scaler%

' Wait for counts
Do Until alldone
alldone = True
For scaler% = 1 To maxtunable%
If Not done(scaler%) Then done(scaler%) = Remote.RemoteGetCountStatus(scaler%)
DoEvents
If ierror Then GoTo TestRemoteCountTestCancel
If Not done(scaler%) Then alldone = False
Next scaler%
Loop

' Get counts
astring$ = ""
For scaler% = 1 To maxtunable%
counts!(scaler%) = Remote.RemoteGetCountCount(scaler%)
astring$ = astring$ & Format$(counts!(scaler%)) & vbTab
Next scaler%

FormMAIN.TextGetPHADistributionDistribution.Text = astring$

' Stop counters
Remote.RemoteStopAllCounters

' Blank beam
Remote.RemoteFaraday Int(1)

' Write data to file
Open outputfile$ For Append As #1
Print #1, astring$
Close #1

Exit Sub

' Errors
TestRemoteCountTestError:
MsgBox Error$, vbOKOnly + vbCritical, "TestRemoteCountTest"
ierror = True
Exit Sub

TestRemoteCountTestCancel:
MsgBox "Test canceled", vbOKOnly + vbExclamation, "TestRemoteCountTest"
Remote.RemoteStopAllCounters
ierror = True
Exit Sub

End Sub

Thanks to Dan Ruscitto and Owen Neill for catching this.
john
« Last Edit: September 28, 2016, 02:01:55 PM by Probeman »
The only stupid question is the one not asked!

Ben Buse

  • Professor
  • ****
  • Posts: 488
Re: Modified Behavior of Remote.RemoteGetCountStatus for 8230/8530
« Reply #1 on: October 06, 2016, 05:44:28 AM »
Hi John,

I've just copied the following lines into testdeadtime to get it working.

If Not done(scaler%) Then done(scaler%) = Remote.RemoteGetCountStatus(scaler%)
If Not done(scaler%) Then alldone = False

It works fine once done is defined as an array

I did Dim done(5) as integer.

Thanks

Ben

Ben Buse

  • Professor
  • ****
  • Posts: 488
Re: Modified Behavior of Remote.RemoteGetCountStatus for 8230/8530
« Reply #2 on: October 06, 2016, 05:59:58 AM »
Ops there is a problem it only stores 1st set of counts - looking into it

Ben Buse

  • Professor
  • ****
  • Posts: 488
Re: Modified Behavior of Remote.RemoteGetCountStatus for 8230/8530
« Reply #3 on: October 06, 2016, 06:11:22 AM »
I got it working by assigning 0 to the done array after the counts have been collected

Ben
« Last Edit: October 06, 2016, 07:11:29 AM by Ben Buse »

Probeman

  • Emeritus
  • *****
  • Posts: 2839
  • Never sleeps...
    • John Donovan
Re: Modified Behavior of Remote.RemoteGetCountStatus for 8230/8530
« Reply #4 on: October 06, 2016, 09:27:48 AM »
Hi Ben,
Nice work!

I cleaned up your code a bit (there is no longer support for fixed monochromaters!), and the relevant section is pasted below and the new macro is attached below and can be utilized for both JEOL and Cameca instruments.  The .xls file will be distributed in subsequent releases of Remote.msi (after tonight).

Code: [Select]
' Unblank beam
remote.RemoteFaraday Int(2)

' Start counters
For scaler = 1 To tunablespecs
remote.RemoteStartCounts scaler, counttime!, maxcounts
Next scaler

' Wait for counters (counts returned in cps)
alldone = False
Do Until alldone
alldone = True
For scaler = 1 To tunablespecs
If Not done(scaler) Then done(scaler) = remote.RemoteGetCountStatus(scaler)
DoEvents
If ierror Then GoTo DeadtimeStartCancel
If Not done(scaler) Then alldone = False
Next scaler
Loop

' Get counts
For scaler = 1 To tunablespecs
counts(scaler) = remote.RemoteGetCountCount(scaler)
Next scaler

' Stop counters
remote.RemoteStopAllCounters

For scaler = 1 To tunablespecs
done(scaler) = False
Next scaler

' Blank beam
remote.RemoteFaraday Int(1)

Good to see someone working on these codes!  There is a lot more one can do with the Remote interface for custom app development for EPMA...
The only stupid question is the one not asked!