Jump to content

sergiodorazio

Members
  • Posts

    13
  • Joined

  • Last visited

Posts posted by sergiodorazio

  1. 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)

     

     

  2. 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.

  3. 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.

  4. 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 ?

×
×
  • Create New...