ps2000.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. /****************************************************************************
  2. *
  3. * Filename: ps2000.h
  4. * Author: MTB & MAS
  5. * Description:
  6. *
  7. * This header defines the interface to driver routines for the
  8. * PicoScope 2000 Series PC Oscilloscopes.
  9. *
  10. * Copyright � 2005 - 2022 Pico Technology Ltd. All rights reserved.
  11. *
  12. ****************************************************************************/
  13. #ifndef PS2000_H
  14. #define PS2000_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 ps2000.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 PS2000_FIRST_USB 1
  70. #define PS2000_LAST_USB 127
  71. /* Maximum number of PS2000 units that can be opened at once
  72. */
  73. #define PS2000_MAX_UNITS (PS2000_LAST_USB - PS2000_FIRST_USB + 1)
  74. #define PS2000_MAX_TIMEBASE 19
  75. #define PS2105_MAX_TIMEBASE 20
  76. #define PS2104_MAX_TIMEBASE 19
  77. #define PS2200_MAX_TIMEBASE 23
  78. #define PS2000_MAX_OVERSAMPLE 256
  79. #define PS2105_MAX_ETS_CYCLES 250
  80. #define PS2105_MAX_ETS_INTERLEAVE 50
  81. #define PS2104_MAX_ETS_CYCLES 125
  82. #define PS2104_MAX_ETS_INTERLEAVE 25
  83. #define PS2203_MAX_ETS_CYCLES 250
  84. #define PS2203_MAX_ETS_INTERLEAVE 50
  85. #define PS2204_MAX_ETS_CYCLES 250
  86. #define PS2204_MAX_ETS_INTERLEAVE 40
  87. #define PS2205_MAX_ETS_CYCLES 250
  88. #define PS2205_MAX_ETS_INTERLEAVE 40
  89. #define PS2000_MIN_ETS_CYCLES_INTERLEAVE_RATIO 1
  90. #define PS2000_MAX_ETS_CYCLES_INTERLEAVE_RATIO 10
  91. #define PS2000_MIN_SIGGEN_FREQ 0.0f
  92. #define PS2000_MAX_SIGGEN_FREQ 100000.0f
  93. /* Although the PS2000 uses an 8-bit ADC, it is usually possible to
  94. * oversample (collect multiple readings at each time) by up to 256.
  95. * the results are therefore ALWAYS scaled up to 16-bits, even if
  96. * oversampling is not used.
  97. *
  98. * The maximum and minimum values returned are therefore as follows:
  99. */
  100. #define PS2000_MAX_VALUE 32767
  101. #define PS2000_MIN_VALUE -32767
  102. #define PS2000_LOST_DATA -32768
  103. typedef enum enPS2000Channel
  104. {
  105. PS2000_CHANNEL_A,
  106. PS2000_CHANNEL_B,
  107. PS2000_CHANNEL_C,
  108. PS2000_CHANNEL_D,
  109. PS2000_EXTERNAL,
  110. PS2000_MAX_CHANNELS = PS2000_EXTERNAL,
  111. PS2000_NONE,
  112. } PS2000_CHANNEL;
  113. typedef enum enPS2000Range
  114. {
  115. PS2000_10MV,
  116. PS2000_20MV,
  117. PS2000_50MV,
  118. PS2000_100MV,
  119. PS2000_200MV,
  120. PS2000_500MV,
  121. PS2000_1V,
  122. PS2000_2V,
  123. PS2000_5V,
  124. PS2000_10V,
  125. PS2000_20V,
  126. PS2000_50V,
  127. PS2000_MAX_RANGES
  128. } PS2000_RANGE;
  129. typedef enum enPS2000TimeUnits
  130. {
  131. PS2000_FS,
  132. PS2000_PS,
  133. PS2000_NS,
  134. PS2000_US,
  135. PS2000_MS,
  136. PS2000_S,
  137. PS2000_MAX_TIME_UNITS,
  138. } PS2000_TIME_UNITS;
  139. typedef enum enPS2000Error
  140. {
  141. PS2000_OK,
  142. PS2000_MAX_UNITS_OPENED, // more than PS2000_MAX_UNITS
  143. PS2000_MEM_FAIL, //not enough RAM on host machine
  144. PS2000_NOT_FOUND, //cannot find device
  145. PS2000_FW_FAIL, //unabled to download firmware
  146. PS2000_NOT_RESPONDING,
  147. PS2000_CONFIG_FAIL, //missing or corrupted configuration settings
  148. PS2000_OS_NOT_SUPPORTED, //need to use win98SE (or later) or win2k (or later)
  149. PS2000_PICOPP_TOO_OLD,
  150. } PS2000_ERROR;
  151. typedef enum enPS2000Info
  152. {
  153. PS2000_DRIVER_VERSION,
  154. PS2000_USB_VERSION,
  155. PS2000_HARDWARE_VERSION,
  156. PS2000_VARIANT_INFO,
  157. PS2000_BATCH_AND_SERIAL,
  158. PS2000_CAL_DATE,
  159. PS2000_ERROR_CODE,
  160. PS2000_KERNEL_DRIVER_VERSION,
  161. PS2000_DRIVER_PATH
  162. } PS2000_INFO;
  163. typedef enum enPS2000TriggerDirection
  164. {
  165. PS2000_RISING,
  166. PS2000_FALLING,
  167. PS2000_MAX_DIRS
  168. } PS2000_TDIR;
  169. typedef enum enPS2000OpenProgress
  170. {
  171. PS2000_OPEN_PROGRESS_FAIL = -1,
  172. PS2000_OPEN_PROGRESS_PENDING = 0,
  173. PS2000_OPEN_PROGRESS_COMPLETE = 1
  174. } PS2000_OPEN_PROGRESS;
  175. typedef enum enPS2000EtsMode
  176. {
  177. PS2000_ETS_OFF, // ETS disabled
  178. PS2000_ETS_FAST, // Return ready as soon as requested no of interleaves is available
  179. PS2000_ETS_SLOW, // Return ready every time a new set of no_of_cycles is collected
  180. PS2000_ETS_MODES_MAX
  181. } PS2000_ETS_MODE;
  182. typedef enum enPS2000ButtonState
  183. {
  184. PS2000_NO_PRESS,
  185. PS2000_SHORT_PRESS,
  186. PS2000_LONG_PRESS
  187. } PS2000_BUTTON_STATE;
  188. typedef enum enPS2000SweepType
  189. {
  190. PS2000_UP,
  191. PS2000_DOWN,
  192. PS2000_UPDOWN,
  193. PS2000_DOWNUP,
  194. MAX_SWEEP_TYPES
  195. } PS2000_SWEEP_TYPE;
  196. typedef enum enPS2000WaveType
  197. {
  198. PS2000_SINE,
  199. PS2000_SQUARE,
  200. PS2000_TRIANGLE,
  201. PS2000_RAMPUP,
  202. PS2000_RAMPDOWN,
  203. PS2000_DC_VOLTAGE,
  204. PS2000_GAUSSIAN,
  205. PS2000_SINC,
  206. PS2000_HALF_SINE,
  207. } PS2000_WAVE_TYPE;
  208. typedef void (PREF4 *GetOverviewBuffersMaxMin)
  209. (
  210. int16_t **overviewBuffers,
  211. int16_t overflow,
  212. uint32_t triggeredAt,
  213. int16_t triggered,
  214. int16_t auto_stop,
  215. uint32_t nValues
  216. );
  217. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_open_unit)
  218. (
  219. void
  220. );
  221. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_get_unit_info)
  222. (
  223. int16_t handle,
  224. int8_t *string,
  225. int16_t string_length,
  226. int16_t line
  227. );
  228. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_flash_led)
  229. (
  230. int16_t handle
  231. );
  232. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_close_unit)
  233. (
  234. int16_t handle
  235. );
  236. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_set_channel)
  237. (
  238. int16_t handle,
  239. int16_t channel,
  240. int16_t enabled,
  241. int16_t dc,
  242. int16_t range
  243. );
  244. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_get_timebase)
  245. (
  246. int16_t handle,
  247. int16_t timebase,
  248. int32_t no_of_samples,
  249. int32_t *time_interval,
  250. int16_t *time_units,
  251. int16_t oversample,
  252. int32_t *max_samples
  253. );
  254. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_set_trigger)
  255. (
  256. int16_t handle,
  257. int16_t source,
  258. int16_t threshold,
  259. int16_t direction,
  260. int16_t delay,
  261. int16_t auto_trigger_ms
  262. );
  263. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_set_trigger2)
  264. (
  265. int16_t handle,
  266. int16_t source,
  267. int16_t threshold,
  268. int16_t direction,
  269. float delay,
  270. int16_t auto_trigger_ms
  271. );
  272. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_run_block)
  273. (
  274. int16_t handle,
  275. int32_t no_of_values,
  276. int16_t timebase,
  277. int16_t oversample,
  278. int32_t * time_indisposed_ms
  279. );
  280. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_run_streaming)
  281. (
  282. int16_t handle,
  283. int16_t sample_interval_ms,
  284. int32_t max_samples,
  285. int16_t windowed
  286. );
  287. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_run_streaming_ns)
  288. (
  289. int16_t handle,
  290. uint32_t sample_interval,
  291. PS2000_TIME_UNITS time_units,
  292. uint32_t max_samples,
  293. int16_t auto_stop,
  294. uint32_t noOfSamplesPerAggregate,
  295. uint32_t overview_buffer_size);
  296. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_ready)
  297. (
  298. int16_t handle
  299. );
  300. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_stop)
  301. (
  302. int16_t handle
  303. );
  304. PREF0 PREF1 int32_t PREF2 PREF3(ps2000_get_values)
  305. (
  306. int16_t handle,
  307. int16_t *buffer_a,
  308. int16_t *buffer_b,
  309. int16_t *buffer_c,
  310. int16_t *buffer_d,
  311. int16_t *overflow,
  312. int32_t no_of_values
  313. );
  314. PREF0 PREF1 int32_t PREF2 PREF3(ps2000_get_times_and_values)
  315. (
  316. int16_t handle,
  317. int32_t *times,
  318. int16_t *buffer_a,
  319. int16_t *buffer_b,
  320. int16_t *buffer_c,
  321. int16_t *buffer_d,
  322. int16_t *overflow,
  323. int16_t time_units,
  324. int32_t no_of_values
  325. );
  326. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_last_button_press)
  327. (
  328. int16_t handle
  329. );
  330. PREF0 PREF1 int32_t PREF2 PREF3(ps2000_set_ets)
  331. (
  332. int16_t handle,
  333. int16_t mode,
  334. int16_t ets_cycles,
  335. int16_t ets_interleave
  336. );
  337. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_set_led)
  338. (
  339. int16_t handle,
  340. int16_t state
  341. );
  342. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_open_unit_async)
  343. (
  344. void
  345. );
  346. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_open_unit_progress)
  347. (
  348. int16_t *handle,
  349. int16_t *progress_percent
  350. );
  351. PREF0 PREF1 int16_t PREF2 PREF3 (ps2000_get_streaming_last_values)
  352. (
  353. int16_t handle,
  354. GetOverviewBuffersMaxMin
  355. );
  356. PREF0 PREF1 int16_t PREF2 PREF3 (ps2000_overview_buffer_status)
  357. (
  358. int16_t handle,
  359. int16_t *previous_buffer_overrun
  360. );
  361. PREF0 PREF1 uint32_t PREF2 PREF3 (ps2000_get_streaming_values)
  362. (
  363. int16_t handle,
  364. double *start_time,
  365. int16_t *pbuffer_a_max,
  366. int16_t *pbuffer_a_min,
  367. int16_t *pbuffer_b_max,
  368. int16_t *pbuffer_b_min,
  369. int16_t *pbuffer_c_max,
  370. int16_t *pbuffer_c_min,
  371. int16_t *pbuffer_d_max,
  372. int16_t *pbuffer_d_min,
  373. int16_t *overflow,
  374. uint32_t *triggerAt,
  375. int16_t *triggered,
  376. uint32_t no_of_values,
  377. uint32_t noOfSamplesPerAggregate
  378. );
  379. PREF0 PREF1 uint32_t PREF2 PREF3 (ps2000_get_streaming_values_no_aggregation)
  380. (
  381. int16_t handle,
  382. double *start_time,
  383. int16_t * pbuffer_a,
  384. int16_t * pbuffer_b,
  385. int16_t * pbuffer_c,
  386. int16_t * pbuffer_d,
  387. int16_t * overflow,
  388. uint32_t * triggerAt,
  389. int16_t * trigger,
  390. uint32_t no_of_values
  391. );
  392. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_set_light)
  393. (
  394. int16_t handle,
  395. int16_t state
  396. );
  397. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_set_sig_gen_arbitrary)
  398. (
  399. int16_t handle,
  400. int32_t offsetVoltage,
  401. uint32_t pkToPk,
  402. uint32_t startDeltaPhase,
  403. uint32_t stopDeltaPhase,
  404. uint32_t deltaPhaseIncrement,
  405. uint32_t dwellCount,
  406. uint8_t *arbitraryWaveform,
  407. int32_t arbitraryWaveformSize,
  408. PS2000_SWEEP_TYPE sweepType,
  409. uint32_t sweeps
  410. );
  411. PREF0 PREF1 int16_t PREF2 PREF3(ps2000_set_sig_gen_built_in)
  412. (
  413. int16_t handle,
  414. int32_t offsetVoltage,
  415. uint32_t pkToPk,
  416. PS2000_WAVE_TYPE waveType,
  417. float startFrequency,
  418. float stopFrequency,
  419. float increment,
  420. float dwellTime,
  421. PS2000_SWEEP_TYPE sweepType,
  422. uint32_t sweeps
  423. );
  424. //===========================================================
  425. // Adv Trigger
  426. //===========================================================
  427. typedef enum enPS2000ThresholdDirection
  428. {
  429. PS2000_ABOVE,
  430. PS2000_BELOW,
  431. PS2000_ADV_RISING,
  432. PS2000_ADV_FALLING,
  433. PS2000_RISING_OR_FALLING,
  434. PS2000_INSIDE = PS2000_ABOVE,
  435. PS2000_OUTSIDE = PS2000_BELOW,
  436. PS2000_ENTER = PS2000_ADV_RISING,
  437. PS2000_EXIT = PS2000_ADV_FALLING,
  438. PS2000_ENTER_OR_EXIT = PS2000_RISING_OR_FALLING,
  439. PS2000_ADV_NONE = PS2000_ADV_RISING
  440. } PS2000_THRESHOLD_DIRECTION;
  441. typedef enum enPS2000ThresholdMode
  442. {
  443. PS2000_LEVEL,
  444. PS2000_WINDOW
  445. } PS2000_THRESHOLD_MODE;
  446. typedef enum enPS2000TriggerState
  447. {
  448. PS2000_CONDITION_DONT_CARE,
  449. PS2000_CONDITION_TRUE,
  450. PS2000_CONDITION_FALSE,
  451. PS2000_CONDITION_MAX
  452. } PS2000_TRIGGER_STATE;
  453. typedef enum enPS2000PulseWidthType
  454. {
  455. PS2000_PW_TYPE_NONE,
  456. PS2000_PW_TYPE_LESS_THAN,
  457. PS2000_PW_TYPE_GREATER_THAN,
  458. PS2000_PW_TYPE_IN_RANGE,
  459. PS2000_PW_TYPE_OUT_OF_RANGE
  460. } PS2000_PULSE_WIDTH_TYPE;
  461. #pragma pack(1)
  462. typedef struct tPS2000TriggerChannelProperties
  463. {
  464. int16_t thresholdMajor;
  465. int16_t thresholdMinor;
  466. uint16_t hysteresis;
  467. int16_t channel;
  468. PS2000_THRESHOLD_MODE thresholdMode;
  469. } PS2000_TRIGGER_CHANNEL_PROPERTIES;
  470. #pragma pack()
  471. #pragma pack(1)
  472. typedef struct tPS2000TriggerConditions
  473. {
  474. PS2000_TRIGGER_STATE channelA;
  475. PS2000_TRIGGER_STATE channelB;
  476. PS2000_TRIGGER_STATE channelC;
  477. PS2000_TRIGGER_STATE channelD;
  478. PS2000_TRIGGER_STATE external;
  479. PS2000_TRIGGER_STATE pulseWidthQualifier;
  480. } PS2000_TRIGGER_CONDITIONS;
  481. #pragma pack()
  482. #pragma pack(1)
  483. typedef struct tPS2000PwqConditions
  484. {
  485. PS2000_TRIGGER_STATE channelA;
  486. PS2000_TRIGGER_STATE channelB;
  487. PS2000_TRIGGER_STATE channelC;
  488. PS2000_TRIGGER_STATE channelD;
  489. PS2000_TRIGGER_STATE external;
  490. } PS2000_PWQ_CONDITIONS;
  491. #pragma pack()
  492. PREF0 PREF1 int16_t PREF2 PREF3 (ps2000SetAdvTriggerChannelProperties)
  493. (
  494. int16_t handle,
  495. PS2000_TRIGGER_CHANNEL_PROPERTIES *channelProperties,
  496. int16_t nChannelProperties,
  497. int32_t autoTriggerMilliseconds
  498. );
  499. PREF0 PREF1 int16_t PREF2 PREF3 (ps2000SetAdvTriggerChannelConditions)
  500. (
  501. int16_t handle,
  502. PS2000_TRIGGER_CONDITIONS *conditions,
  503. int16_t nConditions
  504. );
  505. PREF0 PREF1 int16_t PREF2 PREF3 (ps2000SetAdvTriggerChannelDirections)
  506. (
  507. int16_t handle,
  508. PS2000_THRESHOLD_DIRECTION channelA,
  509. PS2000_THRESHOLD_DIRECTION channelB,
  510. PS2000_THRESHOLD_DIRECTION channelC,
  511. PS2000_THRESHOLD_DIRECTION channelD,
  512. PS2000_THRESHOLD_DIRECTION ext
  513. );
  514. PREF0 PREF1 int16_t PREF2 PREF3 (ps2000SetPulseWidthQualifier)
  515. (
  516. int16_t handle,
  517. PS2000_PWQ_CONDITIONS *conditions,
  518. int16_t nConditions,
  519. PS2000_THRESHOLD_DIRECTION direction,
  520. uint32_t lower,
  521. uint32_t upper,
  522. PS2000_PULSE_WIDTH_TYPE type
  523. );
  524. PREF0 PREF1 int16_t PREF2 PREF3 (ps2000SetAdvTriggerDelay)
  525. (
  526. int16_t handle,
  527. uint32_t delay,
  528. float preTriggerDelay
  529. );
  530. PREF0 PREF1 int16_t PREF2 PREF3 (ps2000PingUnit)
  531. (
  532. int16_t handle
  533. );
  534. #endif /* not defined PS2000_H */