Advertisement
Guest User

Untitled

a guest
Jan 13th, 2017
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. int16_t handle;
  2. PICO_STATUS status;
  3. auto bufferLength = 1024 * 1024;
  4. auto bufferMin = (short*)malloc(bufferLength * sizeof(short));
  5. auto bufferMax = (short*)malloc(bufferLength * sizeof(short));
  6.  
  7. ps5000OpenUnit(&handle);
  8. ps5000SetChannel(handle, PS5000_CHANNEL_A, 1, 1, PS5000_1V);
  9. ps5000SetSimpleTrigger(handle, 1, PS5000_CHANNEL_A, PS5000_MAX_VALUE / 2, RISING_OR_FALLING, 0, 10000);
  10.  
  11. ps5000SetDataBuffers(handle, PS5000_CHANNEL_A, bufferMax, bufferMin, bufferLength);
  12.  
  13. uint32_t samplerate = 16;
  14. status = ps5000RunStreaming(handle, &samplerate, PS5000_NS, 300000, 300000, 1, 1000, bufferLength);
  15.  
  16. QFile f("dump.txt");
  17. f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
  18. QTextStream stream(&f);
  19.  
  20. while(!autoStop) {
  21.     ready = false;
  22.     status = ps5000GetStreamingLatestValues(handle, (ps5000StreamingReady)CallBackStreaming, NULL);
  23.  
  24.     Sleep(100);
  25.     if(ready){
  26.         for(int i = startIndex; i < sampleCount; i++)
  27.             stream << bufferMax[i] / (double)PS5000_MAX_VALUE << "\n";
  28.        
  29.         if(sampleCount < 1) break;
  30.     }
  31. }
  32. f.close();
  33.  
  34. ps5000CloseUnit(handle);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement