9 Home
qbinary edited this page 7 months ago

Welcome to the CerealOS Wiki

Table of Contents

Features

Shift register pin extender

CerealOS has wrapper methods which allows to step stepper motors individually via a shift register with flexible length. The methods a re easy to use.

// This call will make one step with the motor attached at the passed index pin.
step(index);

Stepper controller settings

CerealOS brings two functions to enable and disable the attached stepper controller correctly.

// Correctly enables the stepper controller by disabling the sleep mode and enabling motor power.
enableMotors();

// Correctly disables the stepper controller by enabling the sleep mode and disabling motor power.
disableMotors();

Smart mixing

To avoid an additional mix hardware I made sure that all motors turn simutaneously at certain speed to achieve the percentage given in the recipe.json while also making sure that all of them start and stop at the same time. This procedure ensures that the cereal is already mixed correctly after dispensing.

CerealOS does that by using a simple mathmatical modulo operation:

void bakeModulators(int sizeIndex)
{
    for (unsigned int recipe = 0; recipe < RECIPE_COUNT; recipe++)
        for (unsigned int ingredient = 0; ingredient < INGREDIENT_COUNT; ingredient++)
        {
            double percentageValue = ((cerealSizes[sizeIndex] / 100) * recipePercentages[recipe][ingredient]);
            double modulator = 0;
            if (percentageValue != 0)
                modulator = round(cerealSizes[sizeIndex] / percentageValue);
            recipeModulator[recipe][ingredient] = modulator;
        }
}

This method calculates the modulos from the percentages in the recipe.json. Those modulos will get "baked" in this method which means that these get calculated only once at runtime. This will save system resources during runtime but also makes it necessary to restart CerealOS after each recipe.json flash.