ps3000.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. /****************************************************************************
  2. *
  3. * Filename: ps3000.h
  4. * Author: MTB & MAS
  5. * Description:
  6. *
  7. * This header defines the interface to driver routines for the
  8. * PicoScope 3000 Series PC Oscilloscopes.
  9. *
  10. * Copyright � 2002 - 2022 Pico Technology Ltd. All rights reserved.
  11. *
  12. ****************************************************************************/
  13. #ifndef PS3000_H
  14. #define PS3000_H
  15. #include <stdint.h>
  16. #ifdef PREF0
  17. #undef PREF0
  18. #endif
  19. #ifdef PREF1
  20. #undef PREF1
  21. #endif
  22. #ifdef PREF2
  23. #undef PREF2
  24. #endif
  25. #ifdef PREF3
  26. #undef PREF3
  27. #endif
  28. #ifdef PREF4
  29. #undef PREF4
  30. #endif
  31. #ifdef __cplusplus
  32. #define PREF0 extern "C"
  33. #else
  34. #define PREF0
  35. #endif
  36. /* If you are dynamically linking ps3000.dll into your project #define DYNLINK here
  37. */
  38. #ifdef WIN32
  39. #ifdef DYNLINK
  40. #define PREF1 typedef
  41. #define PREF2
  42. #define PREF3(x) (__stdcall *x)
  43. #else
  44. #define PREF1
  45. #ifdef _USRDLL
  46. #define PREF2 __declspec(dllexport) __stdcall
  47. #else
  48. #define PREF2 __declspec(dllimport) __stdcall
  49. #endif
  50. #define PREF3(x) x
  51. #endif
  52. #define PREF4 __stdcall
  53. #else
  54. #ifdef DYNLINK
  55. #define PREF1 typedef
  56. #define PREF2
  57. #define PREF3(x) (*x)
  58. #else
  59. #ifdef _USRDLL
  60. #define PREF1 __attribute__((visibility("default")))
  61. #else
  62. #define PREF1
  63. #endif
  64. #define PREF2
  65. #define PREF3(x) x
  66. #endif
  67. #define PREF4
  68. #endif
  69. #define PS3000_FIRST_USB 1
  70. #if defined (_DEBUG)
  71. #define PS3000_LAST_USB 64
  72. #else
  73. #define PS3000_LAST_USB 127
  74. #endif
  75. /* Maximum number of PS3000 units that can be opened at once
  76. */
  77. #define PS3000_MAX_UNITS (PS3000_LAST_USB - PS3000_FIRST_USB + 1)
  78. #define PS3206_MAX_TIMEBASE 21
  79. #define PS3205_MAX_TIMEBASE 20
  80. #define PS3204_MAX_TIMEBASE 19
  81. #define PS3224_MAX_TIMEBASE 19
  82. #define PS3223_MAX_TIMEBASE 19
  83. #define PS3424_MAX_TIMEBASE 19
  84. #define PS3423_MAX_TIMEBASE 19
  85. #define PS3225_MAX_TIMEBASE 18
  86. #define PS3226_MAX_TIMEBASE 19
  87. #define PS3425_MAX_TIMEBASE 19
  88. #define PS3426_MAX_TIMEBASE 19
  89. #define PS3000_MAX_OVERSAMPLE 256
  90. /* Although the PS3000 uses an 8-bit ADC, it is usually possible to
  91. * oversample (collect multiple readings at each time) by up to 256.
  92. * the results are therefore ALWAYS scaled up to 16-bits, even if
  93. * oversampling is not used.
  94. *
  95. * The maximum and minimum values returned are therefore as follows:
  96. */
  97. #define PS3000_MAX_VALUE 32767
  98. #define PS3000_MIN_VALUE -32767
  99. #define PS3000_LOST_DATA -32768
  100. /*
  101. * Signal generator constants. Note that a signal generator is not
  102. * available on all variants.
  103. */
  104. #define PS3000_MIN_SIGGEN_FREQ 0.093
  105. #define PS3000_MAX_SIGGEN_FREQ 1000000L
  106. /*
  107. * ETS constants
  108. */
  109. #define PS3206_MAX_ETS_CYCLES 500
  110. #define PS3206_MAX_ETS_INTERLEAVE 100
  111. #define PS3205_MAX_ETS_CYCLES 250
  112. #define PS3205_MAX_ETS_INTERLEAVE 50
  113. #define PS3204_MAX_ETS_CYCLES 125
  114. #define PS3204_MAX_ETS_INTERLEAVE 25
  115. #define PS3000_MAX_ETS_CYCLES_INTERLEAVE_RATIO 10
  116. #define PS3000_MIN_ETS_CYCLES_INTERLEAVE_RATIO 1
  117. #define PS300_MAX_ETS_SAMPLES 100000
  118. #define MAX_PULSE_WIDTH_QUALIFIER_COUNT 16777215L
  119. #define MAX_HOLDOFF_COUNT 8388607L
  120. typedef enum enPS3000Channel
  121. {
  122. PS3000_CHANNEL_A,
  123. PS3000_CHANNEL_B,
  124. PS3000_CHANNEL_C,
  125. PS3000_CHANNEL_D,
  126. PS3000_EXTERNAL,
  127. PS3000_MAX_CHANNELS = PS3000_EXTERNAL,
  128. PS3000_NONE,
  129. PS3000_MAX_TRIGGER_SOURCES
  130. } PS3000_CHANNEL;
  131. typedef enum enPS3000Range
  132. {
  133. PS3000_10MV,
  134. PS3000_20MV,
  135. PS3000_50MV,
  136. PS3000_100MV,
  137. PS3000_200MV,
  138. PS3000_500MV,
  139. PS3000_1V,
  140. PS3000_2V,
  141. PS3000_5V,
  142. PS3000_10V,
  143. PS3000_20V,
  144. PS3000_50V,
  145. PS3000_100V,
  146. PS3000_200V,
  147. PS3000_400V,
  148. PS3000_MAX_RANGES
  149. } PS3000_RANGE;
  150. typedef enum enPS3000WaveTypes
  151. {
  152. PS3000_SQUARE,
  153. PS3000_TRIANGLE,
  154. PS3000_SINE,
  155. PS3000_MAX_WAVE_TYPES
  156. } PS3000_WAVE_TYPES;
  157. typedef enum enPS3000TimeUnits
  158. {
  159. PS3000_FS,
  160. PS3000_PS,
  161. PS3000_NS,
  162. PS3000_US,
  163. PS3000_MS,
  164. PS3000_S,
  165. PS3000_MAX_TIME_UNITS,
  166. } PS3000_TIME_UNITS;
  167. typedef enum enPS3000Error
  168. {
  169. PS3000_OK,
  170. PS3000_MAX_UNITS_OPENED, // more than PS3000_MAX_UNITS
  171. PS3000_MEM_FAIL, //not enough RAM on host machine
  172. PS3000_NOT_FOUND, //cannot find device
  173. PS3000_FW_FAIL, //unabled to download firmware
  174. PS3000_NOT_RESPONDING,
  175. PS3000_CONFIG_FAIL, //missing or corrupted configuration settings
  176. PS3000_OS_NOT_SUPPORTED, //need to use win98SE (or later) or win2k (or later)
  177. PS3000_PICOPP_TOO_OLD,
  178. } PS3000_ERROR;
  179. typedef enum enPS3000Info
  180. {
  181. PS3000_DRIVER_VERSION,
  182. PS3000_USB_VERSION,
  183. PS3000_HARDWARE_VERSION,
  184. PS3000_VARIANT_INFO,
  185. PS3000_BATCH_AND_SERIAL,
  186. PS3000_CAL_DATE,
  187. PS3000_ERROR_CODE,
  188. PS3000_KERNEL_DRIVER_VERSION,
  189. PS3000_DRIVER_PATH
  190. } PS3000_INFO;
  191. typedef enum enPS3000TriggerDirection
  192. {
  193. PS3000_RISING,
  194. PS3000_FALLING,
  195. PS3000_MAX_DIRS
  196. } PS3000_TDIR;
  197. typedef enum enPS3000OpenProgress
  198. {
  199. PS3000_OPEN_PROGRESS_FAIL = -1,
  200. PS3000_OPEN_PROGRESS_PENDING = 0,
  201. PS3000_OPEN_PROGRESS_COMPLETE = 1
  202. } PS3000_OPEN_PROGRESS;
  203. typedef enum enPS3000EtsMode
  204. {
  205. PS3000_ETS_OFF, // ETS disabled
  206. PS3000_ETS_FAST, // Return ready as soon as requested no of interleaves is available
  207. PS3000_ETS_SLOW, // Return ready every time a new set of no_of_cycles is collected
  208. PS3000_ETS_MODES_MAX
  209. } PS3000_ETS_MODE;
  210. typedef int16_t (PREF4 *PS3000_CALLBACK_FUNC)
  211. (
  212. int16_t *dataBuffer,
  213. int16_t noOfBuffers
  214. );
  215. typedef void (PREF4 *GetOverviewBuffersMaxMin)
  216. (
  217. int16_t **overviewBuffers,
  218. int16_t overflow,
  219. uint32_t triggeredAt,
  220. int16_t triggered,
  221. int16_t auto_stop,
  222. uint32_t nValues
  223. );
  224. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_open_unit)
  225. (
  226. void
  227. );
  228. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_get_unit_info)
  229. (
  230. int16_t handle,
  231. int8_t *string,
  232. int16_t string_length,
  233. int16_t line
  234. );
  235. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_flash_led)
  236. (
  237. int16_t handle
  238. );
  239. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_close_unit)
  240. (
  241. int16_t handle
  242. );
  243. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_set_channel)
  244. (
  245. int16_t handle,
  246. int16_t channel,
  247. int16_t enabled,
  248. int16_t dc,
  249. int16_t range
  250. );
  251. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_get_timebase)
  252. (
  253. int16_t handle,
  254. int16_t timebase,
  255. int32_t no_of_samples,
  256. int32_t *time_interval,
  257. int16_t *time_units,
  258. int16_t oversample,
  259. int32_t *max_samples
  260. );
  261. PREF0 PREF1 int32_t PREF2 PREF3(ps3000_set_siggen)
  262. (
  263. int16_t handle,
  264. int16_t wave_type,
  265. int32_t start_frequency,
  266. int32_t stop_frequency,
  267. float increment,
  268. int16_t dwell_time,
  269. int16_t repeat,
  270. int16_t dual_slope
  271. );
  272. PREF0 PREF1 int32_t PREF2 PREF3(ps3000_set_ets)
  273. (
  274. int16_t handle,
  275. int16_t mode,
  276. int16_t ets_cycles,
  277. int16_t ets_interleave
  278. );
  279. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_set_trigger)
  280. (
  281. int16_t handle,
  282. int16_t source,
  283. int16_t threshold,
  284. int16_t direction,
  285. int16_t delay,
  286. int16_t auto_trigger_ms
  287. );
  288. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_set_trigger2)
  289. (
  290. int16_t handle,
  291. int16_t source,
  292. int16_t threshold,
  293. int16_t direction,
  294. float delay,
  295. int16_t auto_trigger_ms
  296. );
  297. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_run_block)
  298. (
  299. int16_t handle,
  300. int32_t no_of_values,
  301. int16_t timebase,
  302. int16_t oversample,
  303. int32_t * time_indisposed_ms
  304. );
  305. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_run_streaming_ns)
  306. (
  307. int16_t handle,
  308. uint32_t sample_interval,
  309. PS3000_TIME_UNITS time_units,
  310. uint32_t max_samples,
  311. int16_t auto_stop,
  312. uint32_t noOfSamplesPerAggregate,
  313. uint32_t overview_buffer_size
  314. );
  315. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_run_streaming)
  316. (
  317. int16_t handle,
  318. int16_t sample_interval_ms,
  319. int32_t max_samples,
  320. int16_t windowed
  321. );
  322. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_ready)
  323. (
  324. int16_t handle
  325. );
  326. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_stop)
  327. (
  328. int16_t handle
  329. );
  330. PREF0 PREF1 int32_t PREF2 PREF3(ps3000_get_values)
  331. (
  332. int16_t handle,
  333. int16_t *buffer_a,
  334. int16_t *buffer_b,
  335. int16_t *buffer_c,
  336. int16_t *buffer_d,
  337. int16_t *overflow,
  338. int32_t no_of_values
  339. );
  340. PREF0 PREF1 void PREF2 PREF3 (ps3000_release_stream_buffer)
  341. (
  342. int16_t handle
  343. );
  344. PREF0 PREF1 int32_t PREF2 PREF3(ps3000_get_times_and_values)
  345. (
  346. int16_t handle,
  347. int32_t *times,
  348. int16_t *buffer_a,
  349. int16_t *buffer_b,
  350. int16_t *buffer_c,
  351. int16_t *buffer_d,
  352. int16_t *overflow,
  353. int16_t time_units,
  354. int32_t no_of_values
  355. );
  356. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_open_unit_async)
  357. (
  358. void
  359. );
  360. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_open_unit_progress)
  361. (
  362. int16_t *handle,
  363. int16_t * progress_percent
  364. );
  365. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_streaming_ns_get_interval_stateless)
  366. (
  367. int16_t handle,
  368. int16_t nChannels,
  369. uint32_t *sample_interval
  370. );
  371. PREF0 PREF1 int16_t PREF2 PREF3(ps3000_get_streaming_last_values)
  372. (
  373. int16_t handle,
  374. GetOverviewBuffersMaxMin lpGetOverviewBuffersMaxMin
  375. );
  376. PREF0 PREF1 int16_t PREF2 PREF3 (ps3000_overview_buffer_status)
  377. (
  378. int16_t handle,
  379. int16_t *previous_buffer_overrun
  380. );
  381. PREF0 PREF1 uint32_t PREF2 PREF3(ps3000_get_streaming_values)
  382. (
  383. int16_t handle,
  384. double *start_time,
  385. int16_t *pbuffer_a_max,
  386. int16_t *pbuffer_a_min,
  387. int16_t *pbuffer_b_max,
  388. int16_t *pbuffer_b_min,
  389. int16_t *pbuffer_c_max,
  390. int16_t *pbuffer_c_min,
  391. int16_t *pbuffer_d_max,
  392. int16_t *pbuffer_d_min,
  393. int16_t *overflow,
  394. uint32_t *triggerAt,
  395. int16_t *triggered,
  396. uint32_t no_of_values,
  397. uint32_t noOfSamplesPerAggregate
  398. );
  399. PREF0 PREF1 uint32_t PREF2 PREF3 (ps3000_get_streaming_values_no_aggregation)
  400. (
  401. int16_t handle,
  402. double *start_time,
  403. int16_t *pbuffer_a,
  404. int16_t *pbuffer_b,
  405. int16_t *pbuffer_c,
  406. int16_t *pbuffer_d,
  407. int16_t *overflow,
  408. uint32_t *triggerAt,
  409. int16_t *trigger,
  410. uint32_t no_of_values
  411. );
  412. PREF0 PREF1 int16_t PREF2 PREF3 (ps3000_save_streaming_data)
  413. (
  414. int16_t handle,
  415. PS3000_CALLBACK_FUNC lpCallbackFunc,
  416. int16_t *dataBuffers,
  417. int16_t dataBufferSize
  418. );
  419. //===========================================================
  420. // Adv Trigger
  421. //===========================================================
  422. typedef enum enThresholdDirection
  423. {
  424. ABOVE,
  425. BELOW,
  426. RISING,
  427. FALLING,
  428. RISING_OR_FALLING,
  429. INSIDE = ABOVE,
  430. OUTSIDE = BELOW,
  431. ENTER = RISING,
  432. EXIT = FALLING,
  433. ENTER_OR_EXIT = RISING_OR_FALLING,
  434. NONE = RISING
  435. } THRESHOLD_DIRECTION;
  436. typedef enum enThresholdMode
  437. {
  438. LEVEL,
  439. WINDOW
  440. } THRESHOLD_MODE;
  441. typedef enum enTriggerState
  442. {
  443. CONDITION_DONT_CARE,
  444. CONDITION_TRUE,
  445. CONDITION_FALSE,
  446. CONDITION_MAX
  447. } TRIGGER_STATE;
  448. typedef enum enPulseWidthType
  449. {
  450. PW_TYPE_NONE,
  451. PW_TYPE_LESS_THAN,
  452. PW_TYPE_GREATER_THAN,
  453. PW_TYPE_IN_RANGE,
  454. PW_TYPE_OUT_OF_RANGE
  455. } PULSE_WIDTH_TYPE;
  456. #pragma pack(1)
  457. typedef struct tTriggerChannelProperties
  458. {
  459. int16_t thresholdMajor;
  460. int16_t thresholdMinor;
  461. uint16_t hysteresis;
  462. int16_t channel;
  463. THRESHOLD_MODE thresholdMode;
  464. } TRIGGER_CHANNEL_PROPERTIES;
  465. #pragma pack()
  466. #pragma pack(1)
  467. typedef struct tTriggerConditions
  468. {
  469. TRIGGER_STATE channelA;
  470. TRIGGER_STATE channelB;
  471. TRIGGER_STATE channelC;
  472. TRIGGER_STATE channelD;
  473. TRIGGER_STATE external;
  474. TRIGGER_STATE pulseWidthQualifier;
  475. } TRIGGER_CONDITIONS;
  476. #pragma pack()
  477. #pragma pack(1)
  478. typedef struct tPwqConditions
  479. {
  480. TRIGGER_STATE channelA;
  481. TRIGGER_STATE channelB;
  482. TRIGGER_STATE channelC;
  483. TRIGGER_STATE channelD;
  484. TRIGGER_STATE external;
  485. } PWQ_CONDITIONS;
  486. #pragma pack()
  487. PREF0 PREF1 int16_t PREF2 PREF3 (ps3000SetAdvTriggerChannelProperties)
  488. (
  489. int16_t handle,
  490. TRIGGER_CHANNEL_PROPERTIES *channelProperties,
  491. int16_t nChannelProperties,
  492. int32_t autoTriggerMilliseconds
  493. );
  494. PREF0 PREF1 int16_t PREF2 PREF3 (ps3000SetAdvTriggerChannelConditions)
  495. (
  496. int16_t handle,
  497. TRIGGER_CONDITIONS *conditions,
  498. int16_t nConditions
  499. );
  500. PREF0 PREF1 int16_t PREF2 PREF3 (ps3000SetAdvTriggerChannelDirections)
  501. (
  502. int16_t handle,
  503. THRESHOLD_DIRECTION channelA,
  504. THRESHOLD_DIRECTION channelB,
  505. THRESHOLD_DIRECTION channelC,
  506. THRESHOLD_DIRECTION channelD,
  507. THRESHOLD_DIRECTION ext
  508. );
  509. PREF0 PREF1 int16_t PREF2 PREF3 (ps3000SetPulseWidthQualifier)
  510. (
  511. int16_t handle,
  512. PWQ_CONDITIONS *conditions,
  513. int16_t nConditions,
  514. THRESHOLD_DIRECTION direction,
  515. uint32_t lower,
  516. uint32_t upper,
  517. PULSE_WIDTH_TYPE type
  518. );
  519. PREF0 PREF1 int16_t PREF2 PREF3 (ps3000SetAdvTriggerDelay)
  520. (
  521. int16_t handle,
  522. uint32_t delay,
  523. float preTriggerDelay
  524. );
  525. PREF0 PREF1 int16_t PREF2 PREF3 (ps3000PingUnit)
  526. (
  527. int16_t handle
  528. );
  529. #endif /* not defined PS3000_H */