]> rtime.felk.cvut.cz Git - mf6xx.git/blob - src/HuLinux-2.4.3/samples/AnalogOut/AOWrite.c
Initial commit; HuLinux ver. 2.4.3; All files auto-indented
[mf6xx.git] / src / HuLinux-2.4.3 / samples / AnalogOut / AOWrite.c
1 /* Humusoft data acquisition library.\r
2  * Example that shows writing to analog output channels\r
3  * using the function to write a single channel.\r
4  */\r
5 \r
6 /* Copyright 2002-2007 Humusoft s.r.o. */\r
7 \r
8 #include <stdio.h>\r
9 \r
10 #include "hudaqlib.h"\r
11 \r
12 \r
13 int main(int argc, char* argv[])\r
14 {\r
15         HUDAQHANDLE h;\r
16         unsigned i;\r
17         double value;\r
18 \r
19         /* open a handle to the first MF624 device in the system */\r
20         h = HudaqOpenDevice("MF624", 1, 0);\r
21         if (h==0)\r
22         {\r
23                 printf("\nData acquisition device not found.\n");\r
24                 return(-1);\r
25         }\r
26 \r
27         /* write all the 8 analog outputs in a loop */\r
28         /* the voltage written to the output is computed as (channel number - 5) */\r
29         for (i=0; i<8; i++)\r
30         {\r
31                 value = i-5.0;\r
32                 HudaqAOWrite(h, i, value);\r
33                 printf("Analog output channel %d, value written %fV.\n", i, value);\r
34         }\r
35 \r
36         /* close the device handle */\r
37         HudaqCloseDevice(h);\r
38 \r
39         return(0);\r
40 }\r
41 \r