Sitting in the RAM

Hi all,
I am starting my house automation project. What I want to do is to code rules, jumps, thresholds etc in RAM area.
Doing so I am able to let the Arduinos change their coding on the fly while doing their job.

I wrote a small application to implement some basic operation needed to manage typical application (in my case I started with lightening around the hause and of our X-mas tree. I added a minimal thread logic because X-mas tree and house lights may use the same sensors but follow different rules at the same time on the same board - and it is a way to create blinking independently.

I works for me now fine but without any life belts :-), I am able to place around 40 instruction/rule combinations into the 2k limits managing 3 threads at the moment.

Before heading to code the next Arduino in my network managing more hardware and give them freedom to mutate on their own (which I actually not coded yet) I am wondering if you guys had some experience with this approach

Happy new year


We did a similar thing 30 years ago on a building control system, it works just fine. I forget the details now but it was a simple opcode/parameter sequence IIRC.

How are you coding the instructions, 40 in 2k seems like not a lot.


I am able to place around 40 instruction/rule combinations into the 2k limits managing 3 threads at the moment.

I prefer headroom and have become sweet on the 1284P-PU w/ 16K SRAM. The chip has a mature Arduino "core" available as well as some nice prototyping boards. One board is solid by forum member CrossRoads... Inexpensive. Fully assembled & tested were available, too.

I own 3 boards and am currently using one now for an FFT project.


Kits & assemblies Are available.

Dear all,

Thanks for your replies, I will check the link ...

I use the gnu compiler and will try to optimize from there.
I use sort of matrix consisting out of lines of a fixed array to code status network transitions. Each struct in the line is tested until the first match is found ("or"), a match is applied if all relevant conditions towards IO channels are met ("and")

Basically I use an array of transitions stored in a struct as:

8 bit 8 bit 16 bit {8-bit tupel} {8 bit tupel}
status new status relevance flag per channel {tupel of op codes} {tupel of references/arguments}

This is far from being optimized, but putting it this way it is easy for me to do the network modeling by hand for the different "threads"

Output is defined per status by a list if status to output mapping like on, off, fast_blinking, slow_blinking, etc

8bit chars[3] {tupel of 8 bit}
status name {output values or reference to 16bit values}

Then I have a small control structure per thread and a minimal Stack to reuse transitions via "function call".

The OpCodes themselves are Value Comparison, Thread conditions and timings. I am thinking of some more to model thread manipulation and synchronization, but this is on the way. Also value manipulation is on my list to have some adaptation in place

I am happy to learn, so I will check the hints from you.

Thanks a lot