DAS  3.1.6 - 18/09/2017
Macros | Functions | Variables
Dscad.c File Reference

DMM procedures. More...

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>
#include "mgui.h"
#include "DAS_Spatram.h"
#include "dscud.h"
+ Include dependency graph for Dscad.c:

Go to the source code of this file.

Macros

#define ERROR_PREFIX   "DMM Driver ERROR:"
 

Functions

int D_InitPC104 (void)
 Starting function that calls the driver functions used NOTE: By convention, you should capture the BYTE return value for each driver API call, and check the error code. I. Driver Initialization II. Board Initialization III. AD Settings. More...
 
void D_readtemp_int (void)
 
void D_rt (void)
 D_readtemp_int callback
. More...
 
void DSCAD_Error (char *err, int w)
 

Variables

DSCADSCAN dscadscan
 
DSCADSETTINGS dscadsettings
 
DSCAIOINT dscaioint
 
DSCB dscb
 
DSCCB dsccb
 
DSCS dscs
 
ERRPARAMS errorParams
 
int Incr_Read_Temp
 
omuthr OMUTHR
 
BYTE result
 
WORDsamples
 
double voltage
 

Detailed Description

DMM procedures.

Author
Diamond Systems Corporation modified by Danbo

Definition in file Dscad.c.

Macro Definition Documentation

§ ERROR_PREFIX

#define ERROR_PREFIX   "DMM Driver ERROR:"

Definition at line 21 of file Dscad.c.

Function Documentation

§ D_InitPC104()

int D_InitPC104 ( void  )

Starting function that calls the driver functions used NOTE: By convention, you should capture the BYTE return value for each driver API call, and check the error code. I. Driver Initialization II. Board Initialization III. AD Settings.

Definition at line 120 of file Dscad.c.

Referenced by D_readtemp_int(), and InitTempAD().

121 {
122  //=========================================================================
123  // I. DRIVER INITIALIZATION
124  //
125  // Initializes the DSCUD library.
126  //
127  // Initialize the driver, using the driver version for validation
128  //=========================================================================
129 
130  if( dscInit( DSC_VERSION ) != DE_NONE )
131  {
134  return 1;
135  }
136 
137  //=========================================================================
138  // II. BOARD INITIALIZATION
139  //
140  // Initialize the DMM board. This function passes the various
141  // hardware parameters to the driver and resets the hardware.
142  //
143  //=========================================================================
144 
146  dsccb.base_address = 0x300;
147  dsccb.int_level = 3;
148  dsccb.dma_level = 3;
149  dsccb.clock_freq = 1000000;
150 
152  {
155  return 1;
156  }
157 
158  //=========================================================================
159  // III. AD SETTINGS INITIALIZATION
160  //
161  // Initialize the structure containing the AD conversion settings and
162  // then pass it to the driver.
163  //
164  //=========================================================================
165 
166  // PRE-FILLED EXAMPLE
172 
173  if( ( result = dscADSetSettings( dscb, &dscadsettings ) ) != DE_NONE )
174  {
177  return 2;
178  }
179 
180  //=========================================================================
181  // IV. AD SCAN INITIALIZATION
182  //
183  // Initialize the structure containing the AD scan setting and allocate
184  // memory for our buffer containing sample values.
185  //
186  //=========================================================================
187 
188  // PRE-FILLED EXAMPLE
190  dscadscan.high_channel = 15;
192 
193  samples = (WORD*)malloc( sizeof( WORD ) * ( dscadscan.high_channel - dscadscan.low_channel + 1 ) );
194 
195  return 0;
196 
197 }
DSCADSCAN dscadscan
Definition: Dscad.c:34
void DSCAD_Error(char *err, int w)
Definition: Dscad.c:48
WORD * samples
Definition: Dscad.c:35
WORD base_address
Definition: DSCUD.H:353
BYTE DSCUDAPICALL dscADSetSettings(DSCB board, DSCADSETTINGS *settings)
BYTE range
Definition: DSCUD.H:433
BYTE current_channel
Definition: DSCUD.H:431
BYTE DSCUDAPICALL dscGetLastError(ERRPARAMS *errparams)
BYTE polarity
Definition: DSCUD.H:434
ERRPARAMS errorParams
Definition: Dscad.c:37
#define DSC_VERSION
Definition: DSCUD.H:155
BYTE load_cal
Definition: DSCUD.H:435
DSCCB dsccb
Definition: Dscad.c:32
char * errstring
Definition: DSCUD.H:479
#define WORD
Definition: DSCUD.H:65
BYTE dma_level
Definition: DSCUD.H:354
BYTE DSCUDAPICALL dscInitBoard(BYTE boardtype, DSCCB *dsccb, DSCB *board)
LONG clock_freq
Definition: DSCUD.H:355
#define GAIN_1
Definition: DSCUD.H:195
DSCB dscb
Definition: Dscad.c:31
BYTE gain
Definition: DSCUD.H:432
BYTE boardtype
Definition: DSCUD.H:346
BYTE gain
Definition: DSCUD.H:451
#define DE_NONE
Definition: DSCUD.H:273
DSCADSETTINGS dscadsettings
Definition: Dscad.c:33
#define RANGE_5
Definition: DSCUD.H:189
BYTE low_channel
Definition: DSCUD.H:448
#define UNIPOLAR
Definition: DSCUD.H:193
BYTE result
Definition: Dscad.c:30
BYTE high_channel
Definition: DSCUD.H:449
#define TRUE
Definition: DSCUD.H:105
#define BYTE
Definition: DSCUD.H:55
#define DSC_DMM
Definition: DSCUD.H:165
BYTE int_level
Definition: DSCUD.H:360
BYTE DSCUDAPICALL dscInit(WORD version)
+ Here is the caller graph for this function:

§ D_readtemp_int()

void D_readtemp_int ( void  )

Definition at line 71 of file Dscad.c.

References omuthr::ADVolt, DSCCB::base_address, BIPOLAR, DSCCB::boardtype, BYTE, DSCCB::clock_freq, DSCADSETTINGS::current_channel, D_InitPC104(), DE_NONE, DSCCB::dma_level, DSC_DMM, DSC_VERSION, DSCAD_Error(), dscADScan(), dscADSetSettings(), dscb, dscGetLastError(), dscInit(), dscInitBoard(), ERRPARAMS::errstring, DSCADSETTINGS::gain, DSCADSCAN::gain, GAIN_1, DSCADSCAN::high_channel, DSCCB::int_level, DSCADSETTINGS::load_cal, DSCADSCAN::low_channel, DSCADSETTINGS::polarity, DSCADSETTINGS::range, RANGE_10, RANGE_5, result, DSCADSCAN::sample_values, samples, TRUE, UNIPOLAR, voltage, and WORD.

Referenced by D_rt().

72 {
73 
74  int i;
75 //=========================================================================
76 // V. SCANNING AND OUTPUT
77 //
78 // Perform the actual sampling and then output the results. To calculate
79 // the actual input voltages, we must convert the sample code (which
80 // must be cast to a short to get the correct code) and then plug it
81 // into one of the formulas located in the manual for your board (under
82 // "A/D Conversion Formulas").
83  //=========================================================================
84 
85 
86  if( ( result = dscADScan( dscb, &dscadscan, samples ) ) != DE_NONE )
87  {
88 // fprintf( stderr, "%s%s\n", ERROR_PREFIX, dscGetErrorString( result ) );
89 // free( samples ); // remember to deallocate malloc() memory
90 // return;
91  }
92 
93  for( i = dscadscan.low_channel; i < dscadscan.high_channel + 1; i++)
94  {
96  {
97  voltage = ((short)dscadscan.sample_values[i] / 2048.0 * 10.0) - 10.0;
98  }
100  {
101  voltage = ((short)dscadscan.sample_values[i] / 2048.0 * 5.0 ) - 5.0;
102  }
104  voltage = ( (short)dscadscan.sample_values[i] / 4096.0) * 5.0;
105  else voltage = ( (short)dscadscan.sample_values[i] / 4096.0) * 10.0;
106 
107  OMUTHR.ADVolt[i] = (voltage / pow(2, dscadsettings.gain));
108  }
109 }
DSCADSCAN dscadscan
Definition: Dscad.c:34
WORD * samples
Definition: Dscad.c:35
BYTE range
Definition: DSCUD.H:433
#define RANGE_10
Definition: DSCUD.H:190
BYTE polarity
Definition: DSCUD.H:434
double voltage
Definition: Dscad.c:36
DSCB dscb
Definition: Dscad.c:31
BYTE gain
Definition: DSCUD.H:432
omuthr OMUTHR
Definition: Dscad.c:43
#define DE_NONE
Definition: DSCUD.H:273
DSCADSETTINGS dscadsettings
Definition: Dscad.c:33
#define RANGE_5
Definition: DSCUD.H:189
BYTE low_channel
Definition: DSCUD.H:448
#define UNIPOLAR
Definition: DSCUD.H:193
BYTE result
Definition: Dscad.c:30
BYTE DSCUDAPICALL dscADScan(DSCB board, DSCADSCAN *dscadscan, DSCSAMPLE *sample_values)
BYTE high_channel
Definition: DSCUD.H:449
#define BIPOLAR
Definition: DSCUD.H:192
double ADVolt[16]
PC104 AD samples reading array.
DSCSAMPLE * sample_values
Definition: DSCUD.H:450
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ D_rt()

