Show Posts
Pages: [1] 2 3 ... 5
1  Development / Other Software Development / Re: MAX31855 library on: January 25, 2014, 07:00:42 am
Hi Rob,

thanks for the fix. Fortunately we have sub zero temperature outside so I can test your new code  smiley

Greetings,
Jan
2  Development / Other Software Development / Re: MAX31855 library on: January 20, 2014, 07:46:24 pm
Hi Rob,

the offset seems to be constant over a wide range, but at the moment I´m blaming the MAX31855 itself. As I read the datasheet, it can only give +- 2°C readings.  Or am I getting something wrong where?

Quote
Can it be caused by not an exact 5V voltage?
I´m feeding 3,3 V from the 3,3V Arduino Pin to the 74HC4050 and these seem to be quite constant. Not as an LDO but usable, I guess.

But a bug in your Code is, that it cannot handle lower than 0°C temp. readings. As soon  as temperature drops below 0, the reading will be offset by 2048. Thus being -2047,5 for a temperature value of -0,5. Or maybe I just implemented it wrong, but I could not find any obvious mistake.

Best regards,
Jan


3  Development / Other Software Development / Re: MAX31855 library on: January 19, 2014, 03:16:51 pm
Hi Rob,

thanks again for another very useful library. I´m using a 74HC4050  high to low http://www.nxp.com/documents/data_sheet/74HC4050_CNV.pdf level shifter in order to read the values from a 4 channel MAX31855K Board (http://www.playingwithfusion.com/productview.php?pdid=20&catid=1001).
Now, I have a multimeter capable of measuring the Temp. with a K type thermocouple and the readings I get from the arduino implementation are allways 1 deg lower. Any Ideas why that could be? Tolerances of the MAX31855K ? Did you experience anything similar?

best regards,
Jan
4  Development / Other Software Development / Re: RunningAverage Class on playground (updated) on: October 28, 2013, 05:45:54 am
Hi there,

thank you  Sembazuru for pointing that out.  I guess that means I should have set "MEDIAN_MAX_SIZE" to somewhat around 200 and then define a
Code:
RunningMedian samples = RunningMedian(50);
Well, as I learned yesterday the RunningMedian takes more processing time as it needs to sort the array. As I´m taking my measurements each 50ms I guess that would not be an option - especially not with a large array size (which seem absolutley logical now to limit the array size). I´m now using the RunningAverage-library as I found my optimum array size for my setup via the tests I did. So everything is fine now. But I still wonder if the array size can be made user configurable during runtime.

@ivanseidel: Thank you for pointing me to your library. But I allready implemented the RunningAverage-library by Rob Tillaart and only needed some fine tuning (and understanding on whats going on behind the scenes). The last results I got were  suficiently constant. I just needed to adjust the array size to get the timing right (because a large array size means smoother data but more timeleg  on steep gradients ).

Best regards,
Jan 
5  Development / Other Software Development / Re: RunningAverage Class on playground (updated) on: October 27, 2013, 12:09:43 pm
Hi there,

just to complete the statements above, I made another series of measurements (see "Diff_Pressure_RunningAverage.pdf") using the same buffer sizes. But now I used RunningAverage again. As can be clearly seen, the output is as expected. I did not clear the variable as this is not necessary with these measurements.
so one may draw the conclusion  that there is something wrong with the code of the RunningMedian Library.

Here is the code sniplet where I calculate my RunningAverage for the differential pressure:
Code:
/*
 *************************************
 * Thread: THREAD_DifferentialPressure
 * Get`s the differential pressure.
 *************************************
 */

/* Global variables for this function */
float diff_Pressure_median = 0;
float diff_Pressure = 0;
float offset_diff_pressure;     // offset which can be set by the user -> FUNC_OffsetDiffPressure (X_E_LCDML_MenuFunctions)
int n_averaging;                // variable can be set by the user to define ow many measurements shall be averaged
RunningAverage diff_p_RA(200);   // use a uer defined size for the running averaging of the differential pressure
  /* --------- INIT ---------
     * Initialization of this function
     * is only being done once at the start of the function
     */
 void simpleThread_setup(THREAD_DifferentialPressure)
  {  
  /* Init Function */
  diff_p_RA.clear();              // Running Average for diff. pressure; explicitly start clean
  }
    
  /* --------- LOOP ----------
     * This is the place for code which is going to be repeated constantly
     * e.g. a time-diplay or the like.
     */
 boolean simpleThread_loop(THREAD_DifferentialPressure)
  {
  /* Loop Function */
  diff_p_RA.addValue(getDifferentialPressure()); // read out the sensor value and add to averaging variable
  // set averaged differential pressure  - pressure offset set by the user
  diff_Pressure = diff_p_RA.getAverage() - offset_diff_pressure;
  Serial.println(diff_Pressure);
  if (isnan(diff_Pressure) || diff_Pressure < 0.00)
  {
    diff_Pressure = 0.00;    // set diff_Pressure to zero if the reading is NaN - Not a Number, or lower than zero
  }
  return true;
  }

