Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Lithium ION
Published © GPL3+

Interfacing 15 Bit DAC with Arduino

New GP8211S series high resolution DAC with Arduino Kills the competition.

IntermediateFull instructions provided1 hour105
Interfacing 15 Bit DAC with Arduino

Things used in this project

Software apps and online services

Arduino IDE
Arduino IDE
pcbway

Story

Read more

Code

Arbitrary wave

Arduino
#include <DFRobot_GP8XXX.h>

DFRobot_GP8211S GP8211S;

void setup() {

  Serial.begin(9600);

  while(GP8211S.begin()!=0){
    Serial.println("Connection Failed!");
    delay(1000);
  }
  GP8211S.setDACOutRange(GP8211S.eOutputRange5V);
 //GP8211S.setDACOutRange(GP8211S.eOutputRange5V);

  delay(100);

  //Save the set voltage in the chip's internal memory for power loss recovery.
  //GP8211S.store();
}

void loop() { // 15 BIT RES give total steps of 32767 and A Voltage resolution of 152uV at 5volts Vref. 
  GP8211S.setDACOutVoltage(6553);     // 1V 
  delay(1000);
  GP8211S.setDACOutVoltage(13106);    // 2V
  delay(1000);
  GP8211S.setDACOutVoltage(19660);    // 3V
  delay(1000);
  GP8211S.setDACOutVoltage(26213);    // 4V
  delay(1000);
  GP8211S.setDACOutVoltage(32767);    // 5V
  delay(1000); 
}

15bit_1000samples

