OpenSprinkler › Forums › Hardware Questions › OpenSprinkler Pi (OSPi) › How to read current station status? › Re: Re: How to read current station status?
I’ll chime in with some blind speculation. Ray (or possibly someone else) will need to provide a more authoritative answer.
If I had to guess, I would think that the communication between the RPi and the OS controller board is one-directional. In other words, the RPi sends commands to the board, but does not receive anything back in the way of status updates. All of the demo programs that I’ve looked at simply remember the last state that it sent to controller. Therefore, if you wanted to obtain the state of your controller (i.e., which stations are open/closed) you would need to query the program that was responsible for issuing the commands to the controller (and if it’s your own program that’s sending the commands, you’ll need to remember the current state in memory).
More generally, I think that what you may be misunderstanding is that every time you muck about with the shift registers, sending commands to controller board, you are effectively setting the *entire* state of the controller, not just changing the state of one or two specific stations. Via the shift registers, you’re basically sending a sequence of 1s and 0s to the controller with each bit representing the desired state of one of the specific stations. If, then, you send the binary 0010100 to the controller, you’re telling it to open stations 3 and 5 and keep all of the others closed. (Let me reiterate, this is speculation. I may have 1s and 0s reversed, and there may be some other details I’m missing. Don’t take this as gospel).
If you want to do some funky stuff with your own program where you are allowing for overlapping jobs, you’ll need to work out the logic on your own and send the complete state to the controller each time you want it to change. For example, let’s say you have the following desired schedule:
- At time t0, start station S1.
At time t1, start station S5.
At time t2, stop station S1.
at time t3, stop station S5.
In the above, you have two jobs. One for station S1 which starts at t0 and stops at t2 and another for station S5 which starts at t1 and stops at t3. The commands you’ll need to send out via the shift registers are as follows:
- At t0: 1000000
At t1: 1000100
At t2: 0000100
At t3: 0000000
At time t2, for example, even though we really only wanted to turn off station 1, we still had to send details to the controller that station t3 should still be active.
I could give you some additional guidance as to how this might be achieved in your own custom program, but my post is already rather wordy. Let me know if you’re curious and I’ll write it up.
Edit: you may want to consider, by the way, that allowing for overlapping jobs could have undesirable real-world effects. Many users, I suspect will not want multiple stations to be open at the same time because there may not be adequate water pressure to handle more than one station at a time.