As you may know, it can be quite challenging to perfectly align the north mark of a wind direction sensor with true north. For example, when you’re on a ladder handling tools or hanging on a tower, you don’t have a spare hand to hold a compass. Things can get more complicated when a sensor moves as you tighten bolts. Fortunately, you can use a method that has been employed for years to ease installation: a sensor direction offset.
When you use a direction offset, you will get perfectly good data as long as the offset is correct. For example, a sensor could be mounted 20 degrees west of true north such that a reading of zero degrees from the sensor is in fact 20 degrees east of true north. Just get a good measurement of the offset and then adjust all readings. For the example above, add 20 degrees because the direction is left of true north. A well-mounted sensor won’t shift in its mountings. The offset will be valid until a sensor is taken down for maintenance.
There is another reason for using an offset mounting angle. Most mechanical wind vanes have a deadband. The deadband is a range of several degrees that can’t be read, and the deadband is usually aligned with north. If your prevailing wind at the site is north, it is recommended to move the deadband to a leeward, or downwind, direction.
When applying an offset, you need to consider the zero crossing. If you add an offset of 20 to a reading of 350, you get 370 degrees, which is over 360 degrees. If the offset is -20 and you have a reading of 10, the result is -10 degrees. So, a bit of math is needed to keep within the range of 0 to less than 360.
One effective way to apply the offset correctly is to use a series of If/Then statements. For example:
WindDir_Temp = WindDir + WindOffset 'Apply offset in a temporary variable If WindDir_Temp < 0 Then WindDir_Temp += 360 'Add 360 if negative ElseIf WindDir_Temp >= 360 Then WindDir_Temp -= 360 'Subtract 360 if greater than or equal to 360 EndIf WindDir_Corrected = WindDir_Temp 'Copy answer to corrected variable
While it is effective, this programming can be a bit messy. The programming is much simpler if you use the MOD operator, as in this example:
WindDir_Corrected = (WindDir + WindOffset + 360) MOD 360
Note that the parentheses are important, as they will enforce the proper order of operations.
When the offset is applied, also add 360 to keep the result positive. It may put that result over 360, but don’t worry. Without adding 360, you would not be allowed to use a negative offset.
The MOD operator divides and returns the remainder. MOD 360 will keep the final result under 360. Consider the following:
The 360 added with the offset keeps the result positive when needed and is removed by MOD when not needed.
So, a single programming line using MOD can replace seven lines using If/Then statements. A complete program example is provided below:
ConstTable (Configuration) Const WindOffset As Float = 20 EndConstTable Public WindDir Public WindDir_Corrected Units WindDir=degrees 'Main Program BeginProg 'Main Scan Scan(1,Sec,1,0) '03301 Wind Direction Sensor measurement 'WindDir' BrHalf(WindDir,1,mV5000,1,VX1,1,2500,True,20000,60,352,0) If WindDir>=352 OR WindDir<0 Then WindDir=0 'Example using MOD: ' Add 360 with offset to keep value positive. ' MOD 360 divides by 360 and returns remainder. WindDir_Corrected = (WindDir + WindOffset + 360) MOD 360 NextScan EndProg
I hope the small addition of MOD to your code will simplify sensor installation for you. If you have any questions or comments about using wind direction offsets, please post them below. As always, please follow the established safety procedures when installing wind sensors.