Hey trilerian,
I did a similar exercise to you last night / this morning, in order to test the ADC at low voltages.
I did not use a potentiometer, but used the DC output of my function generator to supply the test voltage.
I hadn't realised that the output of the function generator changed in 10mV steps, even though the resolution of the setting knob/buttons and display goes down to 1mV. So I made an attenuator to get lower voltage steps / better resolution.
I used my multimeter to measure the voltage, and recorded the corresponding ADC output count. I did not attempt to convert the count to voltage.
Rather than manually take readings, I decided to automate the process.
I programmed the Arduino under test to send SCPI commands to the function generator to set the output voltage, and to the multimeter to read the attenuated voltage that went to the Arduino analogue input.
I tested the two Unos sequentially, transferring the ethernet shield and connections between the two Unos. All connections made using BNC leads.
Here are the results plotted in Excel.
Uno R3:
Uno R4:
It can be seen that the Uno R3 ADC count didn't change from zero until the input voltage was around 20mV, rather than the expected 4mV to 5mV.
Here is the code I used:
#include <SPI.h>
#include <Ethernet.h>
int dy = 500 ;
// Enter a MAC address and IP address for the Arduino
byte mac[] = { 0xA8, 0x61, 0x0A, 0xAE, 0x0B, 0xB5 };
IPAddress ip(192, 168, 0, 10); // desired Arduino IP address
IPAddress server1(192, 168, 0, 7); // IP addresses of the Instruments
IPAddress server2(192, 168, 0, 8); // IP addresses of the Instruments
EthernetClient client1;
EthernetClient client2;
void setup() {
// Start the Ethernet connection:
Ethernet.begin(mac, ip);
// Open serial communications and wait for port to open:
Serial.begin(9600);
Serial.println("\n");
// Give the Ethernet shield a second to initialize:
delay(1000);
Serial.println(" connecting...");
Serial.println("");
// Connect to Instrument 1;
if (client1.connect(server1, 5025)) { // Port 5025 is commonly used for SCPI
Serial.print(" Instrument 1 connected : ");
// Send a SCPI command to the DMM:
client1.println("*IDN?");
} else {
// If you didn't get a connection to the server:
Serial.println("1 connection failed");
}
delay(dy);
while (client1.available() > 0) {
char c = client1.read();
Serial.print(c);
}
// Connect to Instrument 2:
if (client2.connect(server2, 5025)) { // Port 5025 is commonly used for SCPI
Serial.print(" Instrument 2 connected : ");
// Send an SCPI command to the DMM:
client2.println("*IDN?");
} else {
// If you didn't get a connection to the server:
Serial.println("2 connection failed");
}
delay(dy);
while (client2.available() > 0) {
char c = client2.read();
Serial.print(c);
}
Serial.println("\n");
Serial.println("Test: ADC count: voltage:\n");
delay(3000);
}
void loop() {
// If the server disconnected, stop the client:
if (!client1.connected()) {
Serial.println();
Serial.println("disconnecting 1.");
client1.stop();
// Do nothing more:
while (true);
}
// If the server disconnected, stop the client:
if (!client2.connected()) {
Serial.println();
Serial.println("disconnecting 2.");
client2.stop();
// Do nothing more:
while (true);
}
for (int i = 0; i <= 500; i++) {
float voltage = i / 100.0 ;
Serial.print(i);
client1.print("C1:BSWV OFST,"); // set function generator output voltage
client1.println(voltage);
delay(dy);
int reading = analogRead(A0); // read adc count
Serial.print(", ");
Serial.print(reading);
Serial.print(", ");
client2.println("READ?"); // read multimeter
delay(dy);
// If there are incoming bytes available from Instrument 2:
while (client2.available() > 0) {
char c = client2.read();
Serial.print(c);
}
}
}
Here is a typical output from the serial monitor for uno R4:
The Uno R4 changes from zero to non zero around 4mV-5mV as expected.