For fun and learning.

quick clarification Peter I'm assuming (hopefully correctly the K in your example is Knots) if so the correct constant is Kn
 
If the wind vane is left point east but the wind is not blowing should we average in 270 for each minute the wind isn't blowing? I don't think so.
I mentioned averaging 2 vectors above by adding them and dividing the resulting vector by 2: couldn't the average of 3 vectors be taken by adding all 3 and dividing by 3 and so on?, if the wind speed was zero for one (or more) readings then the resultant average would be in the same direction but of a lower magnitude.
 
Angles15.gif


ARCTAN(y_avg/x_avg)). switch the terms

ARCTAN (x_avg/y_avg)).



then switch it back to degrees

Angles14.gif


if output is greater than 180 then subract 180 if output is less than 180 add 180

course this still does not solve measurements taken with no wind velocity.
 
Last edited:
Is anybody getting real work done?

I mentioned averaging 2 vectors above by adding them and dividing the resulting vector by 2: couldn't the average of 3 vectors be taken by adding all 3 and dividing by 3 and so on?, if the wind speed was zero for one (or more) readings then the resultant average would be in the same direction but of a lower magnitude.
Yes, now you have a velocity weighted average.

Others have found the same website Mordred has. The incremental approach on that website doesn't take into account the wind velocity. Can we have the best of both worlds?
 
The main thing here, as with most problems in my experience, is in the definition of the original question. We have come up with several answers to the original question but each with potentially different results.

Aside from that; the original poster asked for a PLC programming challenge: if/when we agree on a theoretical solution I think it would be useful to other members to see various implementations of the solution as PLC programs, maybe on different platforms and in different programming languages.

This problem, whilst interesting and good for keeping the old grey matter chugging along, is not really PLC related. Does anyone have any puzzles/problems which have a definite theoretical solution where the trick is the actual implementation of the solution with a PLC?