Best regards,
Jan

P.S.: I now added the raw data of these measurements.
6  Development / Other Software Development / Re: RunningAverage Class on playground (updated) on: October 27, 2013, 11:10:36 am
Hi Rob,

I did some more measurements and used RunningMedian instead of RunningAverage. The Code I used can be found here:
Code:

/*
 *************************************
 * Thread: THREAD_DifferentialPressure
 * Get`s the differential pressure.
 *************************************
 */

/* Global variables for this function */
float diff_Pressure_median = 0;
float diff_Pressure = 0;
float offset_diff_pressure;     // offset which can be set by the user -> FUNC_OffsetDiffPressure (X_E_LCDML_MenuFunctions)
int n_averaging;                // variable can be set by the user to define ow many measurements shall be averaged
RunningMedian diff_p_RA(200);   // use a uer defined size for the running averaging of the differential pressure
  /* --------- INIT ---------
     * Initialization of this function
     * is only being done once at the start of the function
     */
 void simpleThread_setup(THREAD_DifferentialPressure)
  {  
  /* Init Function */
  //diff_p_RA.clear;              // Running Average for diff. pressure; explicitly start clean
  }
    
  /* --------- LOOP ----------
     * This is the place for code which is going to be repeated constantly
     * e.g. a time-diplay or the like.
     */
 boolean simpleThread_loop(THREAD_DifferentialPressure)
  {
  /* Loop Function */
  diff_p_RA.add(getDifferentialPressure()); // read out the sensor value and add to averaging variable
  // set averaged differential pressure  - pressure offset set by the user
  diff_Pressure = diff_p_RA.getAverage() - offset_diff_pressure;
  diff_Pressure_median = diff_p_RA.getMedian() - offset_diff_pressure;
  Serial.print(diff_Pressure);
  Serial.print(";");
  Serial.println(diff_Pressure_median);
  if (isnan(diff_Pressure) || diff_Pressure < 0.00)
  {
    diff_Pressure = 0.00;    // set diff_Pressure to zero if the reading is NaN - Not a Number, or lower than zero
  }
  return true;
  }
The results of these measurements can be found in the attached pdf file "Diff_Pressure_averaged_median.pdf". Now there is something strange about the averaging value. The buffer size seems not to change.  even the 200 value buffer size ("RunningMedian diff_p_RA(200); ") looks more like the 25 or even 10. The RunningMedian Code I used is from your (Rob Tillaart) github repository. Furthermore, I expected something else from the RunningMedian. Let me know what you think.

Best regards,
Jan

P.S.: I now added the raw data of these measurements.
7  Development / Other Software Development / Re: RunningAverage Class on playground (updated) on: October 27, 2013, 07:05:59 am
Hi Rob,

thanks for the help! Another thing I was stumbling upon was the question if there were any possible chances of creating an RA-array:
Code:
RunningAverage diff_p_RA(50);
in a way that the size (int) would be user configurable during runtime? Now, as I understand it, there is quite a fuz about growing or reducing an array during runtime - meaning that it is not that simple. However, maybe you have an idea for an approach one could try implementing. Maybe, using a fixed large array of the maximum expected size (200 would be a reasonable value -I guess) and then only using parts of that array - as the user defines the averaging to be done between 0 and 200 values.

Best regards,
Jan
8  Development / Other Software Development / Re: RunningAverage Class on playground (updated) on: October 27, 2013, 06:54:49 am
ANSWER BY ROB TILLAART (send by e-mail):

In the example (of the RunningAverage library) I am clearing the RA variable every 300 count so people see how it can be done and what its effect is on the RA. And that effect is exactly what you see in the RA, the smooth line breaks. The number 300 is just arbitrary.

There can be several reasons why one wants to clear the RA var.
(1) one starts a (really) new series of measurements, Suppose one makes a RA measurement of the light-intensity for one minute once per hour. Then you really want to start clean to make the measurements independent.
(2) when you switch to another range of your input , e.g. you switch the analogReference of a VoltMeter sketch from 5.0 to 1.1Volt.
(3) when you switch the timing between the values, if you have a series with a 1 second interval and you change the interval to 1 minute you must clear the RA otherwise you will compare apples with pears.
(4) when the value measured changes more than a certain value (jumps to another level) one might want to follow immediately.
 In the PDF's on the forum post (see link above) there is such a jump around 500 and 900.

That said, in most sketches that run continuously do not need to clear/reset the RA. it can go on and on and on forever.

