]> rtime.felk.cvut.cz Git - mf6xx.git/blob - src/HuLinux-2.4.3/samples/AnalogOut/AOWriteMultiple.c
Added a few comments. Cleaned coding style.
[mf6xx.git] / src / HuLinux-2.4.3 / samples / AnalogOut / AOWriteMultiple.c
1 /* Humusoft data acquisition library.\r
2  *\r
3  * Example that shows writing to analog output channels\r
4  * using the function to write multiple channels together.\r
5  */\r
6 \r
7 /* Copyright 2002-2006 Humusoft s.r.o. */\r
8 \r
9 #include <stdio.h>\r
10 \r
11 #include "hudaqlib.h"\r
12 \r
13 \r
14 int main(int argc, char* argv[])\r
15 {\r
16         HUDAQHANDLE h;\r
17         /* Buffer for channel numbers. Order of channels is not signifficant.\r
18            Duplicated channels are also supported. */\r
19         unsigned channels[8] = {4,5,6,7,0,1,2,3};\r
20         /* Buffer that contains values to be written.\r
21            Is size must correspond to buffer of channels. */\r
22         double values[8] = {5.0, 6.0, 7.0, 8.0, 1.0, 2.0, 3.0, 4.0};\r
23 \r
24         /* Open a handle to the first MF624 device in the system. */\r
25         h = HudaqOpenDevice("MF624", 1, 0);\r
26         if (h==0)\r
27         {\r
28                 printf("\nData acquisition device not found.\n");\r
29                 return(-1);\r
30         }\r
31 \r
32         /* Write all the 8 analog outputs in one call. */\r
33         if(HudaqAOWriteMultiple(h, 8, channels, values)==HUDAQSUCCESS)\r
34         {\r
35                 printf("\nData has been written.\n");\r
36         }\r
37 \r
38         /* Close the device handle. */\r
39         HudaqCloseDevice(h);\r
40 \r
41         return(0);\r
42 }\r
43 \r