• 0
HYH

Remote controlling WaveForms

Question

Posted (edited)

I am wondering how remote controlling WaveForms should be done properly if used as part in a larger test sequence environment. I have not been able to locate step by step procedures for that.

I prefer using the script method if possible. Loading a workspace with the approximate setup, then using a script to alter a few parameters in the setup, and finally run that configuration. And then load a new workspace and fine tune it. And so on.

You have introduced the -runscript command line switch so a loaded script can be started. Like this found in another similar topic "API or software interface to Waveforms 2015" :

 

Is it also possible to terminate a running script ( ~ stopping an ongoing hardware operation ) or does loading a new script automatically stop the hardware properly in preparation for loading a new script ( or workspace ).

Is it possible to get information from a running WaveForms operation. Like WaveForms writing status to a file on request. But is such interaction possible. Information could include error status, trigger armed status and similar information.

What I am looking for is what remote control possibilities WaveForms gives me when using it in situations where no human is looking/interacting with the GUI. 

Thanks in advance for creating such an amazing software and ( most importantly ) keep updating it.

HYH

Edited by HYH

Share this post


Link to post
Share on other sites

13 answers to this question

Recommended Posts

  • 0

Hi @HYH,

Welcome to the Digilent Forums!

I moved your thread to a section where more experience AD2 and WaveForms engineers look.

Best regards,

Jon

Share this post


Link to post
Share on other sites
  • 0

Hi @HYH

1. You can use the WaveForms SDK to develop a custom application/script to control the device and process raw data.

2. You can use the Script tool in the WF application with JS code to automate the instrument control, further process, data/measurements data logging.
You may also use the file functions to communicate with parallel running applications Tool.exec Tool.start, FileWrite, FileRead...

3. The runscript is a simple argument for the app to start the Script tool. Related post:

https://forum.digilentinc.com/search/?&q=script&type=forums_topic&nodes=8&search_and_or=and&sortby=relevancy

Share this post


Link to post
Share on other sites
  • 0

To Attila

Thanks for your summary of programming options.

Actually there is another option, the DwfCmd ( for Windows ). It has not been updated since 2015. Is it still compatible with the current software and hardware in your opinion, like for specifying a digital pulse train output, or should the program better be considered as dead and ignored ?

I had hoped that dwf3script's would be editable outside Waveforms, like being able to modify a variable value in a text/hex editor and upload the new content, but outside Waveforms a dwf3script is a binary file. And merely changing a  variable from 5 to 6 changes most of the binary file content so one cannot readily identify the variable's location in the file.

Is there a way to convert a dwf3script file to text file and back to binary content outside Waveforms ?

Looking into a dwf3script file then it has a "config.ini" section. Is that something strictly internal or can I as user use it for configuring something ?

Regards

HYH

 

 

Share this post


Link to post
Share on other sites
  • 0

Hi @HYH,

@attila will be better suited to answer this more fully, but my understanding is that the DwfCmd is still compatible with the current WaveForms, based on this thread from earlier this year. I don't know the answers on editing of the script file or the config.ini though.

Thanks,
JColvin

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

Hi @HYH

The projects/worspaces are compressed with zlib. These are not intended to be edited by the users.

The latest beta version adds open/save script text file in the File menu, as well "-script example.txt" app argument.
https://forum.digilentinc.com/topic/8908-waveforms-beta-download/

Also adds extract/compress option in case someone needs out of order tasks, like to extract the raw capture files from a project.

image.png.2c29c1eb0c756703631bd3ae5023dab4.png

 

Edited by attila

Share this post


Link to post
Share on other sites
  • 0

To Attila

Amazing feature, Extract/Compress workspace !

Actually my hacking into the compressed project/workspace file was merely a somewhat desperate way to be able to modify parameters. Not nice.

But the new option you just provided to save all parameters within the compressed file as a text file and then re-import it back into a compressed file is just brilliant. I don't understand what goes on, but it worked fine just compressing the involved config.ini file. Please make this an official feature as it will be -almost- perfect for use in an automated setup environment.

