20180123 arduino partitore breadboard01I propose a new measurement experiment using Arduino, working as DAQ (data acquisition instrument). I proceed as described in the article Arduino and Excel with PLX-DAQ and I mount my circuit on breadboard powered by the Arduino board at 5V. I propose to analyze how the resistive voltage divider evolves. I know that when two (or more) series-mounted resistors are affected by the same voltage, this voltage is divided in direct proportion to their size in Ohms.
I do the practical test by mounting on a breadboard a 100kΩ resistor in series with a 100kOhm potenziometer (or trimmer) bridging its central pin with an its side pin (so its resistance varies from 0÷100kΩ).
I perform voltage measurements on the potenziometer using Arduino, changing slowly its resistance over time and collecting data on an Excel spreadsheet using PLX-DAQ. I write the Arduino sketch reported below. Some explanations:

  • I use the A0 pin of Arduino as a probe to measure the voltage: #define sensorPin A0.
  • With statement #define resistorValue 100 I insert the correct resistor value in kOhm. Knowing that the resistance measurement of a resistor is affected by a tolerance and it deviates from its nominal value indicated with the color code, it would be better to enter its resistance value measured with an ohmmeter.
  • To store the voltage coming from the potenziometer I define the variable sensorVoltage.
  • After I calculate the voltage that falls on the resistor using the formula: 5-sensorVoltage, and the potenziometer Ohms with formula: sensorVoltage/((5-sensorVoltage)/resistorValue.
  • With delay(500) I insert 500ms delay between one measurement and the other so the PLX-DAQ-v2.11.xlsm spreadsheet does not crash Excel.

#define sensorPin A0       // select the input pin for the potentiometer
#define resistorValue 100  // resistor in kohm
int sensorValue = 0;       // variable to store the value coming from the sensor 0-1023
float sensorVoltage = 0;  // variable to store the voltage coming from the sensor 0-5V
int cont = 0;

void setup() {
  Serial.begin(9600);
  //Serial.println("CLEARDATA");
  Serial.println("LABEL,t,NUMBER,R-RESISTOR,R-TRIMMER,V-RESISTOR,V-TRIMMER");
}

void loop() {
  // read the value from the sensor
  sensorValue = analogRead(sensorPin);
  // calculate voltage
  sensorVoltage = sensorValue*5.0/1023.0;
  // send value to USB
  Serial.print("DATA,TIME,");
  Serial.print(cont++);
  Serial.print(",");
  Serial.print(resistorValue);
  Serial.print(",");
  Serial.print(sensorVoltage/((5-sensorVoltage)/resistorValue));
  Serial.print(",");
  Serial.print(5-sensorVoltage);
  Serial.print(",");
  Serial.println(sensorVoltage);
  // delay 500ms
  delay(500);
}

The figure below shows a measurement test with data collection in Excel.

20180123 arduino partitore breadboard02


Games

Trivia

Computers