My guess is that you need to make the analogReadResolution(12); first. Then do the reading. Try this order of the code:analogReadResolution(12);val = analogRead(analogInPin); // read the voltage on the pot

There are still some issues with the ADC and DAC.I found and reported earlier, that the ADC readings drop as soon the ARM is warming up a bit (>32*C).The DAC is obviously outputting voltages only in the range of 1/6..5/6 of 3300mV -see also postings at: http://arduino.cc/forum/index.php/topic,129765.15.htmlI have modified your code as follows which should work with above limitations:

/*Read the value of the potentiometer (1.000V) at A0 and multiplyfor 1.625 and output it at DAC1 both with 12 bits resolution */unsigned long val = 0; // variable to store the value coming from A0unsigned long val2 = 0;unsigned long outputValue =0;int analogInPin = 0; // Analog input pin connected to the variable resistorvoid setup(){ analogReadResolution(12); //read-resolution to be set first analogWriteResolution(12); //this should not apply according to documentation but surprisingly does not show up as error?}void loop() { val = analogRead(analogInPin); // read the voltage on the pot val2=val*1625/1000; //recommended and faster to use integers instead of float for calculations. outputValue = map(val2,550,2750,0,3300); //to normalize limited output range analogWrite(DAC1,outputValue); //write at DAC1 delay(500);}

gbduino, thank you for the example. Like you said, you moved the instruction to use 12 bit resolution from loop() to setup(). I was wondering about that myself. It seemed to me kind of wasteful to call for 12 bit resolution every single time that machine tried to read from analog input, it made more sense to setup 12 bit resolution one time in setup(). But the example for using 12 bit resolution on the main website, where it talks about using 10 bit and 12 bit resolution, had the command in the loop(), I think that is why OP also placed it in the loop().

zeluiz,it is not just clear if you still have a problem, what the problem is or if you already could solve it.In case you solved it - what have been your findings and why was it "just necessary to write this" (might be of interest or help for others).

thank you for your reply.For me it was necessary to use mapping, to be able to obtain the correct voltage relation (as to your project) in the limited outout range my Dues provide. It could have been completely done in one step with "map", but for better understanding I used your multiplicator as first step to translate the input by 1.625 and the used map to obtain the correct voltage from the DAC as I found that not to be 1:1 (the value read for xV from ADC input did not result in xV when fed to DAC).Are you able to set the voltage of the ADC-outputs in the full range from 0.0 to 3.3V !?This would be different to what I and also others found.

thank you for your reply.For me it was necessary to use mapping, to be able to obtain the correct voltage relation (as to your project) in the limited outout range my Dues provide. It could have been completely done in one step with "map", but for better understanding I used your multiplicator as first step to translate the input by 1.625 and the used map to obtain the correct voltage from the DAC as I found that not to be 1:1 (the value read for xV from ADC input did not result in xV when fed to DAC).Are you able to set the voltage of the ADC-outputs in the full range from 0.0 to 3.3V !?This would be different to what I and also others found.

From reading the this forum, the DAC only does 5/6 of 3.3 volts, so the maximum out of DAC is 2.75 volts.This fact is actually important to me too because I am using Due in a project and plan to use DAC to control speed of a fan.

Sorry to take this thread on a tangent. But since we have listed the DAC limit. Does ADC has a similar limit for input? Or does it actually accept the maximum of 3.3 volts?

If you need the output voltage starting from zero, you might compensate that by usage of a diode which shifts the min. as well the max. voltage by approx. -0.7V giving you a range of ~0..2V.The ADCs work in full range 0..3300mV = 0..4095. There is only a slight variation for the upper limit, as the reference Voltage at AREF is built from the DUE's 3,3V regulator which is not that accurate in the range of some mV. You can apply your own AREF-voltage, but have to modify the hardware (remove a resistor) for that. AREF is not selectable by software at the DUE.Further I found the ADC not to react below 13mV (which causes a small offset) and also the temperature issue I already reported before - that could cause a significant missreading.

The problem is: I have is to emulate an analogical function control with amplifications, derivators, integrators, etc So I need to perform mathemathicals operations, that is why I use float in my sketch. I do believe that the DACs are linear between 0 to 3.3VDC i.e. the first grade 0 the next 0.00081VDC and so on. That´s why I'm using the Due. I think my multimeter is not exact enough to mesure that. Could someone elucidate that?

I wanted to know exactly the relation among the ADC (input) and the output (DAC) so I modify the sketch and multiply by 1.000. This way with 0V at the input, it outputs to 0.55V (1/6) of 3.3V; 3.3V in the input, it outputs with 2.75V (5/6) of 3.3V. So if the input is among 0 to 3.3V the output is among 0 to 2.75V linearly. I think if someone wants a relation 1 to 1, between the input and the output, he needs to use operational amplifiers. It follows my sketch.