history


thermans

Recommended Posts

would need some advise here,

i have a regulator that regulates the rotational speed of something, then i want the speed to be close enough to the set point for 10 points of history, then save some values to "fake" channels and then add 200 to the set point

So, i guess what i need is a function that looks up the history of a channel, lets say mychann(0,10), and if all those values are in a specified range, then i want to do something like myvar= myvar +200...

Link to comment
Share on other sites

I'm assuming the question is how to process the history. You can get the last 10 points of a channel just by doing:

myChan[0,9]

You could then process that using a for() loop, but its usually better to avoid for loops because they don't scale well (i.e. they are slow when the size of the loop grows). So while it would probably be ok for 10 iterations, if you did, say, 1000, then it'd be kind of slow. Therefore its better to try and use built in DF functions for processing arrays. For checking a range you can use search:

if (search((myChan[0,9] > HiPoint) && (myChan[0,9] < LoPoint)) == -1)
   myVar += 200
endif

Note how the search is the inverse of what you described. It is looking for any value outside of your range. If it doesn't find anything that matches (meaning everything is inside the range) it returns -1. Otherwise it returns the index of the first point outside the range.

Link to comment
Share on other sites

now i have tried this:

While (Regulator==1)

If(search((Rollerspeed[0,40] >(setspeed+200)) && (Rollerspeed[0,40] < (setspeed-200))) == -1)

  Power.AddValue(total_Power[0])
  Enginespeed1.Addvalue(Enginespeed[0])

  setspeed += 300

endif

delay(0.5)

endwhile

But it seems to be inverted some how. When rollerspeed is outside the range it adds 300... i want it to add when its inside of range.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.