- This topic is empty.
September 8, 2014 at 3:22 pm #23155
In the process of changing the program data structure to allow per-station water time, I thought about this question: is it possible to fit ‘station water time’ in 1 byte (0 to 255)? Currently the water time takes 2 bytes (0 to 65535) and it’s in granularity of seconds, so it can represent any time from 0 to 18.2 hours in steps of seconds. To fit it in 1 byte, what would you do?
* Option 1: use granularity of minutes, so it can represent any time up to 4.25 hours in steps of minutes only
* Option 2: use granularity of 15 seconds, so it can represent any time up to 1 hour in steps of 15 seconds
* Option 3: use a non-linear scaling: from 0 to 59 it’s in granularity of seconds, then it changes to granularity of minutes. So this can represent seconds up to 59, then minutes up to 196 (255-59).
* Other options?
Basically I am trying to understand common needs on the accuracy of water time: do you ever need to run a station for just a few seconds? How important is it to be able to set a water time of, say 5 minutes 25 seconds, 20 minutes 50 seconds etc? Thanks!September 8, 2014 at 4:31 pm #28167
I never use seconds. Minutes and hours only.September 8, 2014 at 4:33 pm #28168
Longest run time currently is 3 hours. I do have cycles that run all day long…like15 minutes running every 4 hours 1am until midnight.September 8, 2014 at 4:42 pm #28169
The only use case I could think of when seconds are required is for misting. It seems that 15 seconds minimum fractions should suffice.September 8, 2014 at 4:46 pm #28170
@TechFan: the number of times a program runs doesn’t matter (that’s stored in another variable), what I wanted to know is the water time within a single program run. So in your case , you have one example of 15 minutes, and another of 3 hours. (and just saw that you said you don’t need granularity of seconds, thanks).September 8, 2014 at 4:55 pm #28171
Assuming this byte only represents the user selected time for a circuit, i.e. It is not the actual running time, as that must consider the user set program percentage and possible other factors.
Here are variations on option 3:
A. With minutes and hours; This would allow the user to set a circuit to run as long as 196 hours and 59 minutes, in 1 minute increments.
B. With 30 seconds and hours; This would allow the user to set a circuit to run as long as 136 hours and 59 minutes and 30 seconds, in 30 second increments.
C. With 15 seconds and hours; This would allow the user to set a circuit to run as long as 16 hours and 59 minutes and 45 seconds, in 15 second increments.
For my uses, the 1 minute increment is the best choice. This is because it would be the easiest to set, while not limiting the running time.September 8, 2014 at 5:10 pm #28172
@iDoug: you are right that the actual running time is in granularity of seconds so water percentage can be applied without losing accuracy. The 1 byte restriction is mainly for efficient storage (’cause the microcontroller has limited EEPROM size). Because water time per station takes up most of the program settings, if we can fit it in 1 byte instead of 2, that can provide almost twice as many programs, which is desirable for people with a lot of stations.
Is it important to cover run time longer than, say 8 hours? I mean, if you need to run it that long, you can always break it into two programs that run one after another right?September 8, 2014 at 5:13 pm #28173
How about: 0-59 is seconds, 60-119 minutes, 120-143 hours and 144-255 days.September 8, 2014 at 5:20 pm #28174
@iDoug: here is another version based on your proposal: the first 2 bits represent units (second? minute? hour? day?) and the remaining 6 bits represent value. This will waste some values (like 24 hours and 1 day is the same), but simplifies the conversion.September 8, 2014 at 5:30 pm #28175
Would that limit the user in precision of input?
Don’t forget you have the hard part of actually coding this algorithm, we have the easy part of coming up with the algorithm.
Side note: At the top of Google’s core principles is: “Focus on the user and all else will follow.”September 8, 2014 at 5:37 pm #28176
The simplest approach is to let user input any time they want, and it’s the firmware’s job to quantize the value as necessary. But this may cause some confusion (like they may be surprised that 3 minutes and 10 seconds get rounded to 3 minutes). So the better approach is for the UI to match the firmware: for example, the user can put in any number in the ‘second’ box, but as soon as the ‘minutes’ box has a non-zero number, the ‘second’ box is disabled to reflect the fact that beyond 1 minute the accuracy become minutes.September 8, 2014 at 5:39 pm #28177
Or have a spinner/drop down with unit choice and only one box for numbers.
Sent from my iPhone using TapatalkSeptember 8, 2014 at 5:41 pm #28178
I will have to redesign the input completely to handle the non-linear method.
Using the latest method (defining the units in two bits) lets me show a value input with a unit selection. I think this would be easy from a user perspective.
Update: This is exactly what TechFan just wrote.September 8, 2014 at 5:51 pm #28179
No, the UI won’t be affected much, because the conversion back and forth is done on the firmware side. The UI can send any value to the firmware, and it’s up to the firmware to decide how to store it; similarly, when the firmware sends value to the UI it gives the UI the decoded value. [edit: yes if we are going with the value + unit approach, it will involve a UI change]September 8, 2014 at 5:52 pm #28180
OK, the value + unit list sounds like a good idea.September 8, 2014 at 6:03 pm #28181
Another question: since ‘seconds’ is not very common, do people care about the accuracy of 1 second, or would 5 seconds suffice?September 8, 2014 at 6:06 pm #28182
I don’t have a use case, so it doesn’t matter to me.
Sent from my iPhone using TapatalkSeptember 8, 2014 at 6:16 pm #28183
Another question: since ‘seconds’ is not very common, do people care about the accuracy of 1 second, or would 5 seconds suffice?
If we do units + value do we need to further compress seconds? I’m just curious.
If we did non-linear my plan was to show “seconds” and after 59 (at 60) switch the value to 1 min and change the lable for units to “minutes” and keep moving up as we increase. Same thing as we decrease the value.September 8, 2014 at 6:30 pm #28184
@iDoug: here is another version based on your proposal: the first 2 bits represent units (second? minute? hour? day?) and the remaining 6 bits represent value. This will waste some values (like 24 hours and 1 day is the same), but simplifies the conversion.
After thinking about this idea, I am confused. It appears you are saying that the user would select second, minute, hour or day. The the value of that would be a maximum of 63 as 6 bits has 64 values. Which would mean if a user selected 1 hour and 30 minutes the function would throw an error as this exceeds the lowest common denominator of minutes which has a value of 90. In other words the user is limited to 63 seconds OR 63 minutes OR 63 hours OR 63 days. What did I miss?September 8, 2014 at 6:35 pm #28185
@iDoug: the user has no way of selecting 1 hour and 30 minutes, because there are only one input value box, and one dropdown list to select unit.September 8, 2014 at 6:43 pm #28186
Wouldn’t it be best if the UI sent a time value and ray’s function stores that value into a byte and returns true for success and false for failure. How that time value is stored is all inside the function and should have no bearing on the UI.September 8, 2014 at 6:58 pm #28187
How that time value is stored is all inside the function and should have no bearing on the UI.
Sure, as I said before this is fine; but if we are to adopt the “value + unit” option , then the UI can be changed to match that right?September 8, 2014 at 7:16 pm #28188
IMHO: It does make for an unusual UI. Wouldn’t that also mean an odd API for others? Shouldn’t all time values be passed in the same manner? If so, can all time values be limited to 63 units?
Additionally, you will have to explain your logic to every user/coder that wants an odd variation of these units, i.e. 90 minutes. As you have told me, this is not a pleasant task to justify your logic.September 8, 2014 at 7:35 pm #28189
Look, the firmware does its own independent checking, so if you throw 65 minutes to it it’s just going to round it to 60 minutes because it has no way of representing 65 minutes; and if your throw 120 minutes to it it will convert it to 2 hours. It always does its best to represent whatever value you pass in. I agree with you that the firmware functionality should not be dependent on the UI to do error checking for it.
What I meant is that if the firmware cannot represent 65 minutes, why letting the UI leave this as an option? I think it’s not ideal for users to set 65 only to find out it’s rounded to 60. So what I am saying is that if the UI can do it, why not?September 8, 2014 at 7:43 pm #28190
I agree with your logic about how the UI should behave. I disagree with the firmware not allowing 65 minutes. What happens when a coder wants to expand the log functions to allow for a display of 90 days or months or years? None of this would be represented in the firmware.
By making your unique variation of time available to the UI you are setting a standard for the project. Are you prepared to constantly justify this standard?
- You must be logged in to reply to this topic.