Jump to content

Stefan-F

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by Stefan-F

  1. Hi,

    I want to output a complex but periodic pattern (like the PWM signal of a sine wave), with more than 64k samples / period.

    I want to define the data points for a period and output this pattern endlessly.

    I tried to use playback mode, like in DigitalDiscovery_PlayRecord.py, which works fine for a single period.

    But I have not found a way to repeat the pattern.

    I tried setting FDwfDigitalOutRepeatSet() to a value other than one, but the data point address doesn't seem to start over at 0 for each new period, but keeps increasing and outputting random memory contents after the first period.

    Is there an other way to solve this problem?

    Or is it possible to make FDwfDigitalOutRepeatSet() work for values other than one? 

     

    Best regards,

    Stefan

     

     

  2. OK, I found the solution myself:

    Pin DIO31 has the address 7, not 31.

    So the following code does the trick:

    // Pmod DA1 - AD7303
    
    DIO.Set(31-24,1); // <-- DIO31 has address 7
                                 
    for(var i = 0; i < 50 & wait(0.1); i++){
        var va = 128+sin(2*PI*i/50)*127;
        var vb = 128+cos(2*PI*i/50)*127;
        Start();
        Write(16, 0x0100 | (va & 0xFF)); // Update DAC A input register from shift register
    //    Stop();
    //    Start();
        Write(16, 0x2400 | (vb & 0xFF) ); // Load DAC B input register from shift register and update both DAC A and DAC B DAC registers outputs.
        
        Stop();
    
        // output latch pulse:
        DIO.Set(31-24,0); // <-- DIO31 has address 7
    //    wait(0.0001);  // without wait(), pulse with is approx. 0.9 ms
        DIO.Set(31-24,1); // <-- DIO31 has address 7
    
    
    }
    return "done"

     

  3.  

    Hello,

    to load data into a serial DAC, a separate latch pulse is needed at the end of an SPI transfer.

    I tried to achieve this using a Custom SPI protocol and adding control for an extra output pin.

    According to help file:

    Quote

    The Custom mode lets you write communication script with the following functions:

    <snip>
    * DIO.: Lets you set (the ones are not declared as SPI signal) and read the digital pins. 
    DIO.Set(DIO index 0..31, value 0/1/-1) value of -1 disables output, turns to high impedance the respective DIO channel 

    I modified an example script, but adding DIO.Set(31, 1) results in "Data transfer error", and WaveForms has to be restarted to recover from it.

    // Pmod DA1 - AD7303
    
    //    DIO.Set(31,1); // <-- uncommenting this line results in "Data transfer error", need to restart WaveForms to recover
    
    for(var i = 0; i < 50 & wait(0.1); i++){
        var va = 128+sin(2*PI*i/50)*127;
        var vb = 128+cos(2*PI*i/50)*127;
        Start();
        Write(16, 0x0100 | (va & 0xFF)); // Update DAC A input register from shift register
        Stop();
        Start();
        Write(16, 0x2400 | (vb & 0xFF) ); // Load DAC B input register from shift register and update both DAC A and DAC B DAC registers outputs.
        Stop();
        
    //    DIO.Set(31,0); // <-- uncommenting this line results in "Data transfer error", need to restart WaveForms to recover
        wait(0.0001);
    //    DIO.Set(31,1); // <-- uncommenting this line results in "Data transfer error", need to restart WaveForms to recover
    
    }
    return "done"

    Any suggestions to generate the desired signal? Any help is appreciated!

×
×
  • Create New...