sergiodorazio Posted July 19, 2021 Share Posted July 19, 2021 Hi , have you a complete example Voltmeter script ? I have window Voltmeter that works well in run mode and it read 3.4 Volt. I need a script that read the voltage value. I run this if(!('Voltmeter' in this)) throw "Please open a Voltmeter"; var vPtt = 0; var media = 0; for(var i = 0; i < 10; i++){ vPtt1 = Voltmeter.Input.Channel1.DC.value; media = media + vPtt; wait(0.1); print("vPtt: "+vPtt+" V"); } media = media / 10; var f = File("data.txt"); f.write(media+" voltPtt"); the value vPtt is always 0 , why ? Have you an example ? Link to comment Share on other sites More sharing options...
0 attila Posted July 19, 2021 Share Posted July 19, 2021 (edited) Hi @sergiodorazio Notice that you place the voltage reading to "vPtt1" and later used "vPtt" The Voltmeter already performs averaging. The DC is calculated based on average of the specified Update rate. If you want to average it further, use wait at least this amount of time, like:wait(Voltmeter.State.Update.value) Edited July 19, 2021 by attila Link to comment Share on other sites More sharing options...
0 sergiodorazio Posted July 20, 2021 Author Share Posted July 20, 2021 big Attila, thank you, the problem is solved. attila 1 Link to comment Share on other sites More sharing options...
0 sergiodorazio Posted July 20, 2021 Author Share Posted July 20, 2021 Hi, I have test better, the script work only if I am running "Voltmeter" otherwise read the last value read and it not update the value. How can I update the read value by script ? Sergio Link to comment Share on other sites More sharing options...
0 attila Posted July 21, 2021 Share Posted July 21, 2021 Hi @sergiodorazio Voltmeter.run() wait(0.1) for(var i = 0; i < 10 && wait(Voltmeter.State.Update.value); i++){ print(Voltmeter.Input.Channel1.DC.value) } Link to comment Share on other sites More sharing options...
0 sergiodorazio Posted July 22, 2021 Author Share Posted July 22, 2021 (edited) Hi Attila, very good. Now it'work. I have an other question : If I have 1 script, from windows command line I can run script by command : "WaveForm.exe myconf.dwf3work -runscript" . How I read in help documentation, If I have 2 script , I use this commands : "WaveForm.exe myconf.dwf3work -script scriptname1" and "WaveForm.exe myconf.dwf3work -script scriptname2" but the script that run is the last script saved in the last configuration and not "scriptname1" or "scriptname2". Can you help me ? Sergio. Edited July 22, 2021 by sergiodorazio Link to comment Share on other sites More sharing options...
0 attila Posted July 22, 2021 Share Posted July 22, 2021 Hi @sergiodorazio The selected script tab will be executed, as the workspace was saved. Save separate workspace with each script. Link to comment Share on other sites More sharing options...
0 sergiodorazio Posted July 22, 2021 Author Share Posted July 22, 2021 Yes, but there is a bug ? The possibility of script selection not work ? For my application is better to have a single configuration with different scripts. Sergio. Link to comment Share on other sites More sharing options...
0 attila Posted July 22, 2021 Share Posted July 22, 2021 (edited) Hi @sergiodorazio At the time when these arguments where added the Script had no tabs, only one script could exist. The next WF version (3.16.31) will support selecting the tab, reusing the script argument to load a file, like: WaveForms mywork.dwf3work -script "tab 2" Edited July 22, 2021 by attila Link to comment Share on other sites More sharing options...
Question
sergiodorazio
Hi , have you a complete example Voltmeter script ?
I have window Voltmeter that works well in run mode and it read 3.4 Volt.
I need a script that read the voltage value. I run this
if(!('Voltmeter' in this)) throw "Please open a Voltmeter";
var vPtt = 0;
var media = 0;
for(var i = 0; i < 10; i++){
vPtt1 = Voltmeter.Input.Channel1.DC.value;
media = media + vPtt;
wait(0.1);
print("vPtt: "+vPtt+" V");
}
media = media / 10;
var f = File("data.txt");
f.write(media+" voltPtt");
the value vPtt is always 0 , why ?
Have you an example ?
Link to comment
Share on other sites
8 answers to this question
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now