Purity Measurement of Gold Using Ultrasonic Sensor

About The Project

In this project, we will learn how to measure the purity of a metal using a simple ultrasonic sensor.

 

How is this possible? It’s based on the same principle as Archimedes’ ancient method. By measuring the weight and volume of a metal, he determined its purity. In this project, we will measure the volume of a metal. This is done by simply immersing the material into water in a jar. When it is immersed in the water, the water level rises. This rise in water level is a measure of the volume of the metal. We can measure its weight using a simple weight meter. By mapping and calibrating the weight and water level, we can measure the purity of the metal.

I think it is quite interesting, don’t you?

Ultrasonic Sensor (HC-SR04)

The working principle of an ultrasonic distance sensor is based on the echo of high-frequency sound (Ultrasonic Sound)waves.

  1. Sound Wave Emission: The sensor emits short pulses of ultrasonic sound waves (typically above the range of human hearing, around 40 kHz).
  2. Travel to Object: These sound waves travel through the air and bounce off any obstacle or object in their path.
  3. Echo Reception: The sensor then listens for the echoes of the sound waves reflected back from the object.

Time Calculation : By measuring the time interval between sending the sound pulse and receiving its echo, the Arduino Uno calculates the distance to the object using the formula: Distance = Speed of Sound ×Time interval between sending the sound pulse and receiving its echo/2.

Speed of Sound: The speed of sound wave in air is approximately 343 meters per second .

Volume calculation:

To measure the volume of the metal using the jar with half-filled water, follow these steps:

  1. Initial Measurement: Note the initial water level in the jar before immersing the metal. You can mark the level or record the measurement if the jar has volume markings.
  2. Immersion: Carefully immerse the metal completely into the water without spilling any water out of the jar.
  3. Final Measurement: Note the new water level in the jar after the metal is fully submerged.
  4. Calculate Volume: The volume of the metal is equal to the difference between the final water level and the initial water level.

Volume of metal = Final water level – Initial water level

This difference gives you the volume of the metal, as the water displacement corresponds to the volume of the submerged metal.

Weight Measurement:

The weight measurement can be done simply by using a weight machine, just as we do regularly.

Purity Measurement:

To measure the purity of a metal by knowing its volume and weight, follow these steps:

  1. Calculate the Density:

   – Measure the weight (mass) of the metal using a weight machine.

   – Measure the volume of the metal by the water displacement method as described earlier.

   – Calculate the density of the metal using the formula:

     Density = Weight /Volume

  1. Compare with Known Density:

   – Compare the calculated density with the known density of the pure metal. Each pure metal has a characteristic density (e.g., gold has a density of 19.32 g/cm³, silver has a density of 10.49 g/cm³).

  1. Determine Purity:

   – If the calculated density matches the known density, the metal is pure.

   – If the calculated density is different, the metal is impure. The degree of difference can give an indication of how pure or impure the metal is.

If the calculated density is close to 19.32 g/cm³, the gold is pure. If it is significantly different, the gold contains impurities.

Circuit Wiring

How to Measure Purity

  1. Connect the Circuit: Connect the circuit as shown in the figure.
  2. Upload the Program: Compile and upload the program to the Arduino Uno board using the Arduino IDE.
  3. Set Up the Sensor: Fix the ultrasonic sensor above the half-filled jar. Position the sensor to measure the water level.
  4. Initial Measurement: Press the ‘init’ button to record the initial water level, which will be displayed on the serial monitor. Release the button afterward.
  5. Immerse the Ornament: Carefully immerse the ornament into the jar without spilling any water or partially immersing the ornament.
  6. Final Measurement: Press the ‘dip’ button to record the updated water level. The percentage purity of the gold ornament will then be displayed on the serial monitor.

Program Code

