Jump to content

Banner.jpg.b89429c566825f6ab32bcafbada449c9.jpg

Weather Station Ideas


Gina

Recommended Posts

Since the Mean Speed is summed over a long period I could read it to greater precision than integer but I guess wind speed in whole miles per hour is quite sufficient and "if it ain't broke, don't fix it".  The gust speed is only accurate to units of 1.5mph as the calibration factor is mph in 4.5s and I'm reading in 3s periods and correcting afterwards.

The test rig has been running correctly for a while now so I guess I can put everything back together and put the rig back on the observatory.  Having found a definite cause of problems and fixed it I feel reasonably confident that it should be ready for deployment - again.

The anemometer rotation rate has just increased a bit - guess the mains voltage has increased and with it the fan speed.  I'll just watch it a bit longer and see if the mean speed increases too as it should (slowly).

920075118_Screenshotfrom2020-09-0513-12-04.png.1b087eca5deb8cfd3445b06c3cc76fd9.png

Edited by Gina
Link to comment
Share on other sites

Mean speed has now increased to 10mph.

Got one more test before deploying the wind sensors - reduced the fan speed.  Now watching for the speed readings to decrease over the next 10m or so.  I don't expect the gust speed to change until more than 10m have elapsed but the mean speed should gradually decrease over the 10m period.

Edited by Gina
Link to comment
Share on other sites

Update...  Gust gauges now show zero so it seems the 73mph was an instantaneous value which propagated through the gust ringArray until it was replaced by the correct zero value.  I'll do some more testing...

Fan on low and anemometer rotating at about 1 rev per second.  Gust showing 3mph.

Edited by Gina
Link to comment
Share on other sites

Urck!!  Just thought I'd test the rig with the top assembled.  Doesn't look like it'll be deployed today!!  Fan on and 10mpg gust speed.  Mean rose to 9 as usual.  Turned fan off and let the anemometer slow down and stop.  While this is only a display and for information only I don't really want ridiculous readings!!

257202525_Screenshotfrom2020-09-0515-46-26.thumb.png.77b97d85e6352afcd4fa746e1b5359f5.png

After 10m the giant gust had propagated round the ring Array and the mean speed gone down to zero.  Next minute the gust speed read zero too.

1800821222_Screenshotfrom2020-09-0515-56-38.thumb.png.3193173d2d9ccfa84a90354bbb207a02.png

Edited by Gina
Link to comment
Share on other sites

What to do now - that's the question...

The mean speed seems to be working alright now.  Mostly the gust speed is alright but sometimes getting these rogue values.  Guess it's time to add some debugging.

Link to comment
Share on other sites

Watching the ringIndex, windGust and windSpeed.  Got the fan a bit closer and gust speed of 13mph.  Number is the raw gust speed (counts in 3s) and Number2 is the speed summed over 21 3s intervals for the mean.  Next to switch off the fan and see what happens.  I may have to extend the debugging to show all the ringArray values - quit a lot of data!

661996661_Screenshotfrom2020-09-0516-53-06.thumb.png.6fcb7b847eab8ab562064b2e5898b374.png

Link to comment
Share on other sites

Fan and anemometer stopped and this :-

2030256417_Screenshotfrom2020-09-0517-02-24.thumb.png.95c22a56a7a79d0826ad96734e44ca1e.png

Followed by this :-
470653128_Screenshotfrom2020-09-0517-04-23.thumb.png.3cac401bbaf4e37d5af7e9be39064385.png

Showing one rogue raw gust value (of 17 equating to a speed of 25mph) followed by the correct zeros.  So where did that rogue raw count come from???

As usual the rogue gust value persisted in the gust ringArray until replaced by 10 zeros (ringIndex=1).

The rogue value only seems to exist in the windGust variable - there is no sign of any perturbation in the windSpeed, eliminating a rogue PulseCount value.  This limits the part of the code under suspicion to the timer ISR code relating to the gust speed.

void IRAM_ATTR onTime() {
  portENTER_CRITICAL_ISR(&timerMux);
  interrupts=1;
  windSpeed += PulseCount;  //  Accumulate mean speed
  if (PulseCount > windGust) {windGust = PulseCount;};  // Get max speed for gust
  PulseCount = 0; // clear count 
  timerCount++;  // count number of timer interrupts for 1m speed sum                                      
  portEXIT_CRITICAL_ISR(&timerMux);
}

This would appear to be the line of code that causes the rogue gust speed

  if (PulseCount > windGust) {windGust = PulseCount;};  // Get max speed for gust

Or is it???  If windGust is high when this line of code is run it won't be changed!

Edited by Gina
Link to comment
Share on other sites

This leads to this code where the windGust variable was last accessed.

