]> rtime.felk.cvut.cz Git - mf6xx.git/blobdiff - src/HuLinux-2.4.3/samples/AnalogOut/AOWriteMultiple.c
Merge branch 'hudaqlib_mf614_uio'
[mf6xx.git] / src / HuLinux-2.4.3 / samples / AnalogOut / AOWriteMultiple.c
diff --git a/src/HuLinux-2.4.3/samples/AnalogOut/AOWriteMultiple.c b/src/HuLinux-2.4.3/samples/AnalogOut/AOWriteMultiple.c
new file mode 100644 (file)
index 0000000..d062c78
--- /dev/null
@@ -0,0 +1,43 @@
+/* Humusoft data acquisition library.\r
+ *\r
+ * Example that shows writing to analog output channels\r
+ * using the function to write multiple channels together.\r
+ */\r
+\r
+/* Copyright 2002-2006 Humusoft s.r.o. */\r
+\r
+#include <stdio.h>\r
+\r
+#include "hudaqlib.h"\r
+\r
+\r
+int main(int argc, char* argv[])\r
+{\r
+       HUDAQHANDLE h;\r
+       /* Buffer for channel numbers. Order of channels is not signifficant.\r
+          Duplicated channels are also supported. */\r
+       unsigned channels[8] = {4,5,6,7,0,1,2,3};\r
+       /* Buffer that contains values to be written.\r
+          Is size must correspond to buffer of channels. */\r
+       double values[8] = {5.0, 6.0, 7.0, 8.0, 1.0, 2.0, 3.0, 4.0};\r
+\r
+       /* Open a handle to the first MF624 device in the system. */\r
+       h = HudaqOpenDevice("MF624", 1, 0);\r
+       if (h==0)\r
+       {\r
+               printf("\nData acquisition device not found.\n");\r
+               return(-1);\r
+       }\r
+\r
+       /* Write all the 8 analog outputs in one call. */\r
+       if(HudaqAOWriteMultiple(h, 8, channels, values)==HUDAQSUCCESS)\r
+       {\r
+               printf("\nData has been written.\n");\r
+       }\r
+\r
+       /* Close the device handle. */\r
+       HudaqCloseDevice(h);\r
+\r
+       return(0);\r
+}\r
+\r