C
// www.matthewtechub.com
// Purity measurement
const int trigPin = 7;    
const int echoPin = 10;    
const int buttonInitialPin = 3;
const int buttonDipPin = 2;
int status_dip;
int status_initial;
float time_us;
float distance_initial = 0;
float distance_dip = 0;
float distance;
/*weight_gm is the weight of the ornament 
in grams for which the purity is to be measured.*/
float weight_gm = 60.87;
/* The density of gold is approximately 
19.32 grams per cubic centimeter (g/cm³). */
float density_gold = 19.32;
// Variable to hold the density of the ornament
float density_ornament;
void setup() {
  // Begin serial port
  Serial.begin(9600);
  // Configure buttons
  pinMode(buttonDipPin, INPUT_PULLUP);
  pinMode(buttonInitialPin, INPUT_PULLUP);

  // Configure the trigger pin to output mode
  pinMode(trigPin, OUTPUT);
  // Configure the echo pin to input mode
  pinMode(echoPin, INPUT);
}
void loop() {
  // Check if the initial button is pressed
  status_initial = digitalRead(buttonInitialPin);
  if (status_initial == LOW) {
    // Generate 10-microsecond pulse to TRIG pin
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);
    // Measure time duration of pulse from ECHO pin
    time_us = pulseIn(echoPin, HIGH);
    // Calculate the distance
    distance_initial = 0.017 * time_us;
    // Print the value to Serial Monitor
    Serial.print("Initial distance: ");
    Serial.print(distance_initial);
    Serial.println(" cm");
  }
  // Check if the dip button is pressed
  status_dip = digitalRead(buttonDipPin);
  if (status_dip == LOW) {
    // Generate 10-microsecond pulse to TRIG pin
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);
    // Measure time duration of pulse from ECHO pin
    time_us = pulseIn(echoPin, HIGH);
    // Calculate the distance
    distance_dip = 0.017 * time_us;
    // Print the value to Serial Monitor
    Serial.print("Dip distance: ");
    Serial.print(distance_dip);
    Serial.println(" cm");
    // Calculate the difference in distance
    distance = distance_initial - distance_dip;
    // Print the distance difference to Serial Monitor
    Serial.print("Distance difference (volume measure): ");
    Serial.print(distance);
    Serial.println(" cm");
    // Calculate density of the ornament
    // 1 cm in height equals 10 cm³ of volume
    density_ornament = weight_gm / (distance * 10);
    // Calculate purity percentage
    float purity = (density_ornament /density_gold) * 100;
    // Print purity percentage to Serial Monitor
     Serial.print("density  of Ornament: ");
    Serial.print(density_ornament);
    Serial.print("Purity of Ornament: ");
    Serial.print(purity);
    Serial.println(" %");
  }
  delay(3000); // Delay between measurements
}
  • The code measures the initial water level and the water level after dipping the ornament.
  • It calculates the volume based on the difference in water levels.
  • It uses the weight and volume to calculate the density of the ornament.
  • Finally, it calculates the purity percentage of the gold ornament based on the density comparison with pure gold.

Code Explanation

C
const int trigPin = 7;    
const int echoPin = 10;    
const int buttonInitialPin = 3;
const int buttonDipPin = 2;
int status_dip;
int status_initial;
float time_us;
float distance_initial = 0;
float distance_dip = 0;
float distance;
/* weight_gm is the weight of the ornament
 in grams for which the purity is to be measured. */
float weight_gm = 60.87;
/* The density of gold is approximately 19.32 grams 
per cubic centimeter (g/cm³).*/
float density_gold = 19.32;
// Variable to hold the density of the ornament
float density_ornament;

Global Variables and Constants

  • trigPin: The pin number for the trigger pin of the ultrasonic sensor.
  • echoPin: The pin number for the echo pin of the ultrasonic sensor.
  • buttonInitialPin: The pin number for the button to measure the initial water level.
  • buttonDipPin: The pin number for the button to measure the water level after the ornament is dipped.
  • status_dip, status_initial: Variables to store the status of the buttons.
  • time_us: Variable to store the time duration of the echo pulse.
  • distance_initial: Variable to store the initial distance measured by the sensor.
  • distance_dip: Variable to store the distance measured by the sensor after the ornament is dipped.
  • distance: Variable to store the difference in distance.
  • weight_gm: The weight of the gold ornament in grams (in our case we are measing our ornament of 60.87 grams ).
  • density_gold: The density of pure gold (19.32 grams per cubic centimeter- a fixed value in the case of gold).
  • density_ornament: Variable to store the calculated density of the ornament.
C
void setup() {
  // Begin serial port
  Serial.begin(9600);
  // Configure buttons
  pinMode(buttonDipPin, INPUT_PULLUP);
  pinMode(buttonInitialPin, INPUT_PULLUP);

  // Configure the trigger pin to output mode
  pinMode(trigPin, OUTPUT);
  // Configure the echo pin to input mode
  pinMode(echoPin, INPUT);
}

setup() Function

  • Serial.begin(9600): Initializes the serial communication at a baud rate of 9600.
  • pinMode(buttonDipPin, INPUT_PULLUP): Configures the dip button pin as an input with an internal pull-up resistor.
  • pinMode(buttonInitialPin, INPUT_PULLUP): Configures the initial button pin as an input with an internal pull-up resistor.
  • pinMode(trigPin, OUTPUT): Configures the trigger pin as an output.
  • pinMode(echoPin, INPUT): Configures the echo pin as an input.