On the forum there is also the question about fillValue(value, number);
This function can be used to initialize the RA on a certain value with a certain weight,
Example (assume buffersize = 10
if you do a clear() followed by a addValue(100); the RA will be 100. another addValue(50) will set the RA to 75.0.
if you do a fillValue(100, 10), followed by a addValue(100); the RA will be 100, another addValue(50) will set the RA to 95.0,
if you do a fillValue(100, 5), followed by a addValue(100); the RA will be 100, another addValue(50) will set the RA to 92,8571...,

So fillValue has its use especially at the start of a measurement
9  Development / Other Software Development / Re: RunningAverage Class on playground (updated) on: October 22, 2013, 04:47:56 pm
Hi there,

I´m using the runningAverage library and got some problems when clearing the averaging variabel every 300 counts.
Now, I did a Measurement series showing my raw sensor data and the avaregd data (see attached Differenzdruck_gemittelt_100.pdf). Looking at these curves, it is clearly visible that my avareged sensor data is going bogus when the averaging variabel is cleared after 300 samples. Now, looking at the library I found the option to use the a "fillvalue" instead. As the code is not that good commented, I just thought to ask what it actually does. However, Im loosing the peaks in my sensor data but seems to oscillate now. Well, to make a long story short, could someone explain the fillvalue feature of the running average library in more detail.

Code using the running average (plain and simple)
Code:
/*
 *************************************
 * Thread: THREAD_DifferentialPressure
 * Get`s the differential pressure.
 *************************************
 */

/* Global variables for this function */
float diff_Pressure = 0;
float offset_diff_pressure;              // offset which can be set by the user -> FUNC_OffsetDiffPressure (X_E_LCDML_MenuFunctions)
RunningAverage diff_p_RA(100);            // use default size for running average for differential pressure
int diff_p_samples = 0;                  // create a samples counter
  /* --------- INIT ---------
     * Initialization of this function
     * is only being done once at the start of the function
     */
 void simpleThread_setup(THREAD_DifferentialPressure)
  {  
  /* Init Function */
  diff_p_RA.clear();                     // Running Average for diff. pressure; explicitly start clean
  }
    
  /* --------- LOOP ----------
     * This is the place for code which is going to be repeated constantly
     * e.g. a time-diplay or the like.
     */
 boolean simpleThread_loop(THREAD_DifferentialPressure)
  {
  /* Loop Function */
  diff_p_RA.addValue(getDifferentialPressure()); // read out the sensor value and add to averaging variable
  diff_p_samples++;                      // increase samples counter
  // set averaged differential pressure  - pressure offset set by the user
  diff_Pressure = diff_p_RA.getAverage() - offset_diff_pressure;
  Serial.println(diff_Pressure);
  if (diff_p_samples == 300)             // handle large samplenumbers...
  {
    diff_p_samples = 0;                // ...delete samples counter, and...
    diff_p_RA.clear();                 // ...clear the averaging variable.
  }
  else if (isnan(diff_Pressure) || diff_Pressure < 0.00)
  {
    diff_Pressure = 0.00;    // set diff_Pressure to zero if the reading is NaN - Not a Number, or lower than zero
  }
  return true;
  }

Same code using the running average wih the fill value option:
Code:
/*
 *************************************
 * Thread: THREAD_DifferentialPressure
 * Get`s the differential pressure.
 *************************************
 */

/* Global variables for this function */
float diff_Pressure = 0;
float offset_diff_pressure;              // offset which can be set by the user -> FUNC_OffsetDiffPressure (X_E_LCDML_MenuFunctions)
RunningAverage diff_p_RA(100);            // use default size for running average for differential pressure
int diff_p_samples = 0;                  // create a samples counter
  /* --------- INIT ---------
     * Initialization of this function
     * is only being done once at the start of the function
     */
 void simpleThread_setup(THREAD_DifferentialPressure)
  {  
  /* Init Function */
  diff_p_RA.fillValue(0,50);                     // Running Average for diff. pressure; explicitly start clean
  }
    
  /* --------- LOOP ----------
     * This is the place for code which is going to be repeated constantly
     * e.g. a time-diplay or the like.
     */
 boolean simpleThread_loop(THREAD_DifferentialPressure)
  {
  /* Loop Function */
  diff_p_RA.addValue(getDifferentialPressure()); // read out the sensor value and add to averaging variable
  diff_p_samples++;                      // increase samples counter
  // set averaged differential pressure  - pressure offset set by the user
  diff_Pressure = diff_p_RA.getAverage() - offset_diff_pressure;
  if (diff_p_samples == 300)             // handle large samplenumbers...
  {
    diff_p_samples = 0;                  // ...delete samples counter, and...
    diff_p_RA.fillValue(diff_Pressure, 25); // ...clear the averaging variable.
  }
  else if (isnan(diff_Pressure) || diff_Pressure < 0.00)
  {
    diff_Pressure = 0.00;    // set diff_Pressure to zero if the reading is NaN - Not a Number, or lower than zero
  }
  return true;
  }


Thank you for any help.
Best regards,
Jan
10  Using Arduino / Programming Questions / Re: Multiple Boolean Conditions on: October 19, 2013, 11:48:30 am
Thanks for the help Msquare,

I figure the problem is somewhere within the simpleThread_isRun() Function I´m using. So I guess I have to do some more pocking around. However, good to know that my initial sample (expanded by the brackets jimmy suggested) is a go.

Best regards,
Jan

11  International / Deutsch / Re: Projektvorstellung: simpleThreads auf dem Arduino mit Hilfe von Makros on: October 19, 2013, 11:42:27 am
Hallo Jomelo,

hast Du nen Tip warum:
Code:
    if (simpleThread_isRun(THREAD_InitControl) == true){Serial.print("Here we go!");}

nicht compiliert? Der THREAD_InitControl exisitiert natürlich. Die oben gezeigte Abfrage wird in einem anderen Thread auseführt (also nicht in THREAD_InitControl).

Beste Grüße,
Jan
12  Using Arduino / Programming Questions / Re: Multiple Boolean Conditions on: October 19, 2013, 11:08:42 am
Thanks for the help. I tried with the brackets, it would not compile either.
Here is the code I´m using:

Code:
boolean simpleThread_loop(THREAD_LEDBlink)
  {
  /* Loop Function */
  if ((use_Relay_block == 1 && Relay_block == true) || (simpleThread_isRun(THREAD_InitControl) == true))
  {
    // take control over the LEDs
    LED_control = 1;
    // Dynamic Display showing a blinking call sign to signal user that relay is blocked
    odd_even = !odd_even; // alternating operator used to display the call sign
      if (odd_even){ // Even
         digitalWrite(LEDPin_red, HIGH); // red LED off
      }
      else {  // Odd
         digitalWrite(LEDPin_red, LOW); // red LED off
      }
  }
  else{
    // Dont take control over the LEDs
    LED_control = 0;
  }
  return true;
  }

and that is the compiler error I get:
Code:
X_D_ThreadsFunctions.ino: In function 'boolean simpleThread_loop_THREAD_LEDBlink()':
X_D_ThreadsFunctions:377: error: expected `)' before ';' token
X_D_ThreadsFunctions:377: error: expected `)' before ';' token
X_D_ThreadsFunctions:377: error: expected primary-expression before '==' token
X_D_ThreadsFunctions:377: error: expected `;' before ')' token
Z_Loop:21: error: expected `}' at end of input
13  Using Arduino / Programming Questions / Re: Multiple Boolean Conditions on: October 19, 2013, 10:55:51 am
Thanks for the fast answer Paul.
 But actually i cant compile my sketch when I implement the if statement above. Anyhow, I thought it would be some limitation of the IDE.
