Arduino Due and map configuration

Hi, I have to transfer a voltage and ampere reading program from arduino mega 2560 and arduino due, I use the map function, from the analysis of the characteristics of Arduino DUE and read that by default it has the same adc reference as arduino Mega 2560 that is 10 bit.
the function that I normally use of the nano, mega etc. is the following
amp = map (analogRead (IN_50vI), 512,1023,0,625);
volt = map (analogRead (IN_50vv), 0,1023,0,788);
with amp ADC (A0)I read a value between 2.5v and 5v in ,see ampere between 0-50A
with volt ADC (A1) I read through an attenuator circuit the voltage, for volt around 48-50v
So reading that arduino DUE has a default ADC? of 10 bits I believe not to have to change the above configuration, instead the
configuration of the two maps (arduino Mega 2560 and arduno DUE) give different values,
Where am I wrong?
Thank you
Jacob

why not transfer the value in terms of Volts and Amps rather than ADC values with assumptions about the ADC range in volts and # of bits.

fractional value can be transmitted as integers scaled by 10, 100, 1000

Thanks, but I have these functions in a larger program that, after reading the map value, also performs other checks, I do not have the adequate knowledge to proceed to change the entire program
for instance :

  if ((volt > = 570)) {// Overvoltage, always alarm!
                   FAULT = 2;
                   fault (); // Jump to FAULT handling
                   }
            if ((volt ) and (Operate == 1) and (TestMode == 0)) {// Undervoltage while in operate mode!
                   FAULT = 2;
                   fault (); // Jump to FAULT handling
                   }
etc

i'm confused about what the problem is. is it the transfer of values between two Arduinos or that the code produces different results on a Mega and Due?

Thanks, the problem is that the program that works with correct values on Mega, does not work the same on DUE, I believe for the configuration of the ADC BIT, is it true that arduino DUE has a default of 10bit adc? the same program on the two arduini should give the same result, maybe you have to switch to ADC 12bit on the TWO since it has the ports at 3.3v?
I apologize but I'm not very practical, I'm at the beginning of arduino programming.

is the ADC reference voltage the same on both processors?

non ho cambiato i BIT, credo che mega ha 10bit infatti la funziona MAP funziona con 5 volt e arduino due dovrebbe avere 10 bit di default, come ho letto sul web.

BOARD OPERATING VOLTAGE USABLE PINS MAX RESOLUTION
Uno 5 Volts A0 to A5 10 bits
Mini, Nano 5 Volts A0 to A7 10 bits
Mega, Mega2560, MegaADK 5 Volts A0 to A14 10 bits
Micro 5 Volts A0 to A11* 10 bits
Leonardo 5 Volts A0 to A11* 10 bits
Zero 3.3 Volts A0 to A5 12 bits**
Due 3.3 Volts A0 to A11 12 bits**
MKR Family boards 3.3 Volts A0 to A6 12 bits**

https://www.arduino.cc/reference/it/language/functions/zero-due-mkr-family/analogwriteresolution/

  • Ingressi Analogici: pin da A0 a A11 Il Due dispone di 12 ingressi analogici, ognuno dei quali può fornire 12 bit di risoluzione (ovvero 4096 valori differenti). Di default la risoluzione delle letture è impostata a 10 bit, per compatibilità con altre schede Arduino. È possibile modificare la risoluzione dell'ADC con analogReadResolution() . I pin degli ingressi analogici del Due misurano da terra fino a un valore massimo di 3,3V. L'applicazione di più di 3,3 V sui pin di Due danneggerà il chip SAM3X. La funzione analogReference() viene ignorata in Due.
  • Thanks Jacob

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.