Classroom Activity
Mars Chemistry Coding Challenge
Overview
In this coding challenge, students will use real data from the Perseverance Mars rover to create a system that can monitor and test the functioning of the MOXIE instrument, which converts carbon dioxide in the Martian atmosphere into breathable oxygen.
Materials
Management
- Students should have some knowledge of how to balance chemical equations and/or charges for this lesson.
- Each student should have their own computer, and it may be helpful for them to follow along on their own device while the instructor introduces the challenge.
- Groups should be no larger than four students to keep each student actively engaged.
Background
The Perseverance Mars rover landed on the Red Planet in 2021 and is NASA’s most advanced rover to date.
The rover, which operates using programmed instructions it receives from engineers on Earth, carries a suite of advanced science tools to search for signs of ancient life while studying the geology and subsurface of the Red Planet.
Like other missions, Perseverance also brought new technologies to Mars to test them on the Red Planet and push the frontiers of what future missions could do.
One of those new technologies was Ingenuity, the first helicopter to fly on Mars. Performing more than 70 powered flights, Ingenuity showed how helicopters could be a useful tool for future robotic and human explorers on Mars.
Another new technology that traveled to Mars with Perseverance resides within the chassis of the rover: an instrument called MOXIE, which stands for Mars Oxygen In-situ Resource Utilization Experiment. This electrochemical device can create breathable oxygen by using a catalyst to split carbon dioxide in the Martian atmosphere.
The oxygen produced by MOXIE, or instruments like it, could be used in the future to create breathable air for astronauts, or it could even be combusted and used as fuel for launches from the Martian surface – for example, to send samples from Mars back to Earth.
Because Mars is so far away, testing and evaluating instruments like MOXIE from here on Earth relies heavily on computer science and coding. Scientists and engineers send command codes to the rover when they want to operate MOXIE and when they want to receive data back from the instrument. This includes commands that tell MOXIE when to run and for how long, and how to measure the success of each test of the instrument.
In this challenge, students will look at real data from MOXIE on Mars and design a system that can test and monitor whether the instrument is running properly.
Procedures
- Provide an overview of the MOXIE instrument aboard the Perseverance Mars rover, explaining that it's designed to convert carbon dioxide in the Martian air to oxygen.
- Divide students into groups and tell them that, in this challenge, they will be using real data from MOXIE to program a system that can monitor and test whether the instrument is running properly.
- Review the data set while showing students the MOXIE gas flow schematic below. Point out that there are multiple places where temperature and pressure are monitored and that gas laws can be a valuable starting point to track how these details change over time. Note that carbon dioxide enters at the bottom left as a reactant, then carbon monoxide and oxygen leave as products at the top left and right, respectively.
- Give students time to plan and map out how they will use the data to track whether or not MOXIE is operating properly. Students should consider what columns they need to successfully complete the task, how the task can be broken into smaller parts for each member of the group, etc.
Students will most likely try to develop a solution using the gas laws from their chemistry course, relating pressure and temperature (Gay-Lussac’s law), like so:
(P/T)carbon dioxide = (P/T)carbon monoxide + (P/T)oxygen
Note that the most common mistake students make when using gas laws is forgetting to correct for the number of moles. In this case, encourage students to balance the equation first:
2CO2 → 2CO + O2
And add a multiplier in their code for the number of moles using the equation:
(P/nT)carbon dioxide = (P/nT)carbon monoxide + (P/nT)oxygen
or
(P/2T)carbon dioxide = (P/2T)carbon monoxide + (P/1T)oxygen
- Have students begin writing their code with each team member completing the task assigned by the group. Providing these hints and tips as needed:
- The simplest place to begin is with the alarm for whether or not conditions are met. If students are just using Python, a team member can be charge of the parameters for success and the readout:
- If students are using external devices or microcontrollers, they may want to use lights or sounds:
- Suggest students create subsets of the data instead of operating off of the entire (very large!) spreadsheet. Which columns do they need for their plan? Can they test on a small set of lines first before running through every line?
- As team members work through their tasks, they may see opportunities to tie code together into more effective solutions. This will likely include having the code do the calculations line by line and then be fed to the alarm:
- If students are familiar with libraries, this presents a much faster and effective way to go through the thousands of lines of code:
- As students test their code, have them look at separate sections of the data as subsets before looking at everything all at once. Does the data trigger more when the device is on or off, hot or cold? This may help students navigate any limitations to their code. Remind students to save small subsets of the original data file and label them clearly.
- The simplest place to begin is with the alarm for whether or not conditions are met. If students are just using Python, a team member can be charge of the parameters for success and the readout:
- Have student groups share their code and strategy with each other midway through the challenge to generate new ideas and solutions.
- Once they have finished creating their programs, have students share their final solutions, including considerations about the discussion prompts below.
Discussion
- Ask students where they set their alarm levels for the mass balance of oxygen produced. Why did they select this level? What could be done to improve it?
- Encourage students to articulate the strengths and weaknesses of their solutions. Did the code take a long time because it was running line by line? How could it be made to run faster?
- Thinking about the engineering of MOXIE, what assumptions were made about the process, and how did they affect our outcome? For example, if students used gas laws to get pressure, volume, and temperature, do those equations work in open systems like MOXIE or only in closed systems?
Assessment
- Consider using the provided engineering rubric or editing it to highlight your individual learning objectives.
- Students should be able to evaluate the strengths and weaknesses of their model as well as the models of other students groups. Encourage students to articulate these pros and cons in a writing assignment to help them communicate the advantages of different solutions to the same problem.
Extensions
If students haven't already tried it, task them with using physics to create a charge balance instead of using chemistry to generate a mass balance. Note that columns in the data should include volts and current. Because electrons have a known charge, it is possible (and more representative of the real MOXIE) to use Ohm’s Law, V = IR, to track how much oxygen is being produced.
Explore More
- Lesson
Build a Relay Inspired by Space Communications
In this intermediate-level programming challenge, students use microdevices along with light and mirrors to build a relay that can send information to a distant detector.
Subject Technology
Grades 8-12
Time 1-2 hrs
- Lesson
Coding a Radio Message for Space
Students code microcontrollers to send and receive radio signals, simulating communications between Earth and spacecraft.
Subject Technology
Grades 6-12
Time 30-60 mins
- Lessonn
Heat Flow Programming Challenge
Students use microcontrollers and temperature sensors to measure the flow of heat through a soil sample.
Subject Technology
Grades 5-12
Time 1-2 hrs
- Lesson
Build a Light Detector Inspired by Space Communications
In this advanced programming activity, students will construct a light-wavelength detector to model future technology for communicating with spacecraft.
Subject Technology
Grades 9-12
Time 2+ hrs
- Lesson
Mars Sample Return Coding Challenge
Student teams use block coding or python to program separate components of the Mars Sample Return mission then combine their projects into a single system.
Subject Technology
Grades 6-12
Time 2+ hrs
- Collection
Coding Lessons for Educators
Use these coding lessons to get students excited about space exploration and computer programming.
- Collection
Coding Projects for Students
In these DIY projects, students using programming to design their own missions to the Moon, Mars, and beyond.