I know L D[AR2,P#0.0] has posted a few interesting quizzes (totally lost me because of my lack of stl & step7 knowledge) any others?
 
AverageWindDirection:=K*AverageWindDirection+(1-K)*NewWindDirection?

This is a nice approach to the problem still working with it lol
 
I am home now.

AverageWindDirection:=K*AverageWindDirection+(1-K)*NewWindDirection?

This is a nice approach to the problem still working with it lol
Better is this
K=(1-exp(-t/tau))
AvgVec=AvgVec+K*(NewVec-AvgVec)
or
AvgVec=AvgVec+K*DifVec

Where
AvgVec is actually the filtered speed and direction
NewVec is the new wind speed and direction
DifVec is the difference between the new wind speed vector and the average wind speed vector
t is the sample time. For example 1 minute
tau is the time constant. The time constant should be longer than the sample time.

I think this example is the best example of adding increments to the average wind vector and it takes into account the wind speed.

Mordred, you example shows the flaws simply adding vectors.
Another example would be to adding 10 mph east to 10 mph west and get 0. This too is misleading because obviously the wind was blow. However, this too is a contrived example.

This problem cries out for an Excel spreadsheet example using Mordred's data using different techniques. The average should be updated after every reading.

I am still working on my cascaded loop problem. I am trying to do some symbolic proofs.
 
I have thought of ways to do the examples given in ladder. Lets pretend we don't have line code capabilities. I sure want to work on these math examples, but lets make it fun like making a 16 step sequence in 1 rung. Lots of intro programmers look here for ideas.

My thoughts on this is.... I have been at my new place for 3 years. I came in with Logix 5000 knowledge. I have took full advantage of the things you can do via where outputs, oneshots, and etc, can be put. It freaks out programmers use to the RS500 programming. I can do things in 1 rung that use to take many. Lets do all of it.
 
Last edited:
Mordred, you example shows the flaws simply adding vectors.
Another example would be to adding 10 mph east to 10 mph west and get 0. This too is misleading because is a contrived example.

I wholeheartenly agree the reason I postd this data set was this was the crux of the problem I had run into on the SQL server I was working on. The other problem was readings taken when their was no steady wind. The method used to detect wind speed did not take into consideration what I referred to as harmonic wind simply put air is always moving plus you get pressure differences on one side of a fan as opposed to the other this will by itself cause movements. Luckily with the system I was working on filtering out values below 1knot/hour helped but I still ran into occasssional data sets that would give me incorrect values on the speed component. This I beleive was due to pressure variations due to temperature variations on the building roof top as well as the fact out door air is never still.

The second post where I switched the terms and used radians is from that particular SQL server and it is one I've seen used in quite a few examples where this same method is used in real world environments. Although this data set is contrived in those real world enviroments the passing from east to west do occur. This is one of the reasons I like your incremental approach as it takes into account changes in direction far better than the vector approach. I've also considereed treating 0 degrees as 360 degrees however this leads to problems as well.
 
A better way of viaulizing the pressure, Harmonic statements is visual a wind senser fan/vane combination. You have not enough wind to cause a change direction but enough for cause minute shifts. At the same time the fan is turning clockwise, then counter clock wise with out the vane spinning 180 degrees ( not enough wind to change it to reflect the change in harmonic wind direction) by the way the job I was asked to do was to see if I could improve the accuracy of the overall system. I did get paid for the job as the filters did improve the system however it took extensive work to figure out the causes. How much force was needed to move the vane (direction axis) ignoring reverse fan movements where there was not enough force to cause a change in direction axis. As well as the movements of the speed fan that were occuring while there was no steady wind.
 
Last edited:
I wouldnt call this "high-level math". We are (mostly) average dudes confronted with irritating interesting real-world problems.
This is the original challenge:
Peter Nachtwey said:
Here is a good one though and not too difficult, calculate the average wind direction when sampling every minute. Most of the time it will be easy because the wind will not come from the north but if it does it will come from 355 degrees some times and 05 degrees other times and the average is 180 which isn't right.
Should the direciton be weighted by the wind speed? How would you do that?
The challenge has been set without proper definitions.
It will be possible to calculate both average speed and average direction with or without weighting for each other.

I am sure there are proper terms for this, but since I dont know them I will suggest "average absolute wind speed", "average relative wind speed", "average absolute wind direction" and "average relative wind direction"
In practical terms, I can imagine a use for average absolute wind speed, average relative wind speed, and average relative wind direction. But I cannot see a use for average absolute direction. I might be wrong though.
Peter didnt tell us which one(s) we were supposed to find, or what conditions that apply so that we could deduce it by ourselves.

Average absolute wind speed ignores the direction. Simply sample the absolute wind speed value, and ignore the direction. Thus the problem of the 360 to 0 degrees transition becomes moot.
Average absolute wind direction ignores the speed. Simply sample the direction as x/y-vectors, assuming a fixed nominal wind speed. The "problem" of the 360 to 0 degrees transition disappears in the proces.
Average relative wind speed takes the direction into account. It is simple to sample as x/y-vectors, and then convert back to a speed and direction vector in the end. So both average speed and direction are calculated in one go. The "problem" of the 360 to 0 degrees transition disappears in the proces.

As to the average wind direction value, there are more serious problems to consider.
To take Peters example and change it a little, if the wind direction is 5 degrees half the time and 175 degrees the other half of the time, is the average direction then 90 degrees ? Mathematically yes, but in many practical applications certainly not.
I think this must be a classical statistics problem. If you have two peaks or in a set of sampled values, is the middle value between the two peaks representative or not ?
I think that a statistics person will answer that one shall first analyse the data to find out what characteristics are dominant, and then find what model matches the data best. A statistician will answer that the wind direction in the region was changing between 5 and 175 degrees. He would not say that the average was 90 degrees.
 

Similar Topics

I found this code today in a running machine. This routine executes but the bit to call it is only written to inside this same routine... so how...
Replies
7
Views
2,044
Ok simple one let's start counting with pictures thread as a bit of Fun. Rules - Picture must be +1 higher than the previous picture -...
Replies
41
Views
11,153
I recently came across a scale slot car drag racing track used for $4500. The racer in me was like cooool. The programmer in me was like, I can...
Replies
6
Views
2,738
I believe I posted something about this last year but here it is again. This Spud Gun has a removable breech that holds the igniter, which is...
Replies
3
Views
2,198
I received my Alexa Echo yesterday and I'm looking forward to automating the home. But I wondered just what other amazing things I can do with...
Replies
36
Views
9,798
Back
Top Bottom