Sigmoid wave form is generating a wrong value

Related to the development libraries, released by Curt Binder

Posts: 12306
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Thu Sep 18, 2014 3:18 pm
The sigmoid wave form is outputting the wrong value in the center of the peak.
This is what I used to generate the plot:
Code: Select all
PWMSigmoid(8,0,20,0,0,100,0)

Right in the middle, it output 50 instead of 100.
https://github.com/reefangel/Libraries/issues/194
Roberto.

Posts: 263
Joined: Wed Jan 01, 2014 7:26 am
PostPosted: Thu Sep 18, 2014 5:20 pm
Weird. I use it every day and didn't see that. I'll check it out.

Posts: 263
Joined: Wed Jan 01, 2014 7:26 am
PostPosted: Thu Sep 18, 2014 5:37 pm
Is it really exactly in the middle? The math is pretty simple, but I can maybe see a way that it would generate a different number in the center since it isn't totally continuous, when (current-start) = FWHM there doesn't seem to be a value set, since I just had done < and >, not <=, for instance. Also, FWHM is exactly in the center, so it would fit with happening at that spot.

Before I do a commit to change it, can you just add an equal sign, like this:

Code: Select all
    if ((current >= (start + FWHM)) && (current < (end - FWHM)))


Since FWHM is at the exact halfway point, that if should be satisfied for either of them if you have an = sign in there, but it doesn't hurt to have them both. They should both give the same value.

It won't be exactly 100%, by the way, but something very close. Within 1% of 100%.

Posts: 12306
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Fri Sep 19, 2014 8:52 am
No. that did not fix it.
Roberto.

Posts: 12306
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Fri Sep 19, 2014 8:56 am
This is the code I used for testing:
Code: Select all
#include <Salinity.h>
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <ReefAngel.h>

void setup()
{
  ReefAngel.Init(); 
  setSyncInterval(SECS_PER_HOUR*6000);
  delay(500);
  wdt_reset();
  delay(500);
  wdt_reset();
  delay(500);
  wdt_reset();
  delay(500);
  wdt_reset();
  delay(500);
  wdt_reset();
  delay(500);
  wdt_reset();
}
//ReefAngel.PWM.
void loop()
{
  while(1)
  {
    wdt_reset();
    Serial.println(PWMSigmoid(8,0,20,0,0,100,0));
    adjustTime(60);
    delay(1);
  }
  ReefAngel.ShowInterface();
}
Roberto.

Posts: 12306
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Fri Sep 19, 2014 9:00 am
I think this code could even be changed up a bit to allow us to run for 24hrs and allow us to see how the pattern looks in the tank within a short span of time.
Kind of like press preview and the controller adjusts the LEDs to show how the pattern would look like. What do you think?
The only caveat is that all other functions that use time would be affected too. :(
Roberto.
User avatar
Posts: 5362
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Fri Sep 19, 2014 9:25 am
That sounds cool
User avatar
Posts: 5362
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Fri Sep 19, 2014 9:58 am
rimai wrote:The only caveat is that all other functions that use time would be affected too. :(


The only thing I would worry about that is the dosing pumps, how quick do you run through the 24 hour window? I think a simple flag to not run the dosing pumps during the preview would suffice...

Posts: 263
Joined: Wed Jan 01, 2014 7:26 am
PostPosted: Fri Sep 19, 2014 10:58 am
That code is a great idea! I never thought about doing it that way.

Return to Development Libraries

Who is online

Users browsing this forum: No registered users and 3 guests

cron