However in order to be perfect then an additional feature is needed. Compressing the config.ini file ( and whatever other needed folders and files ) should be available as a stand-alone utility in some form. Why ? :

I can imagine a simple application for this. A programmable ( PWM ) pattern generator say to control some lights, intensity and length. One needs to change a handful of parameters in the pattern instrument to do this. Being able to modify the light parameters outside of WaveForms by editing a generic pattern config.ini file and then upload ( by -runscript ) the workspace to WaveForms would be the use scenario. WaveForms acts as the controller/server for this virtual light instrument.

The utility is of course necessary because the workspace file is compressed as you mentioned. 

- - -

As I am new to WaveForms and the Digilent instrument world, then I have tried to get an overview of the programming options.

Taking the mentioned light control application as an example :

- I now understand that DwfCmd is unsuitable for the above use as it is basically dead. It doesn't include any options to control a pattern generator. Only analog controls.

- Scripting is also of very limited use as it only include an option to control the repeat parameter.

- So that only leaves the option to generate the pattern generator myself by using the SDK. And then you don't have the ( WaveForms ) GUI, if you wanted to use that.

- BUT, out of the blue, you just added the missing link introducing Extract/Compress workspace !

Regards

HYH

Share this post


Link to post
Share on other sites
  • 0

Hi @HYH

The easiest way to automate things is using the WF app and the Script tool.
In the interface you can easily configure and test the setup, use a bit of JS code to modify/automate what needed. You can also use the File IO and exec/start commands to communicate with external apps.

image.png.475cabee5c242b1c2aa68701be878224.png

The project/workspace is compressed similar to this: http://3adly.blogspot.com/2011/06/qt-folder-compression.html

Share this post


Link to post
Share on other sites
  • 0

To Attila

Thanks for the quick answer.

However I cannot generate a universal programmable PWM pattern generator using the script language. The first immediate problem is that it does not support setting the desired parameters. A example :

To make a basic PWM generator, one ( as a minimum ) needs to control the following five parameters, listed in the splendid "config.ini" format :

patterns0.run=100 us
patterns0.repeat="4 "
patterns0.channels.0.divider="1 "
patterns0.channels.0.low="400 "
patterns0.channels.0.high="2.1k "

Assume I will want to be able to choose/vary them all in arbitrary ( meaningful ) but unknown combinations then I would have to prepare 1000's of script files. Silly and unrealistic of course.

But using the "config.ini" format then it is simply to program ( using Python or LabVIEW or simular ) whatever relevant combinations of the parameters into a new config.ini file that once compressed/converted to a workspace file can be send to WaveForms using the "-runscript" command line option.

Playing with pattern0.repeat worked fine in my first tests. So the concept works.

The only problem remaining is then that I cannot generate the workspace file itself outside of WaveForms. So that is what I look forward to be implemented too in some way.

A simple command line switch for WaveForms to load the text file(s) and save/generate the workspace file would also do the trick.

- - -

According to the manual then scripting supports the following pattern options. Only Repeat is available :

 Patterns#    
  .States    
   .Trigger.text    
   .Wait.value    
   .Run.value    
   .Repeat.value    
   .RepeatTrigger.checked    
  .Preview.text    Sets or gets the preview mode: Manual, Auto.
  .Channels    
   .channel    Sets or gets the channel like: DIO1, Bus1, SPI1.
    .name    Sets or gets the channel name.
    .data    Gets the preview data array.
    .custom    Sets or gets the custom value array.
    .customz    Sets or gets the custom high impedance data array for TS output.
   .DIO#    
    .DIO.value    Sets or gets the digital I/O pin index.
   .Bus#    
    .Format.text    
    .Endianness.text    
    .MSB.text    
    .LSB.text    
    .Pin#    
     .DIO.value    Sets or gets the digital I/O pin index.

- - -

I could not make the text file in/out work in the latest beta. The program simply ignores a text file. But then again I don't know what should be in the file :

The latest beta version adds open/save script text file in the File menu, as well "-script example.txt" app argument.

Do you have any example(s) showing how it works ?

The text file option for scripting is not the solution for my application mentioned above, but it would certainly be handy for other applications.

Regards

