1 /***************************************************************************
\r
2 ****************************************************************************
\r
4 * Humusoft data acquisition library.
\r
6 * Copyright 2002-2008 Humusoft s.r.o.
\r
7 * Copyright 2009-2010 J.Fojtik
\r
9 ******************************************************************************
\r
10 *****************************************************************************/
\r
12 #ifndef HUDAQLIB_H__
\r
13 #define HUDAQLIB_H__
\r
16 /* All the functions have C naming convention in C++. */
\r
19 #endif /* __cplusplus */
\r
22 /* Define calling conventions. */
\r
24 #define HUDAQLIBPUBLIC __declspec(dllimport)
\r
28 #define HUDAQAPI __stdcall
\r
31 #define HUDAQLIBPUBLIC
\r
37 /** Return codes for HUDAQ functions.
\r
38 * @ingroup GroupConstants
\r
42 HUDAQSUCCESS = 0, ///< Success. @ifnot UNDOCUMENTED All other values mean failure. @endif
\r
43 /** @cond UNDOCUMENTED */
\r
44 HUDAQPARTIAL = 1, ///< Several A/D or D/A operation succeeded and at least one failed, see ::HudaqAOWriteMultiple.
\r
45 HUDAQFAILURE = 2, ///< Unspecified problem occured (e.g. hardware failure).
\r
46 HUDAQBADARG = 3, ///< Unexpected arguments.
\r
47 HUDAQNOTSUPPORTED = 4 ///< Device does not support this functionality.
\r
48 /** @endcond UNDOCUMENTED */
\r
52 /** Subsystem identifiers.
\r
53 * Used to identify individual subsystems of the board.
\r
54 * @ingroup GroupChannelConfig */
\r
57 HudaqAI = 0x1000, ///< Analog Input
\r
58 HudaqAO = 0x2000, ///< Analog Output
\r
59 HudaqDI = 0x3000, ///< Digital Input
\r
60 HudaqDO = 0x4000, ///< Digital Output
\r
61 HudaqEnc = 0x5000, ///< Encoder
\r
62 HudaqCtr = 0x6000, ///< Counter
\r
63 HudaqPWM = 0x7000, ///< Pulse-Width Modulation Output
\r
64 /** @cond UNDOCUMENTED */
\r
65 HudaqStep= 0x8000, ///< Stepper motor
\r
66 HudaqIRQ = 0x9000, ///< IRQ subsystem
\r
67 HudaqSubsystemMASK = 0xFFFFF000 ///< Mask that separates subsystem number and its parameter.
\r
68 /** @endcond UNDOCUMENTED */
\r
72 /** Parameter identifiers. They are used as the third parameter to
\r
73 * ::HudaqGetParameter and ::HudaqSetParameter functions to specify which parameter should be
\r
74 * configured. Please note that a particular
\r
75 * device does not neccesarily support all functions.
\r
77 * @ingroup GroupChannelConfig
\r
81 /* Parameter names for Analog Input functions. */
\r
82 /** @cond UNDOCUMENTED */
\r
83 HudaqAIUNITS = HudaqAI, ///< Set units of channel. See ::HudaqAIOUnits.
\r
84 /** @endcond UNDOCUMENTED */
\r
85 HudaqAIRANGE, ///< @brief Select analog input voltage range. @brief The range is selected by its index;
\r
86 ///< the actual voltages corresponding to the range can be obtained by calling ::HudaqQueryRange. @par
\r
87 /** @cond UNDOCUMENTED */
\r
88 HudaqAINUMCHANNELS, ///< Get number of analog input channels.
\r
89 /** @endcond UNDOCUMENTED */
\r
91 /* Parameter names for Analog Output functions. */
\r
92 /** @cond UNDOCUMENTED */
\r
93 HudaqAOUNITS = HudaqAO, ///< Set units of channel. See ::HudaqAIOUnits.
\r
94 /** @endcond UNDOCUMENTED */
\r
95 HudaqAORANGE, ///< @brief Select analog output voltage range. @brief The range is selected by its index;
\r
96 ///< the actual voltages corresponding to the range can be obtained by calling ::HudaqQueryRange. @par
\r
97 /** @cond UNDOCUMENTED */
\r
98 HudaqAONUMCHANNELS, ///< Get number of analog output channels.
\r
99 /** @endcond UNDOCUMENTED */
\r
101 /* Parameter names for Digital Output functions. */
\r
102 /** @cond UNDOCUMENTED */
\r
103 HudaqDINUMCHANNELS = HudaqDI, ///< Get number of digital input channels.
\r
104 HudaqDINUMBITS, ///< Get number of bits in one digital output channel. @par
\r
105 /** @endcond UNDOCUMENTED */
\r
107 /* Parameter names for Digital Output functions. */
\r
108 /** @cond UNDOCUMENTED */
\r
109 HudaqDONUMCHANNELS = HudaqDO, ///< Get number of digital output channels.
\r
110 HudaqDONUMBITS, ///< Get number of bits in one digital output channel. @par
\r
111 HudaqDOMODE, ///< 0 set channel as input, 1 set channel as output
\r
112 /** @endcond UNDOCUMENTED */
\r
114 /* Parameter names for Encoder Input functions. */
\r
115 HudaqEncRESETONREAD = HudaqEnc,///< Automatically reset encoder pulse count after it is read; possible values are 0 (off) or 1 (on).
\r
116 HudaqEncFILTER, ///< Filter encoder inputs with a lowpass filter; possible values are 0 (off) or 1 (on).
\r
117 HudaqEncMODE, ///< Encoder mode; for possible values see ::HudaqEncMode.
\r
118 HudaqEncCOUNTCONTROL, ///< Encoder count control; for possible values see ::HudaqEncCountControl.
\r
119 HudaqEncRESETMODE, ///< Encoder reset mode; for possible values see ::HudaqEncResetMode. @par
\r
120 /** @cond UNDOCUMENTED */
\r
121 HudaqEncI, ///< Read @a I signal. Only ::HudaqGetParameter is supported; option type int.
\r
122 HudaqEncNUMCHANNELS, ///< Get number of encoder channels.
\r
123 /** @endcond UNDOCUMENTED */
\r
125 /* Parameter names for Counter Input functions. */
\r
126 HudaqCtrRESETONREAD = HudaqCtr,///< Automatically reset counter pulse count after it is read; possible values are 0 (off) or 1 (on).
\r
127 HudaqCtrCLOCKSOURCE, ///< Counter clock source; for possible values see ::HudaqCtrClockSource.
\r
128 HudaqCtrOUTPUTCONTROL, ///< Counter output signal; for possible values see ::HudaqCtrOutputControl
\r
129 HudaqCtrREPETITION, ///< 0 - counter stops after terminal count; 1 - counter reloads and continues counting.
\r
130 HudaqCtrLOADTOGGLE, ///< 0 - always load from register A; 1 - alternate load registers A and B.
\r
131 HudaqCtrDIRECTION, ///< 0 - counter counts down; 1 - counter counts up.
\r
132 HudaqCtrOUTTOGGLE, ///< 0 - output is directly connected to TC; 1 - use flipflop that is toggled on every TC.
\r
133 HudaqCtrTRIGSOURCE, ///< Counter trigger source; for possible values see ::HudaqCtrTrigSource
\r
134 HudaqCtrTRIGTYPE, ///< Counter trigger edge; for possible values see ::HudaqCtrTrigType
\r
135 HudaqCtrRETRIGGER, ///< Counter can be retriggered: 0 - only when stopped; 1 - anytime
\r
136 HudaqCtrGATESOURCE, ///< Counter gate source; for possible values see ::HudaqCtrGateSource
\r
137 HudaqCtrGATEPOLARITY, ///< Counter gate polarity: 0 - gate low disables counting; 1 - gate high disables counting.
\r
138 HudaqCtrFILTER, ///< Filter counter inputs with a lowpass filter; possible values are 0 (off) or 1 (on). @par
\r
139 /** @cond UNDOCUMENTED */
\r
140 HudaqCtrNUMCHANNELS, ///< Get number of counter channels. @par
\r
141 /** @endcond UNDOCUMENTED */
\r
143 /* Parameter names for PWM Output functions. */
\r
144 /** @cond UNDOCUMENTED */
\r
145 HudaqPwmTHRESHOLD = HudaqPWM, ///< If you change PWM from slow frequency to fast, the last period for old frequency is in progress.
\r
146 ///< e.g. if you switch from 1Hz to 1MHz you would wait up to 1s to change generated frequency.
\r
147 ///< Frequencies below threshold are fixed for this artefact. Used algorithm ensures that a rest of
\r
148 ///< pulse will not be larger than a period of new frequency.
\r
149 HudaqPwmNUMCHANNELS, ///< Get number of PWM channels.
\r
150 HudaqPwmINPUT, ///< Read @a Input signal. Only ::HudaqGetParameter is supported.
\r
151 /** @endcond UNDOCUMENTED */
\r
152 HudaqPwmPHASES, ///< Read bits that coresponds to output phases. Only ::HudaqGetParameter is supported. (MF625 only)
\r
153 HudaqPwmUPDOWN, ///< Read UpDown flag. Only ::HudaqGetParameter is supported. (MF625 only)
\r
154 HudaqPwmINVERSIONS, ///< Read bits, that corresponds to inversions in all phases. (MF625 only)
\r
155 HudaqPwmDEADBAND, ///< Set dead band between phase and inverted phase (MF625 only)
\r
156 HudaqPwmOUTPUTCONTROL, ///< Output phase signal; for possible values see ::HudaqCtrOutputControl
\r
157 HudaqPwmCLOCKSOURCE, ///< Counter clock source; for possible values see ::HudaqCtrClockSource.
\r
158 HudaqPwmFILTER, ///< Filter counter inputs with a lowpass filter; possible values are 0 (off) or 1 (on).
\r
159 HudaqPwmGATESOURCE, ///< Counter gate source; for possible values see ::HudaqCtrGateSource
\r
160 HudaqPwmTRANSPARENT, ///< 0 - Dual buffer is turned on, 1 - Dual buffer is turned off. (MF625 only)
\r
161 HudaqPwmEMERGENCY, ///< Define condition to block PWM output; for possible values see ::HudaqPwmEmergency (MF625 only)
\r
162 HudaqPwmGATEPOLARITY, ///< Counter gate polarity: 0 - gate low disables counting; 1 - gate high disables counting.
\r
163 HudaqPwmOUTPUTUDCONTROL, ///< Output up/down signal; for possible values see ::HudaqCtrOutputControl @par
\r
165 /* Parameter names for Stepper Output functions. */
\r
166 /** @cond UNDOCUMENTED */
\r
167 HudaqStepFMIN = HudaqStep, ///< Minimal speed of stepping motor [steps/s]; option type double.
\r
168 HudaqStepFMAX, ///< Maximal speed of stepping motor [steps/s]; option type double.
\r
169 HudaqStepACCELERATION, ///< Acceleration of stepping motor [steps/s^2]; option type double.
\r
170 HudaqStepCURRENTPOSITION, ///< Current position in steps; option type int.
\r
171 HudaqStepREMAININGSTEPS, ///< Amount of unrealised steps. Read only. Option type int.
\r
172 HudaqStepTARGETPOSITION, ///< Target position in steps. Read only. Option type int.
\r
173 HudaqStepNUMCHANNELS ///< Get number of stepper channels. @par
\r
174 /** @endcond UNDOCUMENTED */
\r
179 /** @cond UNDOCUMENTED */
\r
180 /* lowercase names for backward compatibility */
\r
183 HudaqAIRange = HudaqAIRANGE,
\r
184 HudaqAORange = HudaqAORANGE
\r
186 /** @endcond UNDOCUMENTED */
\r
189 /** @cond UNDOCUMENTED */
\r
190 /* this is documented elsewhere to avoid generation of class hierarchy */
\r
191 /** Structure that contains one range record with low and high limit.
\r
193 * @ingroup GroupChannelConfig
\r
197 double Lo; ///< Low range limit.
\r
198 double Hi; ///< Target position in steps. Read only. Option type int.
\r
200 /** @endcond UNDOCUMENTED */
\r
204 * The HUDAQ device handle data type.
\r
205 * @ingroup GroupConstants
\r
207 typedef size_t HUDAQHANDLE;
\r
211 /** @cond UNDOCUMENTED */
\r
214 * Resource range structure.
\r
215 * @ingroup GroupConstants
\r
219 size_t Base; ///< Base addres/IO port.
\r
220 size_t Length; ///< Amount resources.
\r
221 unsigned int UioMappingIndex; ///< With UIO driver, we are doing mmap on /dev/uioX;
\r
222 //for different mappings we just add Index*PAGESIZE as offset
\r
223 } HudaqResourceRange;
\r
227 * Resource information structure. Please note that every device has totally
\r
228 * different meaning of this structure.
\r
229 * @ingroup GroupConstants
\r
233 int NumMemResources; ///< Amount of memory mapped ranges in particular device.
\r
234 HudaqResourceRange MemResources[8]; ///< Memory resources available for user access.
\r
235 int NumIOResources; ///< Amount of IO ranges in particular device.
\r
236 HudaqResourceRange IOResources[8]; ///< IO resources available for user access.
\r
237 unsigned BusNumber;
\r
238 unsigned SlotNumber;
\r
242 } HudaqResourceInfo;
\r
245 /** Options for ::HudaqOpenDevice parameter options
\r
246 * @ingroup GroupConstants
\r
250 HudaqOpenRESET = 0, ///< Force initialization of hardware.
\r
251 HudaqOpenNOINIT = 1, ///< Skip initialization of device. Normally
\r
252 ///< you want initialization. This is reserved for multiple
\r
253 ///< access to device from different application or device enumeration.
\r
254 //HudaqOpenForceInit = 2
\r
255 } HudaqOpenOptions;
\r
257 /** @endcond UNDOCUMENTED */
\r
261 * Open a data acquisition device.
\r
262 * The device is put into initial state when being opened.
\r
263 * @ingroup GroupBoardInitialization
\r
264 * @param[in] devicename Device name.
\r
265 * This parameter is the device type as a string, for example "MF624".
\r
266 * @param[in] deviceorder Device order.
\r
267 * One-based index to distinguish between devices of identical type.
\r
268 * @param[in] options Reserved, must be zero.
\r
269 * @return Device handle or zero on failure.
\r
271 HUDAQLIBPUBLIC HUDAQHANDLE HUDAQAPI HudaqOpenDevice(const char* devicename, int deviceorder, int options);
\r
275 * Reset a data acquisition device.
\r
276 * This function puts the device into initial state.
\r
277 * @ingroup GroupBoardInitialization
\r
278 * @param[in] handle Device handle.
\r
279 * @return ::HUDAQSUCCESS on success, other values on failure.
\r
281 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqResetDevice(HUDAQHANDLE handle);
\r
285 * Close a data acquisition device handle.
\r
286 * The device handle becomes invalid after this call and must not be used any more.
\r
287 * The device state is not changed when its handle is closed. If it is required that the
\r
288 * device is set to a specific state before closing the application, it must be done explicitly
\r
289 * before calling this function.
\r
290 * @ingroup GroupBoardInitialization
\r
291 * @param[in] handle Device handle.
\r
293 HUDAQLIBPUBLIC void HUDAQAPI HudaqCloseDevice(HUDAQHANDLE handle);
\r
296 /** @cond UNDOCUMENTED */
\r
299 * Get device resources.
\r
300 * @ingroup GroupBoardInitialization
\r
301 * @param[in] handle Device handle.
\r
302 * @return Pointer to the resource information structure for the device, zero on error.
\r
304 HUDAQLIBPUBLIC const HudaqResourceInfo* HUDAQAPI HudaqGetDeviceResources(HUDAQHANDLE handle);
\r
306 /** @endcond UNDOCUMENTED */
\r
309 /** This procedure returns full device name. */
\r
310 HUDAQLIBPUBLIC const char* HUDAQAPI HudaqGetBoardName(HUDAQHANDLE handle);
\r
314 /** This procedure returns system handle to a kernel driver. */
\r
315 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqWaitForIrq(HUDAQHANDLE handle, int TimeOut);
\r
319 /** @cond UNDOCUMENTED */
\r
321 /** Possible values for HudaqAOUNITS. Used in both Analog inputs and Analog outputs channels.
\r
322 * See ::HudaqAIUNITS and ::HudaqAOUNITS.
\r
323 * @ingroup GroupChannelConfig
\r
327 HudaqAIOVolts = 0, ///< Use analog values in volts.
\r
328 HudaqAIORaw = 1 ///< Raw value of A/D converter.
\r
331 /** @endcond UNDOCUMENTED */
\r
336 * Read data from a single analog input channel.
\r
337 * @ingroup GroupAnalogInput
\r
338 * @param[in] handle Device handle.
\r
339 * @param[in] channel Analog input channel number.
\r
340 * @return Value read from the analog input channel.
\r
342 HUDAQLIBPUBLIC double HUDAQAPI HudaqAIRead(HUDAQHANDLE handle, unsigned channel);
\r
345 * Read data from multiple analog input channels.
\r
346 * The analog input channels are read with the minimum possible interval between individual
\r
347 * channels or simultaneously if the device supports this feature.
\r
348 * @ingroup GroupAnalogInput
\r
349 * @param[in] handle Device handle.
\r
350 * @param[in] number Number of channels to read.
\r
351 * @param[in] channels Array of channel numbers that will be read.
\r
352 * The array must contain the specified number of channel numbers.
\r
353 * @param[out] values Pointer to the array to be filled with values read from the analog input channels.
\r
354 * The array is allocated by the caller and must contain enough space to hold all the values read.
\r
355 * @return ::HUDAQSUCCESS on success, other values on failure.
\r
357 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqAIReadMultiple(HUDAQHANDLE handle, unsigned number, const unsigned* channels, double* values);
\r
361 * Write data to a single analog output channel.
\r
362 * @ingroup GroupAnalogOutput
\r
363 * @param[in] handle Device handle.
\r
364 * @param[in] channel Analog output channel number.
\r
365 * @param[in] value Value to write to the analog output channel.
\r
367 HUDAQLIBPUBLIC void HUDAQAPI HudaqAOWrite(HUDAQHANDLE handle, unsigned channel, double value);
\r
371 * Write data to multiple analog output channels.
\r
372 * The analog output channels are updated with the minimum possible interval between individual
\r
373 * channels or simultaneously if the device supports this feature.
\r
374 * @ingroup GroupAnalogOutput
\r
375 * @param[in] handle Device handle.
\r
376 * @param[in] number Number of channels to be written.
\r
377 * @param[in] channels Array of channel numbers that will be written.
\r
378 * The array must contain the specified number of channel numbers.
\r
379 * @param[in] values Array of values to be written to the analog output channels.
\r
380 * The array must contain the specified number of values.
\r
381 * @return ::HUDAQSUCCESS on success, other values on failure.
\r
383 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqAOWriteMultiple(HUDAQHANDLE handle, unsigned number, const unsigned* channels, const double* values);
\r
387 * Read a single bit from a digital input channel.
\r
388 * @ingroup GroupDigitalInput
\r
389 * @param[in] handle Device handle.
\r
390 * @param[in] channel Digital input channel number.
\r
391 * @param[in] bit Bit position in the channel.
\r
392 * @return Bit value read from the specified bit.
\r
394 HUDAQLIBPUBLIC int HUDAQAPI HudaqDIReadBit(HUDAQHANDLE handle, unsigned channel, unsigned bit);
\r
397 * Read data from a single digital input channel.
\r
398 * The number of bits in a digital input channel is device specific.
\r
399 * @ingroup GroupDigitalInput
\r
400 * @param[in] handle Device handle.
\r
401 * @param[in] channel Digital input channel number.
\r
402 * @return Value read from the digital input channel.
\r
404 HUDAQLIBPUBLIC int HUDAQAPI HudaqDIRead(HUDAQHANDLE handle, unsigned channel);
\r
407 * Read data from multiple digital input channels.
\r
408 * @ingroup GroupDigitalInput
\r
409 * @param[in] handle Device handle.
\r
410 * @param[in] number Number of channels to read.
\r
411 * @param[in] channels Array of channel numbers that will be read.
\r
412 * The array must contain the specified number of channel numbers.
\r
413 * @param[out] values Pointer to the array to be filled with values read from the digital input channels.
\r
414 * The array is allocated by the caller and must contain enough space to hold all the values read.
\r
415 * @return ::HUDAQSUCCESS on success, other values on failure.
\r
417 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqDIReadMultiple(HUDAQHANDLE handle, unsigned number, const unsigned* channels, unsigned* values);
\r
421 * Write data to a single bit of a digital output channel.
\r
422 * @ingroup GroupDigitalOutput
\r
423 * @param[in] handle Device handle.
\r
424 * @param[in] channel Digital output channel number.
\r
425 * @param[in] bit Bit position in channel specified
\r
426 * @param[in] value Bit value to be written to the specified bit.
\r
428 HUDAQLIBPUBLIC void HUDAQAPI HudaqDOWriteBit(HUDAQHANDLE handle, unsigned channel, unsigned bit, int value);
\r
431 * Write data to a single digital output channel.
\r
432 * The number of bits in a digital output channel is device specific.
\r
433 * @ingroup GroupDigitalOutput
\r
434 * @param[in] handle Device handle.
\r
435 * @param[in] channel Digital output channel number.
\r
436 * @param[in] value Value to be written into digital output.
\r
437 * @return ::HUDAQSUCCESS on success, other values on failure.
\r
439 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqDOWrite(HUDAQHANDLE handle, unsigned channel, unsigned value);
\r
442 * Modify multiple bits in a single digital output channel.
\r
443 * All the bits are modified simultaneously.
\r
444 * @ingroup GroupDigitalOutput
\r
445 * @param[in] handle Device handle.
\r
446 * @param[in] channel Digital output channel number.
\r
447 * @param[in] mask Mask that specifies bits that will be modified. Bits that are 1 will be assigned the corresponding bits of @c value,
\r
448 * bits that are 0 will be left untouched.
\r
449 * @param[in] value Value to write. Only the bits specified by @c mask are modified, the other bits are ignored.
\r
451 HUDAQLIBPUBLIC void HUDAQAPI HudaqDOWriteMultipleBits(HUDAQHANDLE handle, unsigned channel, unsigned mask, unsigned value);
\r
455 * Write data to multiple digital output channels.
\r
456 * @ingroup GroupDigitalOutput
\r
457 * @param[in] handle Device handle.
\r
458 * @param[in] number Number of channels to be written.
\r
459 * @param[in] channels Array of channel numbers that will be written.
\r
460 * The array must contain the specified number of channel numbers.
\r
461 * @param[in] values Array of values to be written to the digital output channels.
\r
462 * The array must contain the specified number of values.
\r
463 * @return ::HUDAQSUCCESS on success, other values on failure.
\r
465 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqDOWriteMultiple(HUDAQHANDLE handle, unsigned number, const unsigned* channels, const unsigned* values);
\r
469 * Counter clock sources.
\r
470 * @ingroup GroupChannelConfig
\r
474 HudaqCtrCLOCK50MHz = 0, ///< Internal clock 50MHz. (MF624 and MF625)
\r
475 HudaqCtrCLOCK10MHz = 1, ///< Internal clock 10MHz. (MF624 and MF625)
\r
476 HudaqCtrCLOCK1MHz = 2, ///< Internal clock 1MHz. (MF624 and MF625)
\r
477 HudaqCtrCLOCK100kHz = 3, ///< Internal clock 100kHz. (MF624 and MF625)
\r
478 HudaqCtrCLOCKINRISING = 5, ///< External input, count on rising edge. (MF614, MF624 and MF625)
\r
479 HudaqCtrCLOCKINFALLING = 6, ///< External input, count on falling edge.(MF614, MF624 and MF625)
\r
480 HudaqCtrCLOCKINEITHER = 7, ///< External input, count on either edge. (MF624 and MF625)
\r
481 HudaqCtrCLOCKPREVRISING = 9, ///< Output of previous counter, count on rising edge. (MF614, MF624 and MF625)
\r
482 HudaqCtrCLOCKPREVFALLING = 10, ///< Output of previous counter, count on falling edge. (MF614, MF624 and MF625)
\r
483 HudaqCtrCLOCKPREVEITHER = 11, ///< Output of previous counter, count on either edge. (MF624 and MF625)
\r
484 HudaqCtrCLOCKNEXTRISING = 13, ///< Output of next counter, count on rising edge. (MF624 and MF625)
\r
485 HudaqCtrCLOCKNEXTFALLING = 14, ///< Output of next counter, count on falling edge. (MF624 and MF625)
\r
486 HudaqCtrCLOCKNEXTEITHER = 15, ///< Output of next counter, count on either edge. (MF624 and MF625)
\r
487 HudaqCtrCLOCK20MHz, ///< Internal clock 20MHz. (MF614 only)
\r
488 HudaqCtrCLOCK2MHz, ///< Internal clock 2MHz. (MF614 only)
\r
489 HudaqCtrCLOCK200kHz, ///< Internal clock 200kHz. (MF614 only)
\r
490 HudaqCtrCLOCK20kHz, ///< Internal clock 20kHz. (MF614 only)
\r
491 HudaqCtrCLOCK2kHz ///< Internal clock 2kHz. (MF614 only)
\r
492 } HudaqCtrClockSource;
\r
496 * Counter output control.
\r
497 * @ingroup GroupChannelConfig
\r
501 HudaqCtrOUTPUTNORMAL = 0, ///< Normal counter output. (MF614 and MF624)
\r
502 HudaqCtrOUTPUTINVERTED = 1, ///< Inverted counter output. (MF624 only)
\r
503 HudaqCtrOUTPUT_0 = 2, ///< Force 0 on output, counter is still counting. (MF624 only)
\r
504 HudaqCtrOUTPUT_1 = 3 ///< Force 1 on output,counter is still counting. (MF624 only)
\r
505 } HudaqCtrOutputControl;
\r
509 * Counter trigger source.
\r
510 * @ingroup GroupChannelConfig
\r
514 HudaqCtrTRIGDISABLE = 0, ///< Trigger is disabled.
\r
515 HudaqCtrTRIGINPUT = 1, ///< Trigger by counter input (TxIn).
\r
516 HudaqCtrTRIGPREV = 2, ///< Trigger by previous counter output.
\r
517 HudaqCtrTRIGNEXT = 3 ///< Trigger by next counter output.
\r
518 } HudaqCtrTrigSource;
\r
522 * Counter trigger type.
\r
523 * @ingroup GroupChannelConfig
\r
527 HudaqCtrTRIGNONE = 0, ///< Trigger is inactive.
\r
528 HudaqCtrTRIGRISING = 1, ///< Trigger by rising edge of trigger signal.
\r
529 HudaqCtrTRIGFALLING = 2, ///< Trigger by falling edge of trigger signal.
\r
530 HudaqCtrTRIGEITHER = 3 ///< Trigger by either edge of trigger signal.
\r
531 } HudaqCtrTrigType;
\r
535 * Counter gate source. Please note ::HudaqCtrGATEPOLARITY for full undrestanding
\r
536 gate functionality.
\r
537 * @ingroup GroupChannelConfig
\r
541 HudaqCtrGATEHIGH = 0, ///< Gate is forced to logical high. (MF614, MF624 and MF625)
\r
542 HudaqCtrGATEINPUT = 1, ///< Gate by counter input (TxIn). (MF614, MF624 and MF625)
\r
543 HudaqCtrGATEPREV = 2, ///< Gate by previous counter output. (MF624 and MF625)
\r
544 HudaqCtrGATENEXT = 3 ///< Gate by next counter output. (MF624 and MF625)
\r
545 } HudaqCtrGateSource;
\r
549 * Reset counter pulse count.
\r
550 * If the counter hardware is used by another subsystem, it is switched to counting mode and
\r
551 * the default input is selected. If the counter is already in counting mode, its input selection
\r
553 * @ingroup GroupCounterInput
\r
554 * @param[in] handle Device handle.
\r
555 * @param[in] channel Number of counter channel.
\r
557 HUDAQLIBPUBLIC void HUDAQAPI HudaqCtrReset(HUDAQHANDLE handle, unsigned channel);
\r
561 * Read counter pulse count.
\r
562 * The returned value is the number of pulses counted by the counter since reset.
\r
563 * @ingroup GroupCounterInput
\r
564 * @param[in] handle Device handle.
\r
565 * @param[in] channel Counter input channel number.
\r
566 * @return Value read from the counter input channel.
\r
568 HUDAQLIBPUBLIC int HUDAQAPI HudaqCtrRead(HUDAQHANDLE handle, unsigned channel);
\r
571 /** Encoder counting modes.
\r
572 * @ingroup GroupChannelConfig
\r
576 HudaqEncMODEIRC = 0, ///< Count IRC pulses on inputs @a A and @a B (MF614, MF624 and MF625)
\r
577 HudaqEncMODERISING, ///< Count pulses on @a A, rising edge, @a B specifies direction (MF614, MF624 and MF625)
\r
578 HudaqEncMODEFALLING, ///< Count pulses on @a A, falling edge, @a B specifies direction (MF624 and MF625)
\r
579 HudaqEncMODEEITHER ///< Count pulses on @a A, either edge, @a B specifies direction (MF624 and MF625)
\r
583 /** Encoder count control.
\r
584 * Encoder count control allows enabling or disabling pulse counting based on software or hardware conditions.
\r
585 * @ingroup GroupChannelConfig
\r
589 HudaqEncCOUNTENABLE = 0, ///< Encoder counting is enabled. (MF614, MF624 and MF625)
\r
590 HudaqEncCOUNTDISABLE, ///< Encoder counting is disabled. (MF624 and MF625)
\r
591 HudaqEncCOUNTI0, ///< Encoder counting is enabled when input @a I is at logical low, disabled when input @a I is at logical high. (MF624 and MF625)
\r
592 HudaqEncCOUNTI1 ///< Encoder counting is enabled when input @a I is at logical high, disabled when input @a I is at logical low. (MF624 and MF625)
\r
593 } HudaqEncCountControl;
\r
596 /** Encoder reset mode.
\r
597 * Encoder reset mode allows enabling the functionality of resetting the encoder pulse count by external signal.
\r
598 * @ingroup GroupChannelConfig
\r
602 HudaqEncRESNONE = 0, ///< Encoder is not being reset by external signal. (MF614, MF624 and MF625)
\r
603 HudaqEncRESPERMANENT, ///< Encoder is permanently reset; the encoder does not count in this mode. (MF624 only)
\r
604 HudaqEncRESI0, ///< Reset encoder pulse count when input @a I is at logical low. (MF614, MF624 and MF625)
\r
605 HudaqEncRESI1, ///< Reset encoder pulse count when input @a I is at logical high. (MF624 and MF625)
\r
606 HudaqEncRESIRISING, ///< Reset encoder pulse count on rising edge of input @a I . (MF614, MF624 and MF625)
\r
607 HudaqEncRESIFALLING, ///< Reset encoder pulse count on falling edge of input @a I . (MF614, MF624 and MF625)
\r
608 HudaqEncRESIEITHER ///< Reset encoder pulse count on either edge of input @a I . (MF624 and MF625)
\r
609 } HudaqEncResetMode;
\r
614 * Reset encoder pulse count.
\r
615 * @ingroup GroupEncoderInput
\r
616 * @param[in] handle Device handle.
\r
617 * @param[in] channel Encoder input channel number.
\r
619 HUDAQLIBPUBLIC void HUDAQAPI HudaqEncReset(HUDAQHANDLE handle, unsigned channel);
\r
623 * Read encoder pulse count.
\r
624 * The returned value is the number of pulses counted by the encoder since reset.
\r
625 * @ingroup GroupEncoderInput
\r
626 * @param[in] handle Device handle.
\r
627 * @param[in] channel Encoder input channel number.
\r
628 * @return Value read from the encoder input channel.
\r
630 HUDAQLIBPUBLIC int HUDAQAPI HudaqEncRead(HUDAQHANDLE handle, unsigned channel);
\r
634 * Emergency PWM output shutdown could be set to the following mode. (MF625 only)
\r
638 HudaqPwmEMERGENCYOFF = 0, ///< No emergency is employed.
\r
639 HudaqPwmEMERGENCYINPUT, ///< Emergency input in '1' shuts all outputs to '0'.
\r
640 HudaqPwmEMERGENCYNOTINPUT, ///< Emergency input in '0' shuts all outputs to '0'.
\r
641 HudaqPwmEMERGENCYON, ///< All outputs are shut to '0' permanently.
\r
642 } HudaqPwmEmergency;
\r
646 * Generate pulse-width modulation signal on a counter output.
\r
647 * @ingroup GroupPWMOutput
\r
648 * @param[in] handle Device handle.
\r
649 * @param[in] channel Counter output channel number.
\r
650 * @param[in] frequency Output frequency in Hz.
\r
651 * @param[in] duty Output signal duty.
\r
652 * The duty is the fraction of signal period during which the signal is at high level.@n
\r
653 * Value 0 means permanent logical low on the counter output.@n
\r
654 * Value 0.5 means periodic signal with the counter output for half of the period at logical low and for half of the period at logical high.@n
\r
655 * Value 1 means permanent logical high on the counter output.@n
\r
656 * @return ::HUDAQSUCCESS on success, other values on failure.
\r
658 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqPWMWrite(HUDAQHANDLE handle, unsigned channel, double frequency, double duty);
\r
662 * Generate 3 phases + their inversions pulse-width modulation signal on a specialized counter.
\r
663 * @ingroup GroupPWMOutput
\r
664 * @param[in] handle Device handle.
\r
665 * @param[in] channel Counter output channel number.
\r
666 * @param[in] frequency Output frequency in Hz.
\r
667 * @param[in] duty1 Output signal duty for first phase.
\r
668 * @param[in] duty2 Output signal duty for second phase.
\r
669 * @param[in] duty3 Output signal duty for third phase.
\r
670 * The duty is the fraction of signal period during which the signal is at high level.@n
\r
671 * Value 0 means permanent logical low on the counter output.@n
\r
672 * Value 0.5 means periodic signal with the counter output for half of the period at logical low and for half of the period at logical high.@n
\r
673 * Value 1 means permanent logical high on the counter output.@n
\r
674 * @return ::HUDAQSUCCESS on success, other values on failure.
\r
676 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqPWM3Write(HUDAQHANDLE handle, unsigned channel, double frequency, double duty1, double duty2, double duty3);
\r
679 /** @cond UNDOCUMENTED */
\r
682 * Generate multiphase pulse-width modulation signal on a specialized PWM counter.
\r
683 * @ingroup GroupPWMOutput
\r
684 * @param[in] handle Device handle.
\r
685 * @param[in] channel Counter output channel number.
\r
686 * @param[in] phasenum Number of phases (sub channels) to be written.
\r
687 * @param[in] phases Array of phase numbers (sub channels) that will be written.
\r
688 * @param[in] frequency Output frequency in Hz (same for all phases).
\r
689 * @param[in] duties Array of output signal duties.
\r
690 * The duty is the fraction of signal period during which the signal is at high level.@n
\r
691 * Value 0 means permanent logical low on the counter output.@n
\r
692 * Value 0.5 means periodic signal with the counter output for half of the period at logical low and for half of the period at logical high.@n
\r
693 * Value 1 means permanent logical high on the counter output.@n
\r
694 * @return ::HUDAQSUCCESS on success, other values on failure.
\r
696 HUDAQLIBPUBLIC HUDAQSTATUS HudaqPWMWriteMultiphase(HUDAQHANDLE handle, unsigned channel, unsigned phasenum, const unsigned *phases, double frequency, const double *duties);
\r
699 * Move stepping motor to a target position. During a first time call it resets internal
\r
700 * position counter and sets 2 internal counters for driving one stepper motor.
\r
701 * @ingroup GroupStepperOutput
\r
702 * @param[in] handle Device handle.
\r
703 * @param[in] channel number of counter.
\r
704 * @param[in] position Target position to move stepping motor. (It is absolute position, not a difference.)
\r
705 * @return ::HUDAQSUCCESS on success, other values on failure.
\r
707 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqStepWrite(HUDAQHANDLE handle, unsigned channel, int position);
\r
709 /** @endcond UNDOCUMENTED */
\r
714 * Reads single channel configuration for a given subsystem.
\r
715 * Not all devices support all the parameters.
\r
716 * @ingroup GroupChannelConfig
\r
717 * @param[in] handle Device handle.
\r
718 * @param[in] channel Channel number. The channel type is determined by the parameter identifier @c param.
\r
719 * @param[in] param Parameter identifier; see ::HudaqParameter for possible values.
\r
720 * @return value Value of the parameter; see individual parameter descriptions for description of the values.
\r
722 HUDAQLIBPUBLIC double HUDAQAPI HudaqGetParameter(HUDAQHANDLE handle, unsigned channel, HudaqParameter param);
\r
726 * Configures single channel of a given subsystem.
\r
727 * Not all devices support all the parameters and all the parameter values.
\r
728 * @ingroup GroupChannelConfig
\r
729 * @param[in] handle Device handle.
\r
730 * @param[in] channel Channel number. The channel type is determined by the parameter identifier @c param.
\r
731 * @param[in] param Parameter identifier; see ::HudaqParameter for possible values.
\r
732 * @param[in] value Value of the parameter; see individual parameter descriptions for possible values.
\r
733 * @return ::HUDAQSUCCESS on success, other values on failure.
\r
735 HUDAQLIBPUBLIC HUDAQSTATUS HUDAQAPI HudaqSetParameter(HUDAQHANDLE handle, unsigned channel, HudaqParameter param, double value);
\r
739 * Query voltage ranges by their indices.
\r
740 * This function translates the voltage range index to actual voltage range limits for the device.
\r
741 * No change is done to device configuration; use ::HudaqSetParameter to set a voltage range by its index; use
\r
742 * ::HudaqGetParameter to get the index of the currently set voltage range.
\r
744 * @ingroup GroupChannelConfig
\r
745 * @param[in] handle Device handle.
\r
746 * @param[in] S Subsystem identifier; possible values are ::HudaqAI or ::HudaqAO.
\r
747 * @param[in] item Zero-based voltage range index.
\r
748 * @return Pointer to a structure containing the voltage range limits for the specified index, or @c NULL for an invalid range index.
\r
749 * The structure pointed to by the returned pointer is defined like this:
\r
758 HUDAQLIBPUBLIC const HudaqRange * HUDAQAPI HudaqQueryRange(HUDAQHANDLE handle, HudaqSubsystem S, unsigned item);
\r
762 /* All the functions have C naming convention in C++. */
\r
765 #endif /* __cplusplus */
\r
768 #endif /* HUDAQLIB_H__ */
\r