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:
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
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
Ops there is a problem it only stores 1st set of counts - looking into it
I got it working by assigning 0 to the done array after the counts have been collected
Ben
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).
' 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...