sergiodorazio
-
Posts
13 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Gallery
Posts posted by sergiodorazio
-
-
Hi,
if I want save some data with script, I use these instructions:
var f = File("data.txt");
f.write("data to save: " + d1);
the file data.txt is save in the waveform installation folder.
I need to set this folder, I need that this folder is the folder where I save ".dwf3work" files. How can I do this ?
By Sergio.
-
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.
-
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.
-
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
-
-
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 ?
-
Hi Attila,
you have inverted my problem : I have a Visual Basic application that do many functions, one of this is THD measure . It isn't possible through 'waveforms SDK' , it is possible through the 'Digilent' application, through 'Digilent' script. I have tested this and it work well. My question is : is it possible lunch 'Digilent' in background mode (or hidden mode) ? You have answer NO.
Have you an other solution for my problem ?
By
Sergio.
-
Yes, but 'THD' measure is possible only with 'spectrum measure' graphical application, in SDK interface there isn't 'THD' measure. I think that I need long time to develop a algorithm to obtain 'THD' measure from a samples sequence !!
An other possibility is that 'Digilent' send me his 'THD' source code function.
By
Sergio.
-
Hi Attila, OK , now I understand:
If I must run 2 script in 2 different times, I must save 2 workspace with one script for every workspace and I run the 2 script in this way:
script1 : "C:\Program Files (x86)\Digilent\WaveForms3\WaveForms.exe" "C:\Users\T0102950\workspace1.dwf3work -runscript
script2 : "C:\Program Files (x86)\Digilent\WaveForms3\WaveForms.exe" "C:\Users\T0102950\workspace2.dwf3work -runscript
I hop that this help other users !!
For exchange data from script and visual basic I use a file, the script can write a file with these commands:
var f = File("data.txt")
f.write("data write")
I have a last question for you:
- can I run the Waveforms.exe application in background mode (or hidden mode) by a 'cmd' command ?
By
Sergio.
-
Hi Attila,
I have "readCurrent" script, with 'cmd' command:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>"C:\Program Files (x86)\Digilent\WaveForms3\WaveForms.exe" "C:\Users\T0102950\default.dwf3work -readCurrent
The "Waveforms" program start, the workspace start with all function that I want, but the script "readCurrent" not start .
Questions:
- what is the correct command to start script ?
- can I run the application in background mode ?
- have you an example for exchange data from a script and an application visual basic program ?
This is my script:
if(!('Protocol' in this)) throw "Please open a Protocol";
Protocol.SPI.Start();
var average = 0;
var data = 0;
var nAmp;for(var i = 0; i < 100; i++){
Protocol.SPI.Start();
data = (Protocol.SPI.Read0(15,1) & 0x7ff);
Protocol.SPI.Stop();average += data;
print("step", i+1, data)
// wait hands over the execution to other process, returns false when script is stopped
if(!wait(0.02)) throw "Canceled"
}
print("Lettura somma : "+average);
average /= 100;
print("Lettura media : "+average);
average -= 1024;
print("Lettura step : "+average);
//average = average * 40000/2048;
//mAmp = (average * 40000/2048)/0.89;
//mAmp = (2250/89.95)*(average);
//mAmp = 40000*(average - 2048)/89.95;
mAmp = average * 20000 / 4096; //??????????????????
print("Current: "+mAmp+" mA");Regards.
Sergio.
-
Hi Attila,
the command :
"C:\Program Files (x86)\Digilent\WaveForms3>WaveForms.exe "C:/MyWorkSpace.dwf3work" - runscript"
run the application with last configuration but it not run the script
- what is the correct syntax of "cmd" command ?
- how can I close Waveforms application at end of measure (by cmd command) ?
Sergio
pmodisns20 Problem
in Test and Measurement
Posted
Hi,
I am working with Digilent Discovery 2 and PMODISNS20 board for current measure. The system work but sometime (every about 20 time) the VB code read a bad value of current. I send you my VB source code. Can you help me to found the problem or you send me an example code ?
dwf.FDwfDeviceOpen(-1, hdwf)
Threading.Thread.Sleep(20)
dwf.FDwfAnalogIOChannelNodeSet(hdwf, 0, 0, 1.0)
dwf.FDwfAnalogIOChannelNodeSet(hdwf, 0, 1, 3.3)
dwf.FDwfAnalogIOEnableSet(hdwf, 1)
Threading.Thread.Sleep(170)
dwf.FDwfDigitalSpiSelect(hdwf, 0, 1) ' CS DIO-0 high
dwf.FDwfDigitalSpiFrequencySet(hdwf, 20000.0)
dwf.FDwfDigitalSpiClockSet(hdwf, 2)
'dwf.FDwfDigitalSpiDataSet(hdwf, 0, 1) ' 0 DQ0_MOSI_SISO = DIO-1
dwf.FDwfDigitalSpiDataSet(hdwf, 0, 1)
dwf.FDwfDigitalSpiModeSet(hdwf, 1)
dwf.FDwfDigitalSpiOrderSet(hdwf, 1) ' 1 MSB first
Dim bbRx(2) As Byte
Dim bbRx1 As UInteger
Dim corrente As Double = 0
Dim average As Double = 0
Dim somma As Double = 0
' spurius reads
For c = 0 To 5
dwf.FDwfDigitalSpiSelect(hdwf, 0, 0) ' CS DIO-0 low
dwf.FDwfDigitalSpiRead(hdwf, 0, 8, bbRx, 2)
dwf.FDwfDigitalSpiSelect(hdwf, 0, 1) ' CS DIO-0 high
Threading.Thread.Sleep(3)
Next
Threading.Thread.Sleep(30)
For c = 0 To 20
dwf.FDwfDigitalSpiSelect(hdwf, 0, 0) ' CS DIO-0 low
dwf.FDwfDigitalSpiRead(hdwf, 0, 8, bbRx, 2)
dwf.FDwfDigitalSpiSelect(hdwf, 0, 1) ' CS DIO-0 high
bbRx1 = (bbRx(0) * 256 + bbRx(1)) / 2
corrente = (11.117 * (bbRx1 - 2048))
somma = somma + corrente
Next
average = somma / 20
dwf.FDwfDeviceCloseAll()
WriteRichTextBox1(vbCrLf)
WriteRichTextBox1("Current detector average ")
WriteRichTextBox1(average)
WriteRichTextBox1(" mAmp ")
WriteRichTextBox1(vbCrLf)