News:

  • April 18, 2024, 12:47:48 PM

Login with username, password and session length

Author Topic: Lookup Table  (Read 3312 times)

pbw

  • Hero Member
  • *****
  • Posts: 121
Lookup Table
« 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.

Bolt

  • Hero Member
  • *****
  • Posts: 543
Re: Lookup Table
« Reply #1 on: January 08, 2018, 12:33:53 PM »
BobO helped me with a similar setup earlier, 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.
« Last Edit: January 08, 2018, 12:36:51 PM by Bolt »

pbw

  • Hero Member
  • *****
  • Posts: 121
Re: Lookup Table
« Reply #2 on: January 08, 2018, 01:21:44 PM »
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. :'(

plcnut

  • Hero Member
  • *****
  • Posts: 803
    • premiersi.com
Re: Lookup Table
« Reply #3 on: January 08, 2018, 01:43:23 PM »
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.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

plcnut

  • Hero Member
  • *****
  • Posts: 803
    • premiersi.com
Re: Lookup Table
« Reply #4 on: January 08, 2018, 01:46:39 PM »
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.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

pbw

  • Hero Member
  • *****
  • Posts: 121
Re: Lookup Table
« Reply #5 on: January 08, 2018, 02:04:24 PM »
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
« Last Edit: January 08, 2018, 02:06:36 PM by pbw »

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 5984
  • Yes Pinky, Do-more will control the world!
Re: Lookup Table
« Reply #6 on: January 08, 2018, 03:21:24 PM »
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]
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

pbw

  • Hero Member
  • *****
  • Posts: 121
Re: Lookup Table
« Reply #7 on: January 08, 2018, 06:44:59 PM »
Slick work Bob
Thanks

jcottrill

  • Full Member
  • ***
  • Posts: 43
Re: Lookup Table
« Reply #8 on: January 09, 2018, 02:48:55 PM »
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.

pbw

  • Hero Member
  • *****
  • Posts: 121
Re: Lookup Table
« Reply #9 on: January 09, 2018, 03:09:32 PM »
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.   

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3658
    • Host Engineering
Re: Lookup Table
« Reply #10 on: January 09, 2018, 04:05:08 PM »
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).

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3558
  • Darth Ladder
Re: Lookup Table
« Reply #11 on: January 09, 2018, 04:40:23 PM »
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.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

pbw

  • Hero Member
  • *****
  • Posts: 121
Re: Lookup Table
« Reply #12 on: January 09, 2018, 05:17:28 PM »
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?

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3558
  • Darth Ladder
Re: Lookup Table
« Reply #13 on: January 09, 2018, 05:27:19 PM »
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.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.