void D_rt ( void  )

D_readtemp_int callback
.

Starting function that calls the driver functions used
.

Returns
er:
  • 0 = initialization succesfully concluded
  • 1 = problems in driver initialization
  • 2 = problems in hardware initialization

Definition at line 64 of file Dscad.c.

References D_readtemp_int().

Referenced by D_readtemp().

65 {
66 
68 
69 }
void D_readtemp_int(void)
Definition: Dscad.c:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DSCAD_Error()

void DSCAD_Error ( char *  err,
int  w 
)

Definition at line 48 of file Dscad.c.

References palette::DB_BG, palette::DB_BG_Albl, palette::DB_FG_Albl, DPAL, HELV_SMALL, lbl, MCreateLabel(), MCreateShell(), MObjectSetBackgroundRGB(), MObjectSetForegroundRGB(), MObjectSetShadow(), MShellRealize(), and WS_SHADOW_OUT.

Referenced by D_readtemp_int().

49 {
50  MOBJECT sh, lbl;
51  char buf[64];
52  sh = MCreateShell("AD Error", 0);
54 
55  sprintf(buf, "%d ) %s",w, err);
56  lbl = MCreateLabel(sh, buf, HELV_SMALL);
59  MObjectSetShadow(lbl, WS_SHADOW_OUT, 1, 0);
60  MShellRealize(sh);
61 }
void MObjectSetBackgroundRGB(MOBJECT obj, int r, int g, int b)
MOBJECT lbl
Definition: DFileMan.c:42
void MObjectSetShadow(MOBJECT obj, int type, int in, int out)
void MShellRealize(MOBJECT obj)
MOBJECT MCreateLabel(MOBJECT parent, const char *text, MTFont font)
short DB_BG_Albl[3]
Background ACTIVE Label Colors.
palette DPAL
Definition: 2DPlot.c:27
#define HELV_SMALL
Definition: Mguidefs.h:881
short DB_FG_Albl[3]
Foreground ACTIVE Label Colors.
MOBJECT MCreateShell(const char *title, int flags)
short DB_BG[3]
Default Background Color.
void * MOBJECT
Definition: Mguidefs.h:192
void MObjectSetForegroundRGB(MOBJECT obj, int r, int g, int b)
#define WS_SHADOW_OUT
Definition: Mguidefs.h:957
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

§ dscadscan

DSCADSCAN dscadscan

Definition at line 34 of file Dscad.c.

§ dscadsettings

DSCADSETTINGS dscadsettings

Definition at line 33 of file Dscad.c.

§ dscaioint

DSCAIOINT dscaioint

Definition at line 40 of file Dscad.c.

§ dscb

DSCB dscb

Definition at line 31 of file Dscad.c.

Referenced by D_readtemp_int(), and ShutCB().

§ dsccb

DSCCB dsccb

Definition at line 32 of file Dscad.c.

§ dscs

DSCS dscs

Definition at line 41 of file Dscad.c.

§ errorParams

ERRPARAMS errorParams

Definition at line 37 of file Dscad.c.

§ Incr_Read_Temp

int Incr_Read_Temp

Definition at line 101 of file DAS_Spat.c.

§ OMUTHR

omuthr OMUTHR

Definition at line 43 of file Dscad.c.

§ result

BYTE result

Definition at line 30 of file Dscad.c.

Referenced by D_readtemp_int(), and DB_FindChar().

§ samples

WORD* samples

Definition at line 35 of file Dscad.c.

Referenced by D_readtemp_int().

§ voltage

double voltage

Definition at line 36 of file Dscad.c.

Referenced by D_readtemp_int().

______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:45:03 for DAS - Rel. 3.1.6 - 18/09/2017.