bugis33:
Hello everyone. I'm using the Mega 2560.
That is massive overkill for what you need. But you can use it to program a small, cheap board that does the job and you hang on to that 2560. Did you know that it's capable of hosting external RAM addressed directly by the CPU? I paid $25 for a board with 8 56KB-usuable banks of RAM. It's got 4 high speed serial ports and a ton of pins too, don't waste it!
Today I've made the changes that GoForSmoke recommends and a few more changes to my mind, and everything seems to work. Changes made to my anchor, so I deleted a few blank spaces and added extra brackets.
if (temp1 <= 20 && (]flame_pin == HIGH))
{
fsm_doz.check_timer();
fsm_uzd.check_timer();
}
else if (temp1 <= 20 && (flame_pin == LOW))
Just have a few more questions: how to make the temperature readable eg. 20.5 but not 20.50 because when the temperature reaches the specified relay it starts to switch it on and it switches off as long as the temperature does not exceed the set limit.
Your logic has the off and on points touching. You need to have some part of the system with a higher heater-OFF point than heater-ON point to give more time for the system to cool than the relays need to (in many heating systems it is the igniter that fails first but the cure is the same, why home thermostats have 2 working set points.
The second question is about the Nextion screen, I can not link it in any way. In what way I try, I get only meaningless characters, not the proper command signal to serial port THANKS for everyone
I don't have one nor a clue nor do you give any of those. Does it have a serial or I2C or SPI interface or does it require a load of custom wiring? Display with interface is much easier wiring and code.
Here is a way to diagram how your machine should work: draw timing diagrams for all your IO pins on lined paper, 1 pin per line or two. Across the line is time, you draw the line high or low as the pin should be with the rest and the up and down transitions between then note what event that signifies or causes directly or indirectly,
The whole operation seems like it should be simple, you might organize around connected conditions and events in time and get a proper picture of the states the heat machine you have can be in -in terms of these pins as high or low and when.
Then you can start to see what state machines are for, to organize a job by the steps the process goes through and code each step to run whenever a variable, the state, equals that step number. Any step may change the state value on any event or condition, maybe it watches a pin and a timer to trigger the next state change.
Last part
- the state machine is made to run a short step each time that void loop() runs. It's named loop() for a reason.
- when you're mostly watching and changing pins,at even 1MHz the changes look slow and asynchronous, code that is always watching catches that as quickly as void loop() runs. If you use millis() values in unsigned long variables you can tell when a time is up or not, and if it isn't up then the next pin check can run and next at very many per millisecond speed ... errrr,
but only if the code doesn't block execution with delay() or other wait-for commands or loops inside of loop(). If you have code that makes everything else wait, everything slows down and response gets poor. Answer is never block!
Code it as a machine and drive the code machine with states and void loop().