Jump to content
  • 0

Start DAQami logging from script


Crouch

Question

Is there a way to start and stop the DAQami logging from a command prompt or other script?  I'm writing a program to get the live data into Excel (I've already got that figured out from the .tdms file); my goal is to have Excel stop the recording when the experiment is complete.  I can send a command line prompt or possibly a keystroke from excel VBA.  Is either a possibility?

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hello @Crouch.

There are no available API function calls for DAQami.  Unless you (or someone in this community) is familiar with a 3rd party software to record mouse clicks and keystrokes, an end-user must launch DAQami, manually select a configuration (.amicfg) file (if one is available), press the Record button, and finally press the Stop button to end the acquisition.

Regards,

Fausto

Link to comment
Share on other sites

  • 0

I found a couple of work-arounds for VBA, using the Shell command: 

To open DAQami, and start recording using the default configuration:

Sub OpenDAQ()
'Opens DAQami using the Shell command
    Shell "C:\Program Files\Measurement Computing\DAQami\DAQami.exe", vbNormalFocus
'Wait 2 seconds after starting
    DoEvents
    Application.Wait Now + TimeValue("00:00:02")
'select the last saved configuration
    SendKeys "{TAB}", True
    SendKeys "{TAB}", True
    SendKeys "{TAB}", True
    SendKeys "{TAB}", True
    SendKeys "{ENTER}", True
'start recording
    Application.Wait Now + TimeValue("00:00:01")
    SendKeys "{TAB}", True
    SendKeys "{TAB}", True
    SendKeys "{TAB}", True
    SendKeys "{TAB}", True
    SendKeys "{ENTER}", True
'shift focus back to Excel
    Application.Wait Now + 0.000005787
    AppActivate "DAQ - Excel"
    Workbooks("DAQ.xlsm").Activate
    Sheets("Report").Activate
'start the subroutine that checks for the DAQ recording status
    Call CheckForDAQRecording
End Sub

To close DAQami, and save the data and configuration:

Sub CloseDAQ()
'Return focus to DAQami
On Error GoTo stepout
    AppActivate ("DAQami - [Configuration: system.amicfg] [Data File: DAQdata.tdms]")
    DoEvents
    Application.Wait Now + TimeValue("00:00:01")
'Request close program
    SendKeys ("%{F4}"), True
    SendKeys ("+{TAB}"), True
'Enter to confirm stop recording
    Application.Wait Now + TimeValue("00:00:01")
    SendKeys "{ENTER}", True
'Enter to save configuration
    Application.Wait Now + TimeValue("00:00:05")
    SendKeys "{ENTER}", True
stepout:
End Sub

To find out if DAQami is recording:

Dim recFDT
recFDT = Dim recFDT
recFDT = FileDateTime("C:\Users\XXXXXX\Documents\Measurement Computing\DAQdata.tdms")

I then subtract NOW() by recFDT and if it's less than 1.5 minutes, I know the data is current.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...