Host Engineering Forum
General Category => General Discussion => Topic started by: pbw on January 08, 2018, 10:50:42 AM
-
I'd like to program a lookup Chart (Attached) into a Do-More CPU. What would be the best method to do this?
Any help is appreciated.
I need to determine moisture content based on Rh and temp measurements.
-
BobO helped me with a similar setup earlier, https://forum.automationdirect.com/forum/general-applications/109390-do-more-lookup-table (https://forum.automationdirect.com/forum/general-applications/109390-do-more-lookup-table), I'm sure we can help you through it on this forum just as well.
You would probably need to create memory blocks for each humidity range, then do a lookup in the appropriate column with your known temperature. I'm not sure if there is a cleaner way to do it with all the data in a single block.
-
I saw that post when you guys were discussing it back then, and it had never dawned on me to set it up like that.I have used it since then on numerous occasions and greatly simplified my code.to do this chart I figured I would have to do as you suggested, but I was thinking maybe there was an easier and cleaner way to do it in Do-More and was hoping that maybe I was overlooking something.
This chart is actually just a start-up prototype deal. The chart I want use in the finished code would have temp range 0-100 and Rh range of 0-100 as well and creating that many code blocks gets messy.What would be great though, is if a guy could create a codeblock like "Temperature0-100" and create 100 RH subs("Temperature0.RH0") which is possible but I don't know of a way to index through the .RH files. :'(
-
Here is a quick sample.
You will have to finish entering all of the data into the COPY command.
Hopefully this will give you an idea of how it could work.
-
What would be great though, is if a guy could create a codeblock like "Temperature0-100" and create 100 RH subs("Temperature0.RH0") which is possible but I don't know of a way to index through the .RH files. :'(
This can be done using the REF() function in a MATH box, but I believe the sample I posted will probably be easier to maintain.
-
AWESOME!! Tons of information on this forum. If you guys ever compile a Do-More Tips and Tricks book I want to know about it.
Thanks
-
Sorry if this is nut's approach, haven't looked at the code...but...
...you can easily do a 2 dimensional array in a single block of 130 elements (10 rows x 13 cols -> Data0-129):
1. X = ROUND((Humidity - 30) / 5)
2. Y = ROUND((Temperature - 35) / 5)
3. LookupVal = Data[X + Y*13]
-
Slick work Bob
Thanks
-
Does it have to be in a lookup table? I'm sure there is some math behind this table. You may be able to plot it out in Excel, get the equation of the line(s) and then just use a MATH block to compute directly. Not sure if this would create a performance hit but may be easier and less error prone then copying the table.
-
Yes there is math behind it, I think it uses the modified Henderson equation. I did incorporate that equation along with a few other moisture curves into a math box and it works. But there seems to be a lot of inconsistency between the moisture curves I think in part due to all the different variety and breeds of grain out there. I just wanted to be able to have a backup plan in place in case the formulas are not effective. Also I can't seem to find any formulas for peas and lentils although there are charts available on the internet and while probably possible to sketch it out in excel and derive a formula I thought it would be easier to program a chart.
-
If you need a little more precision, you could utilize 10 different LERP instructions, all in a CalcMoisture SUBROUTINE with 2 input parameters (Temp and Rh) and one output parameter (Moisture). Then have a bunch of CalcMoisture CALLs (if you need more than 1 CALL).
-
Yes there is math behind it, I think it uses the modified Henderson equation. I did incorporate that equation along with a few other moisture curves into a math box and it works. But there seems to be a lot of inconsistency between the moisture curves I think in part due to all the different variety and breeds of grain out there. I just wanted to be able to have a backup plan in place in case the formulas are not effective. Also I can't seem to find any formulas for peas and lentils although there are charts available on the internet and while probably possible to sketch it out in excel and derive a formula I thought it would be easier to program a chart.
There's curve-fitting software where you can input the points and it will kick out an equation or equations together with correlation coefficients that gauge how good the fit is for each equation. Plus yeah, a chart is easy too.
-
There's curve-fitting software where you can input the points and it will kick out an equation or equations together with correlation coefficients that gauge how good the fit is for each equation. Plus yeah, a chart is easy too.
What is the name of the software do you have a link available?
-
No. In DOS I used FIT2, which I think is still available. It will run in a DOS box under windows.
I used some Windows software a couple years ago, but no longer have it installed, and I don't remember the name.