I’m working on a Mixer Control to turn my mixer into bascially a bread machine dough cycle.
It will be basically the blink program but more lines:
{ digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(60); // wait for a set amount of on time digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(120); // wait for a set amount of off time }
Something like this. But more like:
-motor on in 1s pulses off for 3s repeated for 1 minute
-motor on for 8 minutes to mix/develop gluten
-motor off for 30 minutes
-motor on for 30 seconds
-off for 50 minutes
-on for 30 seconds
and so forth.
No problem so far. This will be easy to do.
This is for my sourdough program. Say I’d like to have another set of times for Italian bread etc. I could always just upload another sketch. But is there a “best” way to have both “programs” in one sketch and choose between them based on a digital in being high or low?
I guess a for loop?
Just as important… say the Arduino board loses power. It’d mess up the dough by starting back at the beginning of the timing sequence. Is there a way to pickup where it left off in the code loop after power is restored?
I guess you could attach a rotary switch or a touchpad or simply a row of pushbuttons to allow you to select the bread option. Your code could read the switch position or button number and then use a switch-case statement to determine which sequence of actions get executed.
Yes. But the coding may be beyond beginner level. Your code would need to know not only which recipe but which step is being executed, and perhaps even how long that step has executed so far. For this, a Real-Time Clock module might be useful to record the time each step was begun, so that after a power loss, the Arduino can calculate how much more time (if any) that the current step needs to run for.
The current recipe, step and step-start time could be recorded in the Arduino's EEPROM memory, or maybe some non-volatile memory of the RTC.
In that case, it’s easy enough to just store one set of code in the board. If I need another set of instructions for some other type of dough, just plug in a download them.
Sure. the program is always the same, but with different parameters.
My advise is to use EEPROM. Write there your set of "programs" (you need to do only once, e.g. via Serial, on a newly programmed board), then let the user select the desired one from a list (using either buttons or a rotary, plus something to show the current "program" (e.g. some LEDs if you need just a few programs to select from, or an LCD).
Once the user selects the desired program and you want to let Arduino run that program without further requests, you can store its index number inside EEPROM so when starting just checks that specific byte and zero means no selection has made yet (the user needs to select a program to start), 1 for the first program, then 2 etc. After a selection is made, pressing a "start/stop" button will start the cycle.
While running, pressing the "start/stop" button stops the current "program" and when in "stop" state, the user can change the program and then pressing "start/stop" the selected sequence starts.
How long is a bread making cycle, that is to ask how long must the controller operate reliably?
What is the real probability of a failure during that window?
How much dies a ruined batch cost in whatever terms you measure cost?
A simpler solution involving a different kind of fun might be to address the failure modes… if power goes out, aren't you pretty much hosed anyway? What else might go wrong?
To keep my solution simpler, if the "programs" are just 2 or 3 and don't need to make changes to the sequences, you could just create 2 or 3 functions to be called inside the loop() cycle, and run only the one the user selects.
Aside from all the descriptions about the selection and user interface, something like:
// Currently selected program index (0=no program running)
byte CurrentProg = 0;
...
void loop()
{
switch (CurrentProg) {
case 1:
StandardBread();
break;
case 2:
ItalianBread();
break;
case 0: // No program is running
break;
}
}
I do a similar thing all the time, I simply write the step number to FRAM. Unlike EEPROM it has basically unlimited read/write cycles, Nice part it is byte addressable, and no delays when reading or writing. I use the I2C version of the 32K x 8 devices which cost less then a pack of cigarettes. I have replaced the EEPROM on the RTC module with them. It takes a bit of forming to get them to fit. You can get some EEPROM modules for not much and plug them in that socket.
If you power the Arduino with mains, and you can get a power loss, there is trouble.
You could add a battery to the Arduino so the program continues.
E.g. a appropriate battery on the jack plug, and power with USB.
I think a bigger problem is the dough machine, when that looses power.
Is the dough recoverable?
Have you looked at large USP devices? I once had a large pick-and-place machine that could not have ANY three-phase power interruptions. Our plant had an interrupt at least once a month. I found a very large 3-phase UPS at the Oregon State surplus web site. No batteries. I bid on it an won. Bought the four 12 volt batteries for the unit and ran perfectly for as long as we had the machine. I think it was 15 kva. You could do similar.
What if... by mechanical means an escapement (gear) was pushed along in time as stages of mixing occurred... and the present state of the escapement at (re) power-up could give the system enough information to restart at the time of power loss...
In my case, the idea is to make it so I can unplug and move the mixer to a different area without starting over. That or a minor power blip won’t be an issue. Even in the worst case, this is running a Bosch or similar small mixer that makes 4 loaves of sourdough bread at a time. So no huge loss if something failed completely. That and I could pull the dough and finish by hand.
But in the case where all works as it should, I should be able to load the ingredients and walk away for 3-4 hours while the mixer does its thing automatically. This will basically be a customizable bread machine dough cycle with a larger capacity.
Yeah, and you could start with the methods I already described you (the one with full EEPROM storage, or limiting to with 2 or 3 programs).
Now the question is: how much experience do you have with programming, and especially with Arduino? The best thing to do would be to start building something, perhaps using a simulator like WokWi for now, so you can work on the circuit (though you'll probably want to simulate the motors with LEDs for now) and the code without having to physically build anything.