void speed21sum(){
  int divisor = 140;
  sendringIndex();
  sendNumberMessage(windGust);
  sendNumberMessage2(windSpeed);
  // wind speed mean and gust ring arrays and report
  meanArray[ringIndex] = windSpeed; // put windSpeed into new array index
  gustArray[ringIndex] = windGust;  // put windGust into new array index
  meanSpeed = 0; gustSpeed = 0; windSpeed = 0; windGust = 0;
  for (int i = 0; i < 10; i++) { 
    meanSpeed += meanArray[i];  // sum the windSpeeds 
    if (gustArray[i] > gustSpeed){gustSpeed = gustArray[i];}} // find maximum gust speed
  divisor = timerCount * 10 / 1.5;  // with timerCount=21 this gives a whole number
  meanSpeed /=divisor;  // the first sum was over 21 values and then the second over 10 values
  gustSpeed *= 1.5;  // Speed count over 3s rather than 4.5s
  sendSpeedMessages();
  ringIndex = (ringIndex+1)%10; // move ringIndex on to next location in the ring arrays
}

windGust is reset to zero in this code.  Q.E.D.!!!

I've been through the sketch with Find and there are no occurrences of any of the variables in question other than where I've looked.

I thought one possibility might be that the anemometer stopped right on the edge of the Hall sensor operation and vibration caused multiple pulses but if this happened the mean value would show a small jump, which it doesn't seem to do.  To be sure I would have to check the PulseCount at each timer interrupt event.

Link to comment
Share on other sites

Vibration causing a one-off blip in the pulse that doubles the gust will not really show in the mean as you are averaging over a large number of pulses and only showing the average in round mph.  One of your earlier tests had a larger gust blip and there was an increase in the mean then too.

I suggest you re-run the test but rather than turning off the fan (with associated vibrations) put a piece of card in the way to divert the wind - very carefully so as not to knock anything.

You'll then know if it's a physical vibration issue or some problem in the code when pulses stop.

Edited by globular
  • Like 1
Link to comment
Share on other sites

To see if it is a burst of pulses as the anemometer stops I think I'll save the PulseCount into a ringArray in the timer ISR then read out the ringArray outside the ISR.

Link to comment
Share on other sites

This is the run up.  The PulseCount is in Number.  Mainly showing 8 counts which equates to 12mph but peaking 9 which equates to 13.5mph so 13mph for the gust speed is right and 12mph mean speed is right.  Now for the run down...

1905461958_Screenshotfrom2020-09-0519-58-16.thumb.png.663c968d6b92c4e3ea1af4ed7ef1846c.png

Link to comment
Share on other sites

1 hour ago, globular said:

Vibration causing a one-off blip in the pulse that doubles the gust will not really show in the mean as you are averaging over a large number of pulses and only showing the average in round mph.  One of your earlier tests had a larger gust blip and there was an increase in the mean then too.

I suggest you re-run the test but rather than turning off the fan (with associated vibrations) put a piece of card in the way to divert the wind - very carefully so as not to knock anything.

You'll then know if it's a physical vibration issue or some problem in the code when pulses stop.

I think you may have a good point so I've moved the fan off the table onto a different "perch" that won't transmit any vibration to the table.  Plenty of space between fan and anemometer so no problem with a piece of cardboard to stop the breeze.

Link to comment
Share on other sites

Steady state.  Less breeze.

100218999_Screenshotfrom2020-09-0520-21-19.thumb.png.b6068043e520bb02f08f72b66478c7cd.png

With wind break!  Voila - no rogue gust.  But this is only one sample I'll need to repeat.
454334963_Screenshotfrom2020-09-0520-25-22.thumb.png.6528d8c73bfc10dc24a93d4525da4f2b.png

Edited by Gina
Link to comment
Share on other sites

Next test.  Anemometer was stationary when the pulse occurred!

134284638_Screenshotfrom2020-09-0520-39-05.thumb.png.d266595d848e1d663441be2633894907.png

Tried tapping the table to produce vibrations but no pulses!
1907382412_Screenshotfrom2020-09-0520-47-21.thumb.png.d73b361c268e797898bad821417aa0ca.png

1907382412_Screenshotfrom2020-09-0520-47-21.thumb.png.d73b361c268e797898bad821417aa0ca.png

Gust cleared out of the ringArray.
730184233_Screenshotfrom2020-09-0520-53-34.thumb.png.9e18a3ddde377147d30036694e90fb0d.png

Link to comment
Share on other sites

I'd still like to see some more consistency with your variable types. Mixtures of int, long and float together, without explicitly converting when cross assigning, seems a recipe for disaster; as does having int variables being divided and/or multiplied by 1.5 without explicitly saying how you want the remainders to be treated.
Probably not the issue you're seeing - but until it's ruled out it just might be.  

Link to comment
Share on other sites

The rogue PulseCount only occurs when the anemometer is stationary.  I have never seen anything wrong when the anemometer is rotating.

There are no float types in this sketch.  All variables are either integer types, strings or char arrays.  The latter are needed by MQTT.  I could multiply by 3 and divide by 2 rather than multiply by 1.5 I guess but all the calculations now appear to be correct.

I guess I could just detect the rogue value and reject it but I would rather know the cause.

Link to comment
Share on other sites

In integer arithmetic the remainder is simply discarded, no rounding up is applied if the remainder is above half.  I agree that this means division should be left until the end of a calculation to keep as much precision as possible provided no values exceed the range of the particular integer type.  I'll go through my code and apply that principle where possible.

Edited by Gina
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.