]> rtime.felk.cvut.cz Git - mf6xx.git/blob - src/hudaqlib/samples/PWMOut/PWM6Write.c
Changed some directory names for easier understanding.
[mf6xx.git] / src / hudaqlib / samples / PWMOut / PWM6Write.c
1 /* Humusoft data acquisition library.
2  *
3  * Example that shows using multiphase PWM output channel.
4  * This example works on MF625 only!
5  */
6
7 /* Copyright 2002-2007 Humusoft s.r.o. */
8
9 #include <stdio.h>
10
11 #include "hudaqlib.h"
12
13
14 int main(int argc, char* argv[])
15 {
16         HUDAQHANDLE h;
17         unsigned phases[] =  {  0,  1,  2,  3,  4,  5};
18         double duties[] =    {0.2,0.4,0.5,0.6,0.7,0.8};
19
20         double d[]= {1,1.05,1.1,1,1,1};
21
22         /* open a handle to the first MF625 device in the system */
23         h = HudaqOpenDevice("MF625", 1, 0);
24         if (h==0)
25         {
26                 printf("\nData acquisition device MF625 not found.\n");
27                 return(-1);
28         }
29
30         /* set the first PWM channel to frequency 2.5kHz with duty cycles 0.1 0.5 0.9 */
31         HudaqPWMWriteMultiphase(h, 0, 6, phases, 2500, duties);
32
33         //HudaqSetParameter(h, 0, HudaqPwmCLOCKSOURCE, HudaqCtrCLOCKINFALLING);
34         //HudaqSetParameter(h, 0, HudaqPwmFILTER, 0);
35
36         HudaqPWMWriteMultiphase(h, 0, 6, phases, 12000000 /*0.005*/, d);
37
38         /* close the device handle */
39         HudaqCloseDevice(h);
40
41         return(0);
42 }
43