New Page 2

 

Welcome to SDR!

  • Amused
  • Angry
  • Annoyed
  • Awesome
  • Bemused
  • Cocky
  • Cool
  • Crazy
  • Crying
  • Down
  • Drunk
  • Embarraded
  • Enraged
  • Friendly
  • Geeky
  • Grumpy
  • Happy
  • Hungry
  • Piratey
  • Poorly
  • Sad
  • Shy
  • Sneaky
  • Tired
  • + Reply to Thread
    Results 1 to 7 of 7

    Thread: What is the formula for this graph?

    1. #1
      sushi is offline Registered User
      My status is: pee in tank
       
      I am:
      Set you mood here...
       
      Join Date
      Jul 2015
      Location
      Mira Mesa
      Posts
      1,997

      What is the formula for this graph?

      Hello, I am a math idiot, if I want to make a formula that will produce this graph where I can adjust the maximum lighting intensity and full length of the cycle, what would the graph be? I want to use it for my light cycle, currently it is just a linear increase and decrease, not a curve.


    2. #2
      Kris is offline Registered User
      My status is: End of the journey
       
      I am:
      Tired
       
      Join Date
      Apr 2013
      Location
      Oceanside CA.
      Posts
      1,364
      Ask me about feed ing corals, or something easy to splane> It's a sine wave, but how that fits in your math progam on a pi is not my fortae,

      https://en.wikipedia.org/wiki/Sine_wave

      gl, ho this heapls

      approx = 100Sin(x/pi)

      https://graphsketch.com/
      Last edited by Kris; 03-01-2017 at 09:23 PM. Reason: for 100% light and ~ 10 hour day, but my math prolly sux too?

    3. #3
      sushi is offline Registered User
      My status is: pee in tank
       
      I am:
      Set you mood here...
       
      Join Date
      Jul 2015
      Location
      Mira Mesa
      Posts
      1,997
      I don't know if a sine wave function will work because the slope changes more gradually at the ends like a bell curve... I have been googling more for the equation of a bell curve and this seems to work

      y=1/(e^(x^2.4))



    4. #4
      Kris is offline Registered User
      My status is: End of the journey
       
      I am:
      Tired
       
      Join Date
      Apr 2013
      Location
      Oceanside CA.
      Posts
      1,364
      The bell curve never ends, it only approaches zero. Could work if the computer rounds off? the sin curve goes negative,(you only need 1/2 of it?) and how that all might fits into a light controller is a mystery me.

      The other issue is that your graph goes to 1, which is ok if your controller understands 0 as off and 1 = 100% light intensity? again, to me a mystery as I am not familiar with the modern reef automation computers and applications,... ? And if you are lighting LED's a lot of folk never ramp them 100% due to too much light?

      I'd keep it simple and use the old inverted V myself, as the straight line ramp up and down would probably approximate sun intensity reasonably well.

      What I wish I had was a rail system that would move my light (from east to west) over the tank to eliminate one sided coral exposure/day.

      Did you go snow boarding? I got dizzy watching the videos, and almost spilled my drinks.

    5. #5
      sushi is offline Registered User
      My status is: pee in tank
       
      I am:
      Set you mood here...
       
      Join Date
      Jul 2015
      Location
      Mira Mesa
      Posts
      1,997
      I can fix all that stuff, the numerator is the maximum intensity. So if I want my max intensity to go to 50% I just do 0.5/(e^(x^2.5)) and I can round the ends off at some cutoff point.

      To shift it I just take my total length of time I want and scale it from -1.8 t0 1.8. Here is how I can apply it with a gooseberry pi

      I use a seconds-since-midnight variable to control the timed functions of the tank.

      Sunrise = 8:00 am or 28,800 seconds since midnight
      Sunset = 5:00 pm or 61,200 seconds since midnight

      Every second the pi will check if the current time is between 28800 and 61200 seconds. If it is, I can calculate the percentage to set the lighting intensity like this:

      In this example the current time is 40000 seconds since midnight or 11:06am and 36 seconds

      Total cycle time (61200-28800): = 32400
      Seconds into cycle (40000-28800): 11200
      Current portion of cycle (11200/32400): 0.3456790123

      So we are 0.3456790123 into our curve that is 3.6 units long (-1.8 to 1.8) so we are at 0.3456790123*3.6 = 1.244444444

      So to get the input value just add 1.244444444 to -1.8 that is -0.555556 and I take the absolute value since my graph starts at 0, which is 0.555556

      Then I plug that into the equation

      0.5/(e^(0.555556^2.5)) = 0.39724749219 and that is my lighting percent

      I can stretch out the max intensity by increasing the power of x and reducing the curve length, I will make those configurable. Here is the pi code:

      Code:
      import sys
      import math
      
      startTime = 28800
      endtime = 61200
      curveLength = -1.8
      maxDutyCycle = 0.5
      xExponent = 2.5
      
      currentTime = 40000.0  #this will be updated every second
      
      percentOfCycle = (currentTime-startTime)/(endtime-startTime)
      
      positionInCycle = percentOfCycle*abs(curveLength)*2
      
      xValue = abs(positionInCycle + curveLength)
      
      dutyCycle = maxDutyCycle/(pow(math.e,(pow(xValue,xExponent))))
      
      print dutyCycle  #output is 0.397247674971
      
      #now I just use raspberry pi PWM functions to set my light dimmer to dutyCycle
      Also yes I went snowboarding yesterday and I tried putting my gopro on my helmet it was fun!!!!
      Last edited by sushi; 03-01-2017 at 11:21 PM.

    6. #6
      Kris is offline Registered User
      My status is: End of the journey
       
      I am:
      Tired
       
      Join Date
      Apr 2013
      Location
      Oceanside CA.
      Posts
      1,364
      I saw the vid of you sliding down the hill. I kept waiting for a collision as I am always watching "o-shoot another insane car, truck, motorcycle wreck" video compilations on utube, and I was waiting like a Pavlov dog for that agony of defeat moment and it never came? It was a nice day to be on top of the mountain, thanks for posting the slide.

      You lied about your math ability. I am not certain what a gooseberry is, but I know what a Kiwi is. They have fuzzy skin and are good in salad, and I can't program in Kiwi. The Pi looks doable, but I run my reef like a prison or the Marine Corps, 0600 hours lights on out of bed you maggot corals, full intensity oohrah for 8 hours and then it's lights out til tomorrow.
      (I feed at night when I feel like it.) I use the old fashion timer program with the punch card like dial,....Thanks for posting your program, pretty neat. I still think you could use a sine curve, but I can't figure out how. The only math I do now is counting these long days until all the lights finally go out.

      Hypothetically sent from my rotary dial phone using receiver clicks from an outpost out here in the dark net

    7. #7
      sushi is offline Registered User
      My status is: pee in tank
       
      I am:
      Set you mood here...
       
      Join Date
      Jul 2015
      Location
      Mira Mesa
      Posts
      1,997
      Here is a video of me falling! I don't want to ring the bell without providing any food

      https://youtu.be/KawKx6twVbc

    + Reply to Thread

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts