Go Down

### Topic: DAC problem with MKRZERO (Read 3410 times)previous topic - next topic

##### Sep 05, 2017, 04:04 pmLast Edit: Sep 05, 2017, 04:19 pm by LizardOnTheRoad
Hi everyone,

I have a really strange problem with my MKRZERO Arduino. One of the most important things I need to do for my project is to have a perfect control on the DAC. It's not really easy to find a lot of datasheets on this model, I only use the information below:

https://store.arduino.cc/usa/arduino-mkrzero

The Circuit Operating Voltage is 3.3V, and the DAC is supposed to be 10 bits. So normally, I should be able to create steps of 3.3/1023 Volt. In order to test that, I used the code below. (This is not the complete code, I only wrote the important steps, I know that this code cannot work by itself)

Code: [Select]
`pinMode(A0,OUTPUT);                         //W_VoltageanalogWriteResolution(10);for (float i=0; i <= 1023; i++){    delay(500);    analogWrite(A0,i);    delay(500);    Serial.println(i);    }`

If I connect a voltmeter between the ground and my A0/DAC Output, I can see by observing the Serial.println(i) on the computer that my DAC evolves in cycles of 2^8 - 1 = 255 steps. Which means that I read a 0V at step 0, step 256, step 512, etc...  But it's not my main problem. The weirdest thing is, my DAC stops at 2.2V, which is related to the 175 step in my cycle of 255 steps. Whatever I do, my DAC cannot reach 3.3V. It is the same if I try this command.

Code: [Select]
`analogWrite(A0,1023);`

I will only read 2.2V, just like in my last test. Did this happen to anyone else? I would be really glad if you could tell me what you think, because this a huge problem for me, I mainly bought that Arduino for that, and if that does not work i'm kinda blocked.

Thank you so much for your help!

Sincerely yours,

Maxime Mano.

#### ballscrewbob

#1
##### Sep 08, 2017, 11:29 am
You may want to include the FULL sketch as partial ones don't always provide much insight.

Also thanks for an otherwise perfect post using code tags etc always nice to see.
It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

#### pacobene

#2
##### Feb 22, 2018, 10:26 pm
Hello LizardOnTheBoard:

I have the same problem with my Arduino M0 and Arduino M0Pro.

Here is the Sketch:

void setup()
{
SerialUSB.begin(9600);
delay(6000);
pinMode(A0,OUTPUT);
pinMode(A1,INPUT);
analogWriteResolution(10);
}

void loop()

for(int i=0; i<1024; i++)
{analogWrite(A0,i);
SerialUSB.println(i);
SerialUSB.println(lee);
SerialUSB.println(" ");
delay(5);}
}

#### gdsports

#3
##### Feb 23, 2018, 07:43 am
Remove the pinMode(A0, OUTPUT) line.

https://forum.arduino.cc/index.php?topic=525853.0

Go Up