Arduino
#include <DFRobot_GP8XXX.h>
DFRobot_GP8211S GP8211S;
//1000 samples 15 bit amplitude
const PROGMEM uint16_t DACLookup_FullSine_15Bit[1000] =
{
16383, 16486, 16589, 16692, 16795, 16898, 17000, 17103, 17206, 17309, 17412, 17514, 17617, 17720, 17822, 17925, 18027, 18130, 18232, 18334, 18436, 18538, 18640, 18742, 18844, 18946, 19048, 19149, 19250, 19352, 19453, 19554, 19655, 19756, 19856, 19957, 20057, 20158, 20258, 20358, 20457, 20557, 20656, 20756, 20855, 20954, 21053, 21151, 21250, 21348, 21446, 21544, 21641, 21739, 21836, 21933, 22029, 22126, 22222, 22318, 22414, 22510, 22605, 22700, 22795, 22890, 22984, 23078, 23172, 23265, 23359, 23452, 23544, 23637, 23729, 23821, 23913, 24004, 24095, 24185, 24276, 24366, 24456, 24545, 24634, 24723, 24811, 24899, 24987, 25075, 25162, 25248, 25335, 25421, 25507, 25592, 25677, 25761, 25846, 25930, 26013, 26096, 26179, 26261, 26343, 26425, 26506, 26586, 26667, 26747, 26826, 26905, 26984, 27062, 27140, 27218, 27295, 27371, 27447, 27523, 27598, 27673, 27747, 27821, 27895, 27968, 28040, 28113, 28184, 28255, 28326, 28396, 28466, 28535, 28604, 28672, 28740, 28808, 28874, 28941, 29007, 29072, 29137, 29201, 29265, 29329, 29391, 29454, 29515, 29577, 29638, 29698, 29757, 29817, 29875, 29933, 29991, 30048, 30105, 30161, 30216, 30271, 30325, 30379, 30432, 30485, 30537, 30589, 30640, 30690, 30740, 30789, 30838, 30886, 30934, 30981, 31027, 31073, 31118, 31163, 31207, 31251, 31294, 31336, 31378, 31419, 31460, 31500, 31539, 31578, 31616, 31654, 31691, 31727, 31763, 31798, 31832, 31866, 31900, 31933, 31965, 31996, 32027, 32057, 32087, 32116, 32144, 32172, 32199, 32226, 32252, 32277, 32302, 32326, 32349, 32372, 32394, 32416, 32436, 32457, 32476, 32495, 32514, 32531, 32548, 32565, 32581, 32596, 32610, 32624, 32637, 32650, 32662, 32673, 32684, 32694, 32703, 32712, 32720, 32727, 32734, 32740, 32746, 32751, 32755, 32758, 32761, 32764, 32765, 32766, 32767, 32766, 32765, 32764, 32761, 32758, 32755, 32751, 32746, 32740, 32734, 32727, 32720, 32712, 32703, 32694, 32684, 32673, 32662, 32650, 32637, 32624, 32610, 32596, 32581, 32565, 32548, 32531, 32514, 32495, 32476, 32457, 32436, 32416, 32394, 32372, 32349, 32326, 32302, 32277, 32252, 32226, 32199, 32172, 32144, 32116, 32087, 32057, 32027, 31996, 31965, 31933, 31900, 31866, 31832, 31798, 31763, 31727, 31691, 31654, 31616, 31578, 31539, 31500, 31460, 31419, 31378, 31336, 31294, 31251, 31207, 31163, 31118, 31073, 31027, 30981, 30934, 30886, 30838, 30789, 30740, 30690, 30640, 30589, 30537, 30485, 30432, 30379, 30325, 30271, 30216, 30161, 30105, 30048, 29991, 29933, 29875, 29817, 29757, 29698, 29638, 29577, 29515, 29454, 29391, 29329, 29265, 29201, 29137, 29072, 29007, 28941, 28874, 28808, 28740, 28672, 28604, 28535, 28466, 28396, 28326, 28255, 28184, 28113, 28040, 27968, 27895, 27821, 27747, 27673, 27598, 27523, 27447, 27371, 27295, 27218, 27140, 27062, 26984, 26905, 26826, 26747, 26667, 26586, 26506, 26425, 26343, 26261, 26179, 26096, 26013, 25930, 25846, 25761, 25677, 25592, 25507, 25421, 25335, 25248, 25162, 25075, 24987, 24899, 24811, 24723, 24634, 24545, 24456, 24366, 24276, 24185, 24095, 24004, 23913, 23821, 23729, 23637, 23544, 23452, 23359, 23265, 23172, 23078, 22984, 22890, 22795, 22700, 22605, 22510, 22414, 22318, 22222, 22126, 22029, 21933, 21836, 21739, 21641, 21544, 21446, 21348, 21250, 21151, 21053, 20954, 20855, 20756, 20656, 20557, 20457, 20358, 20258, 20158, 20057, 19957, 19856, 19756, 19655, 19554, 19453, 19352, 19250, 19149, 19048, 18946, 18844, 18742, 18640, 18538, 18436, 18334, 18232, 18130, 18027, 17925, 17822, 17720, 17617, 17514, 17412, 17309, 17206, 17103, 17000, 16898, 16795, 16692, 16589, 16486, 16383, 16280, 16177, 16074, 15971, 15868, 15766, 15663, 15560, 15457, 15354, 15252, 15149, 15046, 14944, 14841, 14739, 14636, 14534, 14432, 14330, 14228, 14126, 14024, 13922, 13820, 13718, 13617, 13516, 13414, 13313, 13212, 13111, 13010, 12910, 12809, 12709, 12608, 12508, 12408, 12309, 12209, 12110, 12010, 11911, 11812, 11713, 11615, 11516, 11418, 11320, 11222, 11125, 11027, 10930, 10833, 10737, 10640, 10544, 10448, 10352, 10256, 10161, 10066, 9971, 9876, 9782, 9688, 9594, 9501, 9407, 9314, 9222, 9129, 9037, 8945, 8853, 8762, 8671, 8581, 8490, 8400, 8310, 8221, 8132, 8043, 7955, 7867, 7779, 7691, 7604, 7518, 7431, 7345, 7259, 7174, 7089, 7005, 6920, 6836, 6753, 6670, 6587, 6505, 6423, 6341, 6260, 6180, 6099, 6019, 5940, 5861, 5782, 5704, 5626, 5548, 5471, 5395, 5319, 5243, 5168, 5093, 5019, 4945, 4871, 4798, 4726, 4653, 4582, 4511, 4440, 4370, 4300, 4231, 4162, 4094, 4026, 3958, 3892, 3825, 3759, 3694, 3629, 3565, 3501, 3437, 3375, 3312, 3251, 3189, 3128, 3068, 3009, 2949, 2891, 2833, 2775, 2718, 2661, 2605, 2550, 2495, 2441, 2387, 2334, 2281, 2229, 2177, 2126, 2076, 2026, 1977, 1928, 1880, 1832, 1785, 1739, 1693, 1648, 1603, 1559, 1515, 1472, 1430, 1388, 1347, 1306, 1266, 1227, 1188, 1150, 1112, 1075, 1039, 1003, 968, 934, 900, 866, 833, 801, 770, 739, 709, 679, 650, 622, 594, 567, 540, 514, 489, 464, 440, 417, 394, 372, 350, 330, 309, 290, 271, 252, 235, 218, 201, 185, 170, 156, 142, 129, 116, 104, 93, 82, 72, 63, 54, 46, 39, 32, 26, 20, 15, 11, 8, 5, 2, 1, 0, 0, 0, 1, 2, 5, 8, 11, 15, 20, 26, 32, 39, 46, 54, 63, 72, 82, 93, 104, 116, 129, 142, 156, 170, 185, 201, 218, 235, 252, 271, 290, 309, 330, 350, 372, 394, 417, 440, 464, 489, 514, 540, 567, 594, 622, 650, 679, 709, 739, 770, 801, 833, 866, 900, 934, 968, 1003, 1039, 1075, 1112, 1150, 1188, 1227, 1266, 1306, 1347, 1388, 1430, 1472, 1515, 1559, 1603, 1648, 1693, 1739, 1785, 1832, 1880, 1928, 1977, 2026, 2076, 2126, 2177, 2229, 2281, 2334, 2387, 2441, 2495, 2550, 2605, 2661, 2718, 2775, 2833, 2891, 2949, 3009, 3068, 3128, 3189, 3251, 3312, 3375, 3437, 3501, 3565, 3629, 3694, 3759, 3825, 3892, 3958, 4026, 4094, 4162, 4231, 4300, 4370, 4440, 4511, 4582, 4653, 4726, 4798, 4871, 4945, 5019, 5093, 5168, 5243, 5319, 5395, 5471, 5548, 5626, 5704, 5782, 5861, 5940, 6019, 6099, 6180, 6260, 6341, 6423, 6505, 6587, 6670, 6753, 6836, 6920, 7005, 7089, 7174, 7259, 7345, 7431, 7518, 7604, 7691, 7779, 7867, 7955, 8043, 8132, 8221, 8310, 8400, 8490, 8581, 8671, 8762, 8853, 8945, 9037, 9129, 9222, 9314, 9407, 9501, 9594, 9688, 9782, 9876, 9971, 10066, 10161, 10256, 10352, 10448, 10544, 10640, 10737, 10833, 10930, 11027, 11125, 11222, 11320, 11418, 11516, 11615, 11713, 11812, 11911, 12010, 12110, 12209, 12309, 12408, 12508, 12608, 12709, 12809, 12910, 13010, 13111, 13212, 13313, 13414, 13516, 13617, 13718, 13820, 13922, 14024, 14126, 14228, 14330, 14432, 14534, 14636, 14739, 14841, 14944, 15046, 15149, 15252, 15354, 15457, 15560, 15663, 15766, 15868, 15971, 16074, 16177, 16280
};

