source: multiio/pcmmio/original/dacbuff.c @ da59d43

Last change on this file since da59d43 was 2bae2aa, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 8, 2009 at 2:52:43 PM

Initial import.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/* dacbuff.c Demonstration program for WinSystems PCM-MIO Driver */
2
3/*
4*
5* $Header$
6*
7* $Id$
8*
9* $Log$
10*
11*       Compile with :
12*
13*               gcc dacbuff.c kbhit.c mio_io.o -o dacbuff
14*
15*
16*       This program demonstrates the adc_buffered_channel_conversions function
17*       which allows for a programmed sequence of conversions to be accomplished
18*       with a single call.
19*
20*/
21
22
23#include "mio_io.h"   
24#include <stdio.h>
25#include <stdlib.h>
26
27// This array will store the results of 2000 conversions
28
29unsigned char commands[16385];
30unsigned short values[16384];
31
32void init_keyboard(void);
33void close_keyboard(void);
34int kbhit(void);
35int readch(void);
36
37
38int main(int argc, char* argv[])
39{
40unsigned x;
41
42
43        // Set all 8 DAC outputs to a known span +/- 10V
44
45        for(x=0; x<8; x++)
46                {
47                        set_dac_span(x, DAC_SPAN_BI10);
48                        if(mio_error_code)
49                        {
50                                printf("\n%s\n",mio_error_string);
51                                exit(1);
52                        }
53                }
54
55
56        // For this program we are going to use only channel 0
57        //   with 16384 updates.
58       
59
60        // The data will step up from -10V to +10V in 4/65536 increments
61
62        for(x = 0; x < 16384; x++)
63        {
64            commands[x] = 0;
65            values[x] = x * 4;
66        }
67
68        /* We need to terminate the command so that it knows when its done */
69
70        commands[16384] = 0xff;
71
72 
73        /* This program runs until a key is pressed. It prints nothing
74           on the screen to keep from slowing it down. To see the results
75           it would be necessary to attach an oscilloscope to DAC channel
76           0.
77        */
78
79                init_keyboard();
80
81                printf("DACBUFF running - press any key to exit\n");
82
83        while(!kbhit())
84        {
85
86            /* This command returns when all 16,384 samples have been
87               sent to the DAC as fast as possible
88            */
89
90            buffered_dac_output(commands,values);
91                        if(mio_error_code)
92                        {
93                                printf("\n%s\n",mio_error_string);
94                                exit(2);
95                        }
96
97 
98        }
99
100        readch();
101                close_keyboard();
102                return 0;
103}
104
Note: See TracBrowser for help on using the repository browser.