151
edits
|  (add text) |  (add todos and pseudocodes) | ||
| Line 14: | Line 14: | ||
| * Power supply 12 volts | * Power supply 12 volts | ||
| * Lots of cables... | * Lots of cables... | ||
| == To-Do List == | |||
| * Implement stepper motor speed with AccelStepper library (based on category (CO<sub>2</sub> value)) (s. Pseudocode below) | |||
| * Stabilize bubble rings holder to the stepper motor | |||
| * For better and more directed air flow: add nozzle/funnel? | |||
| * Make wiring diagram | |||
| * Documentation | |||
| == Pseudocode == | |||
| Idea: assign CO<sub>2</sub> value into 3 categories; '''Low, Medium, High''' and adjust the stepper motor speed based on the category.<syntaxhighlight lang="arduino"> | |||
|   DEFINE constants for CO2 thresholds: | |||
|     LOW_MEDIUM_THRESHOLD = 500 //to be determined via trials | |||
|     MEDIUM_HIGH_THRESHOLD = 700 //to be determined via trials | |||
|   DEFINE speed settings for each category: | |||
|     LOW_SPEED = 400      // Steps per second | |||
|     MEDIUM_SPEED = 800   // Steps per second | |||
|     HIGH_SPEED = 1200    // Steps per second | |||
|   INITIALIZE variable currentCategory to -1 | |||
|   INITIALIZE variable lastCategory to -1 | |||
|   FUNCTION setup(): | |||
|     BEGIN | |||
|       SET maximum speed for stepper motor (e.g., 1200 steps/sec) | |||
|       SET acceleration for smoother operation (e.g., 500 steps/sec^2) | |||
|       START serial communication for debugging | |||
|     END | |||
|   FUNCTION loop(): | |||
|     BEGIN | |||
|       READ CO2 value from the sensor (variable CO2) | |||
|       DETERMINE currentCategory: | |||
|         IF CO2 < LOW_MEDIUM_THRESHOLD: | |||
|           SET currentCategory to LOW | |||
|         ELSE IF CO2 < MEDIUM_HIGH_THRESHOLD: | |||
|           SET currentCategory to MEDIUM | |||
|         ELSE: | |||
|           SET currentCategory to HIGH | |||
|       IF currentCategory is different from lastCategory: | |||
|         BEGIN | |||
|           SWITCH currentCategory: | |||
|             CASE LOW: | |||
|               SET stepper motor speed to LOW_SPEED | |||
|             CASE MEDIUM: | |||
|               SET stepper motor speed to MEDIUM_SPEED | |||
|             CASE HIGH: | |||
|               SET stepper motor speed to HIGH_SPEED | |||
|           UPDATE lastCategory to currentCategory | |||
|         END | |||
|       RUN stepper motor at the current speed (use AccelStepper's runSpeed() function) | |||
|     END | |||
| </syntaxhighlight>Idea to determine thresholds: run trials on plants enclosed environment.<syntaxhighlight lang="arduino"> | |||
|   DEFINE variables: | |||
|     minCO2 = Infinity     // Initialize to a very high value | |||
|     maxCO2 = -Infinity    // Initialize to a very low value | |||
|     startTime = CURRENT_TIME | |||
|     trialDuration = 30 minutes (in milliseconds, e.g., 30 * 60 * 1000) | |||
|   FUNCTION setup(): | |||
|     BEGIN | |||
|       INITIALIZE serial communication for debugging | |||
|       INITIALIZE CO2 sensor | |||
|       PRINT "Starting 30-minute CO2 trial..." | |||
|     END | |||
|   FUNCTION loop(): | |||
|     BEGIN | |||
|       WHILE (CURRENT_TIME - startTime) < trialDuration: | |||
|         BEGIN | |||
|           READ current CO2 value from sensor (variable currentCO2) | |||
|           IF currentCO2 < minCO2: | |||
|             UPDATE minCO2 to currentCO2 | |||
|           IF currentCO2 > maxCO2: | |||
|             UPDATE maxCO2 to currentCO2 | |||
|           PRINT currentCO2, minCO2, and maxCO2 to serial monitor | |||
|           WAIT for 1 second //reduce sampling frequency | |||
|         END | |||
|       PRINT "Trial Complete." | |||
|       PRINT minCO2 and maxCO2 to serial monitor | |||
|       CALCULATE range = maxCO2 - minCO2 | |||
|       CALCULATE lowMediumThreshold = minCO2 + (range / 3) | |||
|       CALCULATE mediumHighThreshold = minCO2 + (2 * range / 3) | |||
|       PRINT "Thresholds:" | |||
|       PRINT "Low-Medium Threshold: " + lowMediumThreshold | |||
|       PRINT "Medium-High Threshold: " + mediumHighThreshold | |||
|     END | |||
| </syntaxhighlight> | |||
| == Gallery == | == Gallery == | ||
edits