Not hard at all. Setup a 1 ms timer interrupt (the ONLY interrupt in the system) and fire-off non-preemptive tasks in a loop. Bingo! You have an OS that is good enough to maintain a clock, attend to a serial port, even USB (via FTDI chip or similar), blink some LED’s and, yes, control the sprinkler system.
If you have a little more time, setup a FIFO a linked list or some other structure and have the keypad scanning routine issue messages that are then picked-up off the FIFO by a separate message processor routine that parses them and acts accordingly. In other words, not tasks can send each other messages through a very simple mechanism.
And now, with that in place, you can modify your serial or USB port handler to also allow you to place the same messages into the FIFO. What you’ve just done is enabled full remote control of your sprinkler system with very little code.
Now sensors (rain?) can also insert messages into the message loop and make things happen.
Change the LED routine to pick-up “LED” messages of the loop. Now you can control the LED’s remotely through your serial port.
Then you get a little more ambitious, buy one of those Digi modules that turns an Ethernet connection into a serial port and write simple code that allows you to have said module insert messages into the message loop. Now you can control your sprinkler system from any network location at home.
Not that hard at all. No need for Linux. Just start with a 1 ms timer interrupt and the rest is easy as pie.
By throwing a server-grade OS at controlling a sprinkler system people are not learning the most basic things about computing.
Read more here: https://news.ycombinator.com/item?id=10702086
rebootthesystem comments on "Raspberry Pi Zero vs. Elliott 405"
No comments:
Post a Comment