control for DAC AD5384 for the SOLID SM1 Slow Control

Dependents:   SPItest sscm

Files at this revision

API Documentation at this revision

Comitter:
wbeaumont
Date:
Thu Jan 29 11:03:56 2015 +0000
Parent:
4:bc9ab300ab26
Commit message:
i n calculation corrected gain+1 to gain+2

Changed in this revision

AD5384.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r bc9ab300ab26 -r 477603ce54a0 AD5384.cpp
--- a/AD5384.cpp	Thu Oct 23 17:14:58 2014 +0000
+++ b/AD5384.cpp	Thu Jan 29 11:03:56 2015 +0000
@@ -24,9 +24,10 @@
  * v1.24  added update shadow registers
  * v1.26  corrected mask for reading register value
  * v1.30  added get voltage
+  *V1.31  corrected gain+1  to gain+2 in calculate_dac_setting
  */
 
-#define AD5384_SRC_VERSION "1.26"
+#define AD5384_SRC_VERSION "1.31"
 
 #define  M_DATA_R  0x3
 #define  M_OFFS_R  0x2 
@@ -113,7 +114,7 @@
                 float x2= vout * (float)p2_14 /(2 *vref);
     //  x2 = [(gain+2)/2^n * x1] + offset-2^13               
     // x1 = 2^14/(gain+2) *  [ x2 - offset+2^13 ]
-                u16 x1 = (float)p2_14/((float)gain[nr]+1) *( x2- offset[nr]+p2_13);
+                u16 x1 = (float)p2_14/((float)gain[nr]+2) *( x2- offset[nr]+p2_13);
                 x1= 0x3FFF & x1;
                 dacr[nr]=x1 ;
                 return x1;