Search the Community

Showing results for tags 'c#'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • News
    • New Users Introduction
    • Announcements
  • Digilent Technical Forums
    • FPGA
    • Digilent Microcontroller Boards
    • Non-Digilent Microcontrollers
    • Add-on Boards
    • Scopes & Instruments and the WaveForms software
    • LabVIEW
    • FRC
    • Other
  • General Discussion
    • Project Vault
    • Learn
    • Suggestions & Feedback
    • Buy, Sell, Trade
    • Sales Questions
    • Off Topic
    • Educators
    • Technical Based Off-Topic Discussions

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL







Found 3 results

  1. Hi all, I am using the Impedance Analyzer board for some measurements. The Waveforms Software has the possibility to do an open/short compensation over the desired frequency range. So far I can do the compensation and I get nice results. For my actual application I am using Visual Studio and C# to write the software with the help of the SDK manual. This works also fine so far. But now I want to do the open/short compensation from there as well. There are some commands in the SDK manual like FDwfAnalogImpedanceCompGet(HDWF hdwf, double *pohmOpenResistance, double *pohmOpenReactance, double *pohmShortResistance, double *pohmShortReactance) that should give out exactly the parameters I need. Apparently, If I do that just after doing an open/short compensation in Waveforms, my program cannot read those parameters. Where are the parameters stored? So far I know I can save Waveforms Projects and recall them in Waveforms to get the compensation function again. How can I access the stored parameters from my Visual Studio C# program? Can I export compensation parameters from Waveforms? Thank you for your help in advance. Lea
  2. Hello Community I am using the Analog discovery 2 controlled by a C# Software. At a certain point of the software, I need to check the length of a detected pulse. Before this, I prepare the digital in component of the device. private const uint BUFFER_SIZE = 4000; private const uint DIGITAL_IN_DIVIDER = 1000; private const uint CLOCK_FREQUENCY = 100000000; public void prepareForPulseDetection( int digitalIoIndex ) { checkDigitalIoIndex( digitalIoIndex ); // sampling frequency = 100 MHz / 1000 = 100 kHz (-> 10 us) dwf.FDwfDigitalInDividerSet( device, DIGITAL_IN_DIVIDER ); // just sample DIO pins 0...7 dwf.FDwfDigitalInSampleFormatSet( device, 8 ); dwf.FDwfDigitalInBufferSizeSet( device, (int)BUFFER_SIZE ); dwf.FDwfDigitalInSampleModeSet( device, dwf.DwfDigitalInSampleModeSimple ); // just one acquisition after trigger dwf.FDwfDigitalInAcquisitionModeSet( device, dwf.acqmodeSingle ); // setting triggersource to digital in detector dwf.FDwfDigitalInTriggerSourceSet( device, dwf.trigsrcDetectorDigitalIn ); // take 50 samples before trigger dwf.FDwfDigitalInTriggerPositionSet( device, (uint)BUFFER_SIZE - 50 ); // disable timeout dwf.FDwfDigitalInTriggerAutoTimeoutSet( device, 0 ); // set trigger to rising edge on DIO pin 0 uint triggeredPin = (uint)0x0001 << digitalIoIndex; // high low rising falling dwf.FDwfDigitalInTriggerSet( device, 0x0000, 0x0000, triggeredPin, 0x0000 ); // enable digital in without reconfiguring dwf.FDwfDigitalInConfigure( device, 0, 1 ); } private void checkDigitalIoIndex( int digitalIoIndex ) { if ( ( digitalIoIndex < 0 ) || ( 7 < digitalIoIndex ) ) throw new ArgumentException( "Digital IO index must be in array [0...7]" ); } /// <returns> pulse time in us </returns> public uint getDetectedPulseLength( int digitalIoIndex ) { checkDigitalIoIndex( digitalIoIndex ); var data = new byte[BUFFER_SIZE]; dwf.FDwfDigitalInStatusData( device, data, (int)BUFFER_SIZE ); var numberOfHighSamples = getNumberOfHighSamples( data, digitalIoIndex ); // 1e6 because of us return var usDuration = (uint)( DIGITAL_IN_DIVIDER * 1e6 / CLOCK_FREQUENCY ); usDuration = (uint)( usDuration * numberOfHighSamples ); // reset device, else it is not possible to // recognize if pulse occured dwf.FDwfDigitalInReset( device ); return usDuration; } private int getNumberOfHighSamples( byte[] data, int digitalIoIndex ) { if ( allZero( data ) ) return 1; // means pulse was shorter than samplerate else { int startingIndex = getStartingIndexOfPulse( data, digitalIoIndex ); int endingIndex = getEndingIndexOfPulse( data, digitalIoIndex ); int difference = ( endingIndex - startingIndex + 1 ); return difference + 3; // plus 3 because analog discovery return is inaccurate } } private bool allZero( byte[] data ) { for ( int i = 0 ; i < data.Length ; ++i ) if ( data[i] != 0 ) return false; return true; } private int getStartingIndexOfPulse( byte[] data, int digitalIoIndex ) { int index = 0; for ( ; index < data.Length ; ++index ) if ( checkBit( data[index], (byte)digitalIoIndex ) ) break; return index; } private int getEndingIndexOfPulse( byte[] data, int digitalIoIndex ) { int index = getStartingIndexOfPulse( data, digitalIoIndex ) + 1; for ( ; index < data.Length ; ++index ) if ( !checkBit( data[index], (byte)digitalIoIndex ) ) break; return --index; } private bool checkBit( byte value, byte checkedBit ) { byte shiftedValue = (byte)( (int)value >> (int)checkedBit ); return ( ( shiftedValue & 0x01 ) == 0x01 ); } The pulses are reliably measured. But the number of high samples is always smaller than expected. Most of the time, I expect the measured pulse three microseconds longer than it is. Is this a known issue? Or is there a mistake in my code? I am very sure, that the pulses I am sending to the analog discovery are as long as they should be. I checked it with the analog discovery with the waveforms software and with another osciloscope.
  3. This is a little DLL I wrote using C++ Interop in Visual Studio to pull some of the functions from the Adept SDK into C#. I'm posting it here in the hopes this is useful to someone else. It's pretty rough as I am absolutely not a Windows developer and I make no guarantees as to how well it is written and/or works (it does do what I need it to do ). Only supports basic DEPP functions as that's all I needed, other functions shouldn't be too hard to add at this point. Released under the BSD license.