I guess I have to dig some deeper now that I know that this should work in principle.

Best regards,
Jan
14  Using Arduino / Programming Questions / Multiple Boolean Conditions on: October 19, 2013, 10:44:03 am
Hi there,

could anyone just point out to me, why a statement such as:

Code:
if (conditionA && conditionB) || (conditionC) {
  // do This
}
else{
 // do That
}

would not work in the Arduino IDE?

I cannot find any reasonable explanation.

Thanks and best regards,
Jan
15  Using Arduino / Sensors / Re: SensorTechnics i2c Pressure Sensor on: October 18, 2013, 08:47:40 pm
Hi Steve,

using more than 2 Sensortechnics I2C Sensors is no problem at all. But it is necessary to programm the adresses before you solder your sensors to your board. Sensortechnics has a evaluation board (which i cannot find a datasheet for on their homepage) which can be used to program the adresses into the sensors. Thus, the full range of 127 adresses can be exploited. Consequently, you could use 127 Sensors on one I2C-bus. However, SDA and SCL line capacitance will prevent you from doing so.
Now I suspect you could ask Sensortechnics to program your sensors with different adresses when you order from them directly. I've never done this, though. I allways programmed the adresses myself with an eval-board I have available. They are quite expensive none the less (~400 Euro).

Hope these information will be helpful at some point. Using the I2c interface on these sensors has still some advantages. You get a build in measuring amplifier, filtering capabilities and a somewhat cripled temperature readout. Additionally you do not have to bother about ADC, as that would significantly largen the footprint of your PCB. Presupposed you need more than the 10 bit provided by the arduino.

Best regards,
Jan
Pages: [1] 2 3 ... 5