HYH

 

Share this post


Link to post
Share on other sites
  • 0

Hi @HYH

You can do this with script, like reading parameters from an external file:

image.png.1600b57e48250c831e30e5494b9a69c8.png

 

The script argument should work like this.

>"C:\Program Files (x86)\Digilent\WaveForms3\WaveForms.exe" -script default.js

This opens the WF app, loads and runs the script or the opened WF app runs the give script.

image.png.85ab0a3f8631def720211374749a3d77.png

Share this post


Link to post
Share on other sites
  • 0

To Attila

You are a true magician. Whenever there seems to be a dead end, you have a way out. That is impressing.

But it leaves me a little in envy. Because you draw on ressources I don't have. Example :

Where did you find the syntax for these properties :

image.png.525c3bdc7f4449be822df61e2cbdb832.png

Being able to write  Channels.DIO0.Divider.text  is not documented anywhere. Can you provide a link to where I can read about that ?

- - -

Looking at the apparently legal syntax shown above, then the format looks a lot like what I can see in the config.ini file ( example shown below ) where one can find 100+ properties for the Pattern instrument.

Assuming there is no updated scripting documentation available, is it then adviceable to assume that scripting supports the same properties as can be found in config.ini ?

Assume I want to program the divider.

Looking into Config.ini then it shows : patterns0.channels.0.divider="1 ".
Looking into your listing then scripting it should correspond to this : Patterns.Channels.DIO0.Divider.text = "1 ". Hardcoded.

I can recognize the translation pattern, allowing me to use config.ini to guess what the scripting command should be. Right ?

Regards

HYH

- - -

Patterns example listing from a config.ini file for a project : 

patterns0.update=500 ms
patterns0.trigger=None
patterns0.wait=none
patterns0.run=100 us
patterns0.repeat="4 "
patterns0.condition=Rising
patterns0.repeattrigger=on
patterns0.autorun=off
patterns0.time.samples=Default
patterns0.time.base.rangemode=Division
patterns0.time.base=50 us/div
patterns0.time.position.divmode=off
patterns0.time.position=0 s
patterns0.time.type=Pulse
patterns0.time.output=PP
patterns0.time.initial=0
patterns0.time.direction=Up
patterns0.time.low="1 "
patterns0.time.high="1 "
patterns0.time.start="1 "
patterns0.time.length="100 "
patterns0.time=on
patterns0.scale=Manual
patterns0.channels.count=1
patterns0.channels.0.mode=1
patterns0.channels.0.name=DIO 0
patterns0.channels.0.color=#000000
patterns0.channels.0.icolor=8
patterns0.channels.0.pin=DIO 0
patterns0.channels.0.output=PP
patterns0.channels.0.idle=Initial
patterns0.channels.0.type=Pulse
patterns0.channels.0.constant.check=on
patterns0.channels.0.constant=0
patterns0.channels.0.frequency.check=on
patterns0.channels.0.frequency.min=100 mHz
patterns0.channels.0.frequency.max=100 MHz
patterns0.channels.0.frequency=1 kHz
patterns0.channels.0.duty.check=on
patterns0.channels.0.duty.min=0 %
patterns0.channels.0.duty.max=100 %
patterns0.channels.0.duty=50 %
patterns0.channels.0.Phase.check=on
patterns0.channels.0.Phase.min=0 \xb0
patterns0.channels.0.Phase.max=360 \xb0
patterns0.channels.0.Phase=0 \xb0
patterns0.channels.0.number.check=on
patterns0.channels.0.number.min="0 "
patterns0.channels.0.number.max="0 "
patterns0.channels.0.number="0 "
patterns0.channels.0.direction.check=on
patterns0.channels.0.direction=Right
patterns0.channels.0.length.check=on
patterns0.channels.0.length.min="0 "
patterns0.channels.0.length.max="0 "
patterns0.channels.0.length="0 "
patterns0.channels.0.dinit.check=on
patterns0.channels.0.dinit.min="0 "
patterns0.channels.0.dinit.max="2.14748365G "
patterns0.channels.0.dinit="0 "
patterns0.channels.0.divider.check=on
patterns0.channels.0.divider.min="1 "
patterns0.channels.0.divider.max="2.14748365G "
patterns0.channels.0.divider="1 "
patterns0.channels.0.start.check=on
patterns0.channels.0.start=Low
patterns0.channels.0.init.check=on
patterns0.channels.0.init.min="0 "
patterns0.channels.0.init.max="32.768k "
patterns0.channels.0.init="0 "
patterns0.channels.0.low.check=on
patterns0.channels.0.low.min="0 "
patterns0.channels.0.low.max="32.768k "
patterns0.channels.0.low="400 "
patterns0.channels.0.high.check=on
patterns0.channels.0.high.min="0 "
patterns0.channels.0.high.max="32.768k "
patterns0.channels.0.high="2.1k "
patterns0.channels.0.samples="1.024k "
patterns0.channels.0.first="0 "
patterns0.channels.0.range="1.024k "
patterns0.channels.chtrigger=-1
patterns0.main.0=1
patterns0.main.1=0
patterns0.main.2=1
patterns0.main.3=1
patterns0.main.4=1
patterns0.main.5=1
patterns0.main.plotcolor=Default
patterns0.main.plotwidth="2 "
patterns0.rowheight.0=24
patterns0.main.column.0.width=39
patterns0.main.column.1.width=80
patterns0.main.column.2.width=39
patterns0.main.column.3.width=40
patterns0.main.column.4.width=39
patterns0.main.column.5.width=48
patterns0.main.column.6.width=0
patterns0.main.column.7.width=71
patterns0.main.column.8.width=100
patterns0.main.column.9.width=100
patterns0.main.column.10.width=100
patterns0.main.column.11.width=481
patterns0.main.labels=0
patterns0.window.geomentry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\0\0\0\0\x15\0\0\x4\x91\0\0\0\xc2\0\0\0\0\0\0\0\x15\0\0\x4\x91\0\0\0\xc2\0\0\0\0\0\0\0\0\a\x80)
patterns0.window.state=@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\0\0\0\x4\x92\0\0\0z\0\0\0\x4\0\0\0\x4\0\0\0\b\0\0\0\b\xfc\0\0\0\x1\0\0\0\x2\0\0\0\x1\0\0\0\xe\0\x43\0o\0n\0t\0r\0o\0l\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0)
patterns0.window.size=@Size(1170 174)
patterns0.window.ismaximized=0

