Forums › SA Series Discussions › SA44B python API
- This topic has 7 replies, 3 voices, and was last updated 2 weeks ago by
Andrew.
- AuthorPosts
galcParticipantHello, I’m trying to automate a procedure we use the SA44B for.
Two steps of the procedure are loading user preset and exporting trace data to a *.csv file for further analysis.
I couldn’t find an option to it outside of Spike program. Is it possible to get the same functionality using Python with the existing API?
If not in Python, I can take an example in other language.Thanks.
RogerModeratorHi Gal,
There are potentially two ways to accomplish this in Python: using Spike’s SCPI interface or with the device API. The SDK contains the needed resources for both, and can be downloaded here.
1. SCPI
Spike can be programmatically controlled with SCPI commands. Presets can be loaded using the following commands, for named and quick presets respectively:
:SYSTem:PRESet[:USER]:LOAD
*RCLThen, an acquisition command such as :TRACe[:DATA]? would be used to get the sweep data, which Python could then output to CSV.
An example to get you started is in the SDK at scpi/Spike/examples/python/scpi_simple_sweep.py. The Spike SCPI Programming Manual is also there as a command reference.
2. API
This is a direct connection to the device that is an alternative to Spike.
The configuration functions would be used to replicate the Spike preset, followed by an acquisition function to get the data, and then output CSV from Python.
An example to get you started is in the SDK at device_apis/sa_series/examples/python/sweep_plot.py. The API documentation is available there and online here.
Let me know if you have further questions.
Roger
galcParticipantThanks Roger.
I am still not sure how to create a function which will load user preset (i.e. ini file) as it is done using Spike.Looking in the ini file content I find a lot of parameters which seem to be not configurable using the API. Say for example configuring the trace type parameter or the average count. Same goes for markers.
I find that the API doesn’t cover a lot of the functionality that Spike features.
I did understand that saving samples to a *.csv can be done using the saGetSweep_32f and saGetSweep_64f functions.
Will appreciate help regarding the issue.
AndrewModeratorThe concept of a preset does not exist in the API, that is only in the Spike software.
Also, you are correct, the API provides just the sweep and I/Q data from the instrument. Any measurements on the data need to be performed in your application.
As Roger noted, the SCPI commands support both loading presets and exporting trace data.
Let us know if you have follow up questions.
galcParticipantThanks Andrew.
Unfortunately, the suggested solution requires me to run Spike at the background and it does not comply with my desire of automating the process.I will think again about using your spectrum analyzer.
If you have some other directions I may try, will be happy to hear.
Thanks again.
AndrewModeratorGalc,
Spike has a “hidden” mode in which you can launch the software and it only appears in the task list. You can read more about this in the manual. If the issue is that the software is visible and you want just your application showing, that might be interesting.
galcParticipantThe hidden feature might be an option for us, we will test it.
Currently I am trying to test the commands with the demo device. Is it possible to open the Spike program without being asked if to launch it with demo device? I want to use a subprocess call in Python to open it and then send the hide command.
AndrewModeratorIf Spike is set to hidden mode, that dialog will not appear, but I also believe it will not automatically enter demo mode. There is not a way to automatically enter demo mode. The only way to bypass that dialog into an active state is with 1 Signal Hound device connected.
- AuthorPosts
You must be logged in to reply to this topic.