Simplify Your Sensor Installation Using Wind Direction Offsets

通过 Jacob Davis | 更新: 06/13/2022 | 评论: 0

相关博客帖子


搜索博客


订阅博客

出现新文章时获得邮件。选择您感兴趣的主题。


Area / Application

Product Category

Activity

输入您的邮箱地址:



推荐文章

您是否想了解一个主题更多?请让我们知道。

Leave this field empty

weather vane

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:

  • 20 MOD 360 = 20
  • 380 MOD 360 = 20
  • 740 MOD 360 = 20

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.


分享该文章



关于作者

jacob davis Jacob Davis is the Director of Client Services and Support at Campbell Scientific, Inc. He works with the worldwide technical support teams. His specialties include serial communications and advanced data logger programming. Jacob has a master’s degree in Hydrology and worked with large irrigation projects before coming to Campbell Scientific, Inc.

查看该作者的所有文章


建议

Please log in or register to comment.