Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

ppmc_dac.c File Reference

#include "ppmc.h"

Include dependency graph for ppmc_dac.c:

Include dependency graph

Go to the source code of this file.

Functions

__inline unsigned short VoltToCounts (double volts)
int RawDAC (int nAxis, double volts)
short DACInit (void)
short DACQuit (void)
int ppmcDacNum (void)
int ppmcDacWrite (int dac, double volts)
int ppmcDacWriteAll (int max, double *volts)


Function Documentation

short DACInit void   
 

Definition at line 57 of file ppmc_dac.c.

00058 {
00059         SelWrt(DAC_WRITE_0,0);    // reset strobe
00060         SelWrt(DAC_MODE_0,0);     // sel strobe to INTR/ line
00061         return 0;
00062 }

short DACQuit void   
 

Definition at line 64 of file ppmc_dac.c.

00065 {
00066            return DACInit();  //init sets all outputs to zero
00067 }

int RawDAC int    nAxis,
double    volts
 

Definition at line 34 of file ppmc_dac.c.

00035 {
00036   
00037 
00038   if ( (nAxis > PPMC_MAX_AXIS) || (nAxis < 0) )        /* is axis within range? */
00039     return -1;
00040 
00041   /* convert -10.0 -> 0,0 to 0x8000 10 -> 0xFFFF */
00042   
00043   if (nAxis <=3)
00044    {
00045     SelWrt16(DAC_0 + (nAxis << 1), VoltToCounts(volts));
00046         SelWrt(DAC_WRITE_0, 0);
00047    }
00048   else {
00049     SelWrt16(DAC_4 + ((nAxis-4) << 1), VoltToCounts(volts));
00050         SelWrt(DAC_WRITE_1, 0);
00051   }
00052         
00053         
00054   return 0;
00055 }

__inline unsigned short VoltToCounts double    volts
 

Definition at line 18 of file ppmc_dac.c.

Referenced by RawDAC(), and ppmcDacWriteAll().

00019 {
00020         long nCounts;
00021         nCounts = (long) (((volts / 10.0) * 0x7FFF)+0x8000);
00022 
00023         if (nCounts > 0xffff)
00024     {
00025       nCounts = 0xffff;
00026     }
00027         if (nCounts < 0 )
00028     {
00029       nCounts = 0;
00030     }
00031         return (unsigned short)nCounts;
00032 }

int ppmcDacNum void   
 

Definition at line 68 of file ppmc_dac.c.

Referenced by extDacNum().

00069 {
00070         return PPMC_MAX_AXIS;
00071 }

int ppmcDacWrite int    dac,
double    volts
 

Definition at line 73 of file ppmc_dac.c.

Referenced by extDacWrite(), and main().

00074 {
00075   return RawDAC(dac, volts);
00076 }

int ppmcDacWriteAll int    max,
double *    volts
 

Definition at line 78 of file ppmc_dac.c.

Referenced by extDacWriteAll(), and main().

00079 {
00080         int t;
00081   int smax;
00082  
00083   /* clip smax to max supported-- if they want more, ignore */
00084   if (max > PPMC_MAX_AXIS) {
00085     smax = PPMC_MAX_AXIS;
00086   }
00087   else {
00088     smax = max;
00089   }
00090 #ifndef PPMC_8_AXIS
00091   //take advantage of auto increment of address pointer in ppmc
00092         SelAddr(DAC_0);
00093         for (t = 0; t < smax; t++)
00094         {
00095   /*      printf(" dac channel %d volts %12.4f   digital # %d\n",
00096           t,volts[t],VoltToCounts(volts[t]));  */
00097                 WriteData16(VoltToCounts(volts[t]));
00098     }
00099         /*      printf("\n");  */
00100 #else
00101         SelAddr(DAC_0);
00102         if(smax<=4)
00103         {
00104            for (t = 0; t < smax; t++)
00105              {
00106                 WriteData16(VoltToCounts(volts[t]));
00107              }
00108            return 0;
00109         }
00110         else
00111         {
00112           for (t = 0; t < 4; t++)
00113             {
00114               WriteData16(VoltToCounts(volts[t]));
00115             }
00116           SelAddr(DAC_1);
00117           for (t = 4; t < smax; t++)
00118             {
00119                 WriteData16(VoltToCounts(volts[t]));
00120             }
00121     }
00122 #endif
00123   return 0;
00124 }


Generated on Sun Dec 2 15:28:11 2001 for EMC by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001