C
void loop() {
  // Check if the initial button is pressed
  status_initial = digitalRead(buttonInitialPin);
  if (status_initial == LOW) {
    // Generate 10-microsecond pulse to TRIG pin
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);
    // Measure time duration of pulse from ECHO pin
    time_us = pulseIn(echoPin, HIGH);
    // Calculate the distance
    distance_initial = 0.017 * time_us;
    // Print the value to Serial Monitor
    Serial.print("Initial distance: ");
    Serial.print(distance_initial);
    Serial.println(" cm");
  }
  // Check if the dip button is pressed
  status_dip = digitalRead(buttonDipPin);
  if (status_dip == LOW) {
    // Generate 10-microsecond pulse to TRIG pin
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);
    // Measure time duration of pulse from ECHO pin
    time_us = pulseIn(echoPin, HIGH);
    // Calculate the distance
    distance_dip = 0.017 * time_us;
    // Print the value to Serial Monitor
    Serial.print("Dip distance: ");
    Serial.print(distance_dip);
    Serial.println(" cm");
    // Calculate the difference in distance
    distance = distance_initial - distance_dip;
    // Print the distance difference to Serial Monitor
    Serial.print("Distance difference (volume measure): ");
    Serial.print(distance);
    Serial.println(" cm");
    // Calculate density of the ornament
    // 1 cm in height equals 10 cm³ of volume
    density_ornament = weight_gm / (distance * 10);
    // Calculate purity percentage
    float purity = (density_ornament /density_gold) * 100;
    // Print purity percentage to Serial Monitor
     Serial.print("density  of Ornament: ");
    Serial.print(density_ornament);
    Serial.print("Purity of Ornament: ");
    Serial.print(purity);
    Serial.println(" %");
  }
  delay(3000); // Delay between measurements
}

loop() Function

Initial Distance Measurement

  • status_initial = digitalRead(buttonInitialPin): Reads the status of the initial button.
  • if (status_initial == LOW): If the initial button is pressed:
    • digitalWrite(trigPin, HIGH): Sends a high pulse to the trigger pin.
    • delayMicroseconds(10): Delays for 10 microseconds.
    • digitalWrite(trigPin, LOW): Sends a low pulse to the trigger pin.
    • time_us = pulseIn(echoPin, HIGH): Measures the duration of the echo pulse.
    • distance_initial = 0.017 * time_us: Calculates the distance based on the pulse duration.
    • Serial.print(“Initial distance: “): Prints the initial distance to the serial monitor.

Dip Distance Measurement

  • status_dip = digitalRead(buttonDipPin): Reads the status of the dip button.
  • if (status_dip == LOW): If the dip button is pressed:
    • digitalWrite(trigPin, HIGH): Sends a high pulse to the trigger pin.
    • delayMicroseconds(10): Delays for 10 microseconds.
    • digitalWrite(trigPin, LOW): Sends a low pulse to the trigger pin.
    • time_us = pulseIn(echoPin, HIGH): Measures the duration of the echo pulse.
    • distance_dip = 0.017 * time_us: Calculates the distance based on the pulse duration.
    • Serial.print(“Dip distance: “): Prints the dip distance to the serial monitor.
    • distance = distance_initial – distance_dip: Calculates the difference in distance.
    • Serial.print(“Distance difference (volume measure): “): Prints the distance difference to the serial monitor.
    • density_ornament = weight_gm / (distance * 10): Calculates the density of the ornament (1 cm in height equals 10 cm³ of volume).
    • float purity = (density_ornament / density_gold) * 100: Calculates the purity percentage.
    • Serial.print(“density of Ornament: “): Prints the density of the ornament to the serial monitor.
    • Serial.print(“Purity of Ornament: “): Prints the purity percentage to the serial monitor.

Delay

  • delay(3000): Delays for 3000 milliseconds (3 seconds) between measurements.

Try Yourself

  1. You can measure the purity of your ornament using a transparent container partially filled with water. First, mark the water level when the ornament is fully submerged. Then, take the ornament out and fill the container with water up to the marked level. Measure the amount of water you added; this is the volume of your ornament. Next, weigh your ornament. With the volume and weight, you can calculate the density and, therefore, the purity of your ornament. Give it a try!
  2. Try to measure the purity of your silver ornament. At least think where you might need to modify the program.

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!