how to automate this recorded picoscope macro

Post your Java discussions here
Post Reply
sherzaad
Newbie
Posts: 0
Joined: Tue Jun 06, 2017 3:43 pm

how to automate this recorded picoscope macro

Post by sherzaad »

Hi,

I recorded a macro in picoscope to start -> stop -> save file

I can see the following lines of code in the saved macro:

Code: Select all



    False
	 Run.Pressed=False
     File.SaveAs.IO="filepath"
where "filepath" is the path I selected to save the file.

Is there a way to alter the code so that every time the macro is run it saves as a new file (different filename each time), maybe using a timestamp or incrementing counter?

Possible or not?

Gerry
PICO STAFF
PICO STAFF
Posts: 1144
Joined: Mon Aug 11, 2014 11:14 am

Re: how to automate this recorded picoscope macro

Post by Gerry »

Hi sherzaad,

You need to cut and paste each Macro command into the argunent for the PicoScope automation command "picoscope.com /a" written in a batch file, as follows:

@echo off
cls
echo File Name Increment
for /F "tokens=2" %%i in ('date /t') do (
set CurrentDate=%%i
)
set CurrentTime=%time%
set FilePath=%%
set Count="1"
echo..
echo..do some work
echo..
picoscope.com /a Run.Pressed=True
picoscope.com /a Run.Pressed=False
picoscope.com /a File.SaveAs.IO=%FilePath%%CurrentDate%:%CurrentTime%-%Count%.psdata
set /a Count=Count+1
echo Next filename is %CurrentDate%:%CurrentTime%-%Count%.psdata
echo..
echo..do some more work
echo..
picoscope.com /a Run.Pressed=True
picoscope.com /a Run.Pressed=False
picoscope.com /a File.SaveAs.IO=%FilePath%%CurrentDate%:%CurrentTime%-%Count%.psdata
set /a Count=Count+1

echo Next filename is %CurrentDate%:%CurrentTime%-%Count%.psdata

Note that the numeric variable will reset back to '1' when the command shell is exited, and a new command shell opened, because the Count variable is only temporary with local (automatic) scope within the shell. To be able to continue with the file numbering after exiting the command shell you would need to create a variable with 'static' scope. You can do this using an environment variable, but then you would need to keep a parent command shell open to keep the environment variable from being lost, so I prefer to use a ram disk and save the variable to a file on it.

You need to run a command shell as admin (right click on the 'command prompt') and have an instance of PicoScope 6 running in order to use PicoScope automation commands. However, automation commands are limited to some degree, because they were only written for test purposes, so they only cover a small range of features supported by the software, and are not going to be extended. For information on some commands that are available you can use the command:
picoscope.com /a ?
For more functinality than you can get from automation, we have our SDK, see here: https://www.picotech.com/library/oscill ... nt-kit-sdk.

Regards,

Gerry
Gerry
Technical Specialist

sherzaad
Newbie
Posts: 0
Joined: Tue Jun 06, 2017 3:43 pm

Re: how to automate this recorded picoscope macro

Post by sherzaad »

Thanks!

Post Reply