Share this post


Link to post
Share on other sites
  • 0

Hi @HYH

The Script tool provides access to the model behind the app interface. With "text" properties set the text like you type in the combo box fields in interface (1ms), with "value" you can set numeric value (0.001).
Patterns.Channels.DIO0.Divider.text = "1"
Patterns.Channels.DIO0.Divider.value = 1

Not all the parameters are listed in the help, only the ones considered useful.
To see the properties and children of the current node press Ctrl+Space (or enable code completion under View menu).

image.png.cb1898344891e52cabac9ffed2f4ba4e.png

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

To Attila

Thank you so much for the guidance.

The code completion option when doing script programming is the live saver short of a comprehensive manual.

And so I guess I has arrived at my goal stated in the first thread entry.

Your last example showing how to inject new values to scripted parameters from a "live" file deserves some general attention. The concept is a very strong feature of WaveForms allowing it to act as a server for the hardware in an unattended setup.

( The deleteFile should however be moved to after reading the file content. ) 

- - -

I have only a single suggestion left :

Having tool-tip's available as an option would be a great help for a newcomer ( like me ) to WaveForms.

And if an items information shown in the tool-tip could include how it could be scripted then that would be helpful too. Especially as the scripting manual doesn't seem to be kept up to date. Example :

Assume hovering over the Condition control in Scope. Displaying its scripting identity as something like ScopeN.Trigger.Condition would be a great introduction to scripting.

Regards

HYH

Edited by HYH
Adding arguments to the tool-tip suggestion

Share this post


Link to post
Share on other sites
  • 0

Hi @HYH

Yes, you are right, the deleteFile should be after the readArray...

Thank you for the tooltip idea.

Share this post


Link to post
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