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).
Circuit Diagram
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.