Day 18: Material Analysis Scanner


As the Nebula Raider continues its mission, it is essential to analyze the materials of various items collected during the treasure hunt. This ensures that the inventory is properly categorized and any valuable or dangerous materials are identified. As a cadet, you are tasked with building a Material Analysis Scanner. This device will help you analyze the properties of different materials, using common kitchen items as test subjects.

Components and Setup:
Raspberry Pi Pico WH Microcontroller: The brain of the project, used to run the code and control the circuit.
104pf/0.1uf/100nf 50V Ceramic Disc Capacitors and 10uf 50v Electrolytic Capacitors: Used to form the RC (resistor-capacitor) circuit for measuring capacitance.
Resistors: Used in the circuit to form a timing constant with the capacitors.
Breadboard and Jumper Wires: For connecting all the components securely.

How the Project Works:
RC Circuit:

The core of this project is an RC circuit, where R is the resistor and C is the capacitor. The time it takes for a capacitor to charge or discharge through a resistor is related to the capacitance value of the capacitor.
When you place different materials in contact with the capacitor, the capacitance value changes based on the material’s properties.
Measuring Capacitance:

Discharging the Capacitor: The capacitor is first fully discharged to ensure a consistent starting point. This is done by connecting the capacitor to ground through a discharge pin.
Charging the Capacitor: The capacitor is then charged by applying a voltage through a charge pin. The time it takes to charge to a certain voltage level is measured.
Calculating Capacitance: The time measured during the charging process is used to calculate the capacitance. The relationship between the time (T), resistance (R), and capacitance (C) is given by the formula
𝑇=𝑅×𝐶
By knowing the resistance and measuring the time, you can calculate the capacitance.
Code Explanation:

Discharge Phase: The code sets the discharge pin high to discharge the capacitor and then sets it low to stop discharging.
Charge Phase: The code sets the charge pin high to start charging the capacitor. The ADC (Analog-to-Digital Converter) reads the voltage on the capacitor to determine when it reaches a certain level.
Timing and Calculation: The time it takes for the capacitor to reach the voltage level is measured using the utime.ticks_us() function. This time is then used to calculate the capacitance using the known resistance value.

Testing Materials:

Common kitchen items such as salt, sugar, flour, water, and oil are placed in contact with the capacitor.
The capacitance values are measured and printed out. Different materials will have different capacitance values based on their properties.

Circuit Setup:
Connecting the Capacitors and Resistors:

Place the capacitors and resistors on the breadboard.
Connect one end of the capacitor to the GPIO pin (for charging/discharging) and the other end to the ADC pin.
Use resistors to form the RC circuit.
Wiring the Raspberry Pi Pico:

Connect the charge pin to a GPIO pin on the Raspberry Pi Pico (e.g., GP27).
Connect the discharge pin to another GPIO pin (e.g., GP16).
Connect the ADC pin to the analog input on the Raspberry Pi Pico (e.g., GP15).


Code:
The provided code handles the charging, discharging, and timing of the capacitor. It calculates the capacitance based on the time measured during the charging phase.

Test the System:

Upload the code to the Raspberry Pi Pico and run it.
Place different kitchen items (e.g., salt, sugar, flour, water, oil) in contact with the capacitors and measure the capacitance.
Record the capacitance values and analyze the material properties based on the readings.


Learning Outcomes:

Sensor Integration: Learn how to connect and use capacitors with the Raspberry Pi Pico to measure material properties.
Material Analysis: Understand how to analyze the properties of different materials using capacitance measurements.
Microcontroller Programming: Develop skills in writing code to integrate sensors and perform measurements.
Extension Ideas:

Data Logging: Implement data logging to record and analyze the capacitance values for different materials over time.
Additional Sensors: Add more sensors (e.g., temperature, humidity) to gather additional data about the materials.
Material Database: Create a database of materials and their properties for reference and comparison.
Using Common Kitchen Items:

Salt: Measure the capacitance of salt and compare it with other materials.
Sugar: Analyze the properties of sugar using the Material Analysis Scanner.
Flour: Test the capacitance of flour and understand its material properties.
Water: Measure the capacitance of water and compare it with dry materials.
Oil: Analyze the properties of oil and its capacitance readings.
By completing this project, you will have built a Material Analysis Scanner to check the composition of various items in the inventory. This will help ensure that the materials collected during the treasure hunt are properly categorized and any valuable or dangerous materials are identified.

Post a comment

Leave a Comment

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