void setup() {
  Serial.begin(9600);
  while(GP8211S.begin()!=0){
    Serial.println("Error in Connection ! ");
    delay(1000);
  }
  
  GP8211S.setDACOutRange(GP8211S.eOutputRange10V);   
  delay(500);
}


void loop() {
  uint16_t i;
  for (i = 0; i < 1000; i++)
    {
      GP8211S.setDACOutVoltage(pgm_read_word(&(DACLookup_FullSine_15Bit[i])), false);
    }

}

9bit-15bit

Arduino
#include <DFRobot_GP8XXX.h>
DFRobot_GP8211S GP8211S;

const PROGMEM uint16_t DACLookup_FullSine_9Bit[512] =
{
  2048, 2073, 2098, 2123, 2148, 2174, 2199, 2224,
  2249, 2274, 2299, 2324, 2349, 2373, 2398, 2423,
  2448, 2472, 2497, 2521, 2546, 2570, 2594, 2618,
  2643, 2667, 2690, 2714, 2738, 2762, 2785, 2808,
  2832, 2855, 2878, 2901, 2924, 2946, 2969, 2991,
  3013, 3036, 3057, 3079, 3101, 3122, 3144, 3165,
  3186, 3207, 3227, 3248, 3268, 3288, 3308, 3328,
  3347, 3367, 3386, 3405, 3423, 3442, 3460, 3478,
  3496, 3514, 3531, 3548, 3565, 3582, 3599, 3615,
  3631, 3647, 3663, 3678, 3693, 3708, 3722, 3737,
  3751, 3765, 3778, 3792, 3805, 3817, 3830, 3842,
  3854, 3866, 3877, 3888, 3899, 3910, 3920, 3930,
  3940, 3950, 3959, 3968, 3976, 3985, 3993, 4000,
  4008, 4015, 4022, 4028, 4035, 4041, 4046, 4052,
  4057, 4061, 4066, 4070, 4074, 4077, 4081, 4084,
  4086, 4088, 4090, 4092, 4094, 4095, 4095, 4095,
  4095, 4095, 4095, 4095, 4094, 4092, 4090, 4088,
  4086, 4084, 4081, 4077, 4074, 4070, 4066, 4061,
  4057, 4052, 4046, 4041, 4035, 4028, 4022, 4015,
  4008, 4000, 3993, 3985, 3976, 3968, 3959, 3950,
  3940, 3930, 3920, 3910, 3899, 3888, 3877, 3866,
  3854, 3842, 3830, 3817, 3805, 3792, 3778, 3765,
  3751, 3737, 3722, 3708, 3693, 3678, 3663, 3647,
  3631, 3615, 3599, 3582, 3565, 3548, 3531, 3514,
  3496, 3478, 3460, 3442, 3423, 3405, 3386, 3367,
  3347, 3328, 3308, 3288, 3268, 3248, 3227, 3207,
  3186, 3165, 3144, 3122, 3101, 3079, 3057, 3036,
  3013, 2991, 2969, 2946, 2924, 2901, 2878, 2855,
  2832, 2808, 2785, 2762, 2738, 2714, 2690, 2667,
  2643, 2618, 2594, 2570, 2546, 2521, 2497, 2472,
  2448, 2423, 2398, 2373, 2349, 2324, 2299, 2274,
  2249, 2224, 2199, 2174, 2148, 2123, 2098, 2073,
  2048, 2023, 1998, 1973, 1948, 1922, 1897, 1872,
  1847, 1822, 1797, 1772, 1747, 1723, 1698, 1673,
  1648, 1624, 1599, 1575, 1550, 1526, 1502, 1478,
  1453, 1429, 1406, 1382, 1358, 1334, 1311, 1288,
  1264, 1241, 1218, 1195, 1172, 1150, 1127, 1105,
  1083, 1060, 1039, 1017,  995,  974,  952,  931,
   910,  889,  869,  848,  828,  808,  788,  768,
   749,  729,  710,  691,  673,  654,  636,  618,
   600,  582,  565,  548,  531,  514,  497,  481,
   465,  449,  433,  418,  403,  388,  374,  359,
   345,  331,  318,  304,  291,  279,  266,  254,
   242,  230,  219,  208,  197,  186,  176,  166,
   156,  146,  137,  128,  120,  111,  103,   96,
    88,   81,   74,   68,   61,   55,   50,   44,
    39,   35,   30,   26,   22,   19,   15,   12,
    10,    8,    6,    4,    2,    1,    1,    0,
     0,    0,    1,    1,    2,    4,    6,    8,
    10,   12,   15,   19,   22,   26,   30,   35,
    39,   44,   50,   55,   61,   68,   74,   81,
    88,   96,  103,  111,  120,  128,  137,  146,
   156,  166,  176,  186,  197,  208,  219,  230,
   242,  254,  266,  279,  291,  304,  318,  331,
   345,  359,  374,  388,  403,  418,  433,  449,
   465,  481,  497,  514,  531,  548,  565,  582,
   600,  618,  636,  654,  673,  691,  710,  729,
   749,  768,  788,  808,  828,  848,  869,  889,
   910,  931,  952,  974,  995, 1017, 1039, 1060,
  1083, 1105, 1127, 1150, 1172, 1195, 1218, 1241,
  1264, 1288, 1311, 1334, 1358, 1382, 1406, 1429,
  1453, 1478, 1502, 1526, 1550, 1575, 1599, 1624,
  1648, 1673, 1698, 1723, 1747, 1772, 1797, 1822,
  1847, 1872, 1897, 1922, 1948, 1973, 1998, 2023
};

void setup() {
  Serial.begin(9600);
  while(GP8211S.begin()!=0){
    Serial.println("Error in Connection ! ");
    delay(1000);
  }
  
  GP8211S.setDACOutRange(GP8211S.eOutputRange10V);   
  delay(500);
}


void loop() {
  uint16_t i;
  for (i = 0; i < 512; i++)
    {
      GP8211S.setDACOutVoltage(pgm_read_word(&(DACLookup_FullSine_9Bit[i])), false);
    }

}

Credits

Lithium ION

Lithium ION

53 projects • 34 followers
A passionate electronics DIY boy. Currently improving in Embedded systems, soldering and programming.

Comments