RPiAqua (Raspberry Pi Light Controller - In Progress) - Page 3 - The Planted Tank Forum
 6Likes
Reply
 
LinkBack Thread Tools Display Modes
post #31 of 103 (permalink) Old 08-06-2018, 08:00 PM Thread Starter
Planted Member
 
Kaiede's Avatar
 
PTrader: (0/0%)
Join Date: Sep 2017
Location: Seattle, WA
Posts: 246
Quote:
Originally Posted by jeffkrol View Post
Funny..
But pretty accurate. GitHub does show some statistics on traffic for projects, so I know how few people are poking at it.

Quote:
Originally Posted by jeffkrol View Post
Initial choice would be the choice..
An option of gamma vs linear is brilliant..
Number of separate curves or just one is debatable..If calculated.. not an issue if LUT then ??
I've got a change now that makes it so that you can specify intensity or brightness for any point in the schedule, and it will still do the math in terms of brightness and so changes will follow the gamma correction curve. So you get the linear looking ramp, while also being able to set your peak light levels based on the PAR you want to hit more easily. It also lets you specify the gamma to be something other than 1.8, but some of the juggling of state here is starting to get a little gnarly, so I'm hoping to not make it any more complicated than this without a chance to clean things up long-term. But if you want a ramp that behaves like the Bluefish, Fluval, or TC-420 ramps, you can just set the gamma to 1.0 and call it a day.

With the ARM chips in the Raspberry Pi, you've got hardware floating point available. On top of that, the Zero is a 1Ghz SoC. I'm not currently bothering with a LUT, and instead doing the math directly. The costs of talking to the PWM controller is more expensive than the math being done so far. I2C for the 16-channel PWM controller is kinda slow.

Quote:
Originally Posted by jeffkrol View Post
Arguable that it is "needed" (gamma dimming) in our use but certainly "proper"..
I guess it is more if you want the ramp going from off to on to look linear, or to follow some other curve. If you want to follow a different curve, then in some cases, the short-hand can be to just not use gamma correction at all.

I'm used to working with gamma for displays and photography, but when applying it here, I found it was difficult to create the schedule I wanted, because I couldn't think in terms of PAR like I wanted. I'd have to do the math myself to apply an inverse correction and get the brightness, when I had the intensity. That is not a great experience.

And I'm noticing that at least with the Fluval, Bluefish, TC-420 and quite a few others, it all operates on intensity (and calls it brightness). So the nomenclature is a bit of a mess in this space, I wanted to at least make sure I'm not losing my mind on doing it this way.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Kaiede is offline  
Sponsored Links
Advertisement
 
post #32 of 103 (permalink) Old 08-06-2018, 08:38 PM Thread Starter
Planted Member
 
Kaiede's Avatar
 
PTrader: (0/0%)
Join Date: Sep 2017
Location: Seattle, WA
Posts: 246
Quote:
Originally Posted by Wobblebonk View Post
OSX IS THE DEVIL.
Good thing this builds straight on the Pi without OSX, eh?

I could have done straight-up C/C++, but boost isn't something I'm personally familiar with (I work on too much legacy code to get exposed to boost). While the Foundation and Dispatch libraries in Swift are enough for this project, and cut the CPU use massively compared to the Python implementation, while still providing a good framework to start from. libDispatch is practically tailored for this sort of work.

But as long as the goal was to fit the performance available on the Zero, it would have been rough to stick with Python, as much as I would have preferred it (more popular as a language). C# with Mono is another option, but performance is generally a bit slower all things being equal (i.e. ignoring library performance, which can favor .NET in certain cases or with certain 3rd party libraries). It was worth trying, anyways.

That said, Swift still has some absurdly good type-safe behavior that I like. It's one of the reasons I was able to rewrite it this quickly, despite having to debug/fix 2 existing 3rd party libraries, and write a module to talk to the PCA9685.

Quote:
Originally Posted by Wobblebonk View Post
but uh, I actually took out the cie1931 thing for the hurricanex because the lut took up too much memory (there's 2kb ram... hah) and I could have moved it to program space but they requested to show %s and it's a neat feature for manual modes and such when you're playing around but when setting it up I think actual intensity makes more sense.

When there is more memory available I may make it like a user option in the control gui (iphone / android app?) but it's like a neat feature that is less practical most of the time.
Yeah, this is another reason I went for the Pi I already had. Despite having to statically link the Swift runtime, and the general bloat from working with a higher level language, I'm using <5% RAM at the moment, and I'd be surprised if it doubled by the time I'm done.

The cost of the headroom is the extra power consumption. But I should be able to keep it under a watt or so, which is fine.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Kaiede is offline  
post #33 of 103 (permalink) Old 08-06-2018, 08:46 PM
Planted Tank Guru
 
PTrader: (0/0%)
Join Date: Jun 2013
Location: WI
Posts: 10,747
Yea good point.. brightness of a green LED could equal the brightness of a blue LED but at 2x the "intensity" on the blue driver..
So lets go w/ the linear is a PAR dimming curve and gamma corrected dimming is a "natural" curve..
With the 2 choices there is no need for most to "worry" about err 'irregular" PAR changes in the dim cycle.

Biggest problem is not the ramp up because many do do that rather quickly in the overall scheme of things.

Few, though some, wouldn't go from say 100% to 95% dim as a PAR adjustment..I don't believe.
For those that critical.. a $200 Seneye will help..

YEA.. goofy language..
e.g
Quote:
This table remaps linear input values (the numbers we’d like to use; e.g. 127 = half brightness) to nonlinear gamma-corrected output values (numbers producing the desired effect on the LED; e.g. 36 = half brightness).
https://learn.adafruit.com/led-trick.../the-quick-fix

127= half intensity.. Brightness is relative to the human eye response, if I got all this right.

OK for my pet peeve.. We don't measure "PAR" but "PPFD"..
If I have to live w/ PAR you need to live w/ "brightness"...
like 18% grey................
Quote:
Your eyes are logarithmic detectors. That is, if a source gets brighter by a factor of 4, it will only seem brighter by a factor of 2 to you. If it increases by a factor of 32, it will only seem brighter by a factor of 5. If it increases in brightness by a factor of 128, it will only seem 7 times brighter to you.

The above are not the actual numbers. As you can imagine, measuring how bright things seem to people is very tricky, and varies from person to person. The important thing is that it is this weird logarithmic nature of your eyes that keeps middle gray from being 50%.
https://photo.stackexchange.com/ques...or-photography
Industry is no help either..
Quote:
The LI-190R measures Photosynthetically Active Radiation (PAR, in Ķmol of photons m-2 s-1).
https://www.licor.com/env/products/light/quantum.html

It's not "just PAR".. Par over time and distance is PPFD..
Quote:
Most light meters measure the instantaneous photosynthetic photon flux density in Ķmol m-2 s-1 and yet plant growth is determined by the integrated daily photosynthetic photon flux density in mol m-2 d-1.
https://www.apogeeinstruments.com/co...tegrated-ppfd/

won't even get into Genus and "species" thing..
Sorry Monday, and ranting..

Hmm back to the orig "issue"
OK to do linear readouts at the "PAR" scale in %'s
Now what about the "natural" scale..
If you want to keep the scale it needs to be dependent on the calc. value..
https://learn.adafruit.com/led-trick.../the-quick-fix

Using this table say at 8/14 (step 216)...is "50%"
both would be intensity.. nobody will care if we call it brightness.

ADDENDUM:
Want to get real fancy add a DLI caculation:
https://www.apogeeinstruments.com/co...tegrated-ppfd/
Cumulative "PAR" based on scale over time..
Need to input "starting" PAR.
Nobody really uses it ..yet..except indirectly like "decrease your hours on".

On second thought.. too much work since youd need to integrate every channel ect.but food for another day and when built in PAR sensors are on lights..

"A man with a watch knows what time it is. A man with two watches is never sure."

Last edited by jeffkrol; 08-06-2018 at 09:30 PM. Reason: edit
jeffkrol is offline  
 
post #34 of 103 (permalink) Old 08-06-2018, 08:56 PM
Planted Tank Enthusiast
 
PTrader: (0/0%)
Join Date: Feb 2018
Location: Maryland
Posts: 569
The osx is the devil thing was something I typed a ways back when people were still suggesting you use wine etc and it amused me so I just left it when I came back to make a reply.

I mean on my current project boost would be so unworkable... but I'm battling memory space more than anything. I was just trying to fix it for myself originally... because it was what I had on hand. I certainly wouldn't choose to have 2kb ram if I was designing it... but I didn't think it was worth it for them to redesign it if they're coming out with a new model anyhow (they actually offered to up the ram etc)

The vast majority of what I do for work is c++ or python, so I'm pretty happy to use those. I'm actually fine with using most programming languages I just dislike using xcode specifically.
Wobblebonk is offline  
post #35 of 103 (permalink) Old 08-06-2018, 09:45 PM Thread Starter
Planted Member
 
Kaiede's Avatar
 
PTrader: (0/0%)
Join Date: Sep 2017
Location: Seattle, WA
Posts: 246
Quote:
Originally Posted by jeffkrol View Post
Few, though some, wouldn't go from say 100% to 95% dim as a PAR adjustment..I don't believe.
For those that critical.. a $200 Seneye will help..

YEA.. goofy language..
e.g


https://learn.adafruit.com/led-trick.../the-quick-fix

127= half intensity.. Brightness is relative to the human eye response, if I got all this right.
What I hit was the issue that I wanted to get half intensity to hit a certain target for light level at the substrate, and immediately put in 50% brightness not realizing it was really more like 68% brightness that I needed to set. So operating in terms of brightness isn't terribly intuitive or accurate. If you are just trying to wing it and tweak, it is probably okay.

Yeah, that's about right in the context of that example.

Quote:
Originally Posted by jeffkrol View Post
OK for my pet peeve.. We don't measure "PAR" but "PPFD"..
If I have to live w/ PAR you need to live w/ "brightness"...
That's fine, except when you start needing to talk about the relationship between brightness and intensity, it gets messy because the relationship is non-linear and so using one as short-hand for the other complicates things. Harder to reason about. I wonder how linear the relationship between PAR and PPFD is.

Quote:
Originally Posted by Wobblebonk View Post
The osx is the devil thing was something I typed a ways back when people were still suggesting you use wine etc and it amused me so I just left it when I came back to make a reply.

<snip>

The vast majority of what I do for work is c++ or python, so I'm pretty happy to use those. I'm actually fine with using most programming languages I just dislike using xcode specifically.
Eh, no worries, I figured it was a friendly jab.

Xcode is certainly... a thing. It's fine for projects like this, but the bugs get both hilarious and depressing on larger projects. I picked Swift more because I could easily compile/test/run on Linux/Mac desktop as well as the Pi without doing too much #ifdef-esque nonsense. Xcode integration just makes the debug loop a little easier since I'm not a huge CLI jockey. I didn't even know it was possible until after I finished the early prototype.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Kaiede is offline  
post #36 of 103 (permalink) Old 08-06-2018, 10:12 PM
Planted Tank Guru
 
PTrader: (0/0%)
Join Date: Jun 2013
Location: WI
Posts: 10,747
PAR and PPFD are photon counts, there is no difference in linearity..

PAR per m2 per sec is PPFD.
Unfortunately photon detectors have varying sensitivity to wavelengths and so not really perfect recorders..
They get close w/ a lot of massaging of the input..
see the Li-Cor design..

https://www.advancedaquarist.com/2013/2/equipment
Field scout looks pretty much like a bare photodiode..



Problem is 100PAR of red light is not as "bright" as 100PAR of blue-green Light, yet will contain the same number of photons..

Theoretically PAR and PPFD is a completely linear measurement across the visible spectrum, yet perceived brightness certainly changes w/ "color".

W/ plants all PAR isn't exactly equal either so they "use" PUR which accounts for some differences in quantum capture..
Minor point is there are already a whole bunch of systemic errors anyways..

Regardless of curves sticking w/ a "power scale"

to be honest, brightness really is unimportant as a plant metric. Only intensity and to a lesser extent bandwidth count.
For you and me of course a different story..

not planning any 100PAR deep red tanks 100% of the day..

If one uses power as the scale (integer pairing) then the apparent brightness will be egual for any scale.. Only the number of points getting there will be different..

"A man with a watch knows what time it is. A man with two watches is never sure."
jeffkrol is offline  
post #37 of 103 (permalink) Old 08-07-2018, 03:37 AM
Planted Tank Enthusiast
 
PTrader: (0/0%)
Join Date: Feb 2018
Location: Maryland
Posts: 569
Heh I've spent days (well not really but I couldn't figure it out in the time I spent) trying to figure out how the F I had introduced a bug that messed with my stored intensity values/lookup... but apparently I commented out where it sets the cloud mode to off on initialization so it was just a random # that wasn't 1 or 0. They declared it as a byte instead of boolean, anyhow my day period would be randomly dark(er) and I was all WTF. but sigh so dumb... oops. So I guess I've been running with cloud mode all along (well for a while after loading custom firmwares anyhow) wondering to myself who actually uses this stuff heh.

The if statements were such that it had to appear as 1 to show that it was enabled but as long as it was != 0 it would be in effect heh. I thought I must have introduced a memory leak somewhere or something...

Now is when I discover cloud mode has been saving me from algae all along :/
Wobblebonk is offline  
post #38 of 103 (permalink) Old 08-07-2018, 04:31 AM Thread Starter
Planted Member
 
Kaiede's Avatar
 
PTrader: (0/0%)
Join Date: Sep 2017
Location: Seattle, WA
Posts: 246
Anyhow, got most of the work around 0.2 done today since Iím taking a couple days off this month. The errors when there are problems with the configuration file are better, it supports brightness and/or intensity in the schedule, you can tweak the gamma used to convert between the two, and it supports a form of minimum intensity per channel.

The last one needs tweaks later this week, but Iíll probably start looking at what it would take to do moon phases at the same time.

Because I can set the light levels very low, it could be interesting to play with moon phases where full moon is something like 0.5% intensity.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Kaiede is offline  
post #39 of 103 (permalink) Old 08-07-2018, 04:33 AM Thread Starter
Planted Member
 
Kaiede's Avatar
 
PTrader: (0/0%)
Join Date: Sep 2017
Location: Seattle, WA
Posts: 246
Quote:
Originally Posted by Wobblebonk View Post

The if statements were such that it had to appear as 1 to show that it was enabled but as long as it was != 0 it would be in effect heh. I thought I must have introduced a memory leak somewhere or something...



Now is when I discover cloud mode has been saving me from algae all along :/

That sort of stuff is fun. Iíve worked in codebases where Ďintí was used for true/false. All sorts of goofy stuff there to try to avoid problems with that. Also a very old codebase.

I need to start adding time/intensity back into my tank myself. I finally kicked my algae to the curb by finding out which nutrient was deficient, and I can start seeing how much I can kick it up before it starts to appear again.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Kaiede is offline  
post #40 of 103 (permalink) Old 08-07-2018, 04:41 AM
Planted Tank Enthusiast
 
PTrader: (0/0%)
Join Date: Feb 2018
Location: Maryland
Posts: 569
Well, I can tell you that they were just calculating moonphase from a library that they would put the date/lat/long into and just multiplied the value by the night pwm settings, the value was 0 for a new moon ->1(00%) for a full moon
Wobblebonk is offline  
post #41 of 103 (permalink) Old 08-07-2018, 05:08 AM Thread Starter
Planted Member
 
Kaiede's Avatar
 
PTrader: (0/0%)
Join Date: Sep 2017
Location: Seattle, WA
Posts: 246
Quote:
Originally Posted by Wobblebonk View Post
Well, I can tell you that they were just calculating moonphase from a library that they would put the date/lat/long into and just multiplied the value by the night pwm settings, the value was 0 for a new moon ->1(00%) for a full moon


Thatís my intent, as well. Just a bit more generic and simplistic perhaps.

The code to figure out the moon phase itself isnít too difficult, and I was planning on keeping it simple at first by not having to think about timing of when the moon rises and sets.

But I see a JS (and Python) library that does most of this under the MIT License that would be simple to port to Swift. May just start by porting that as an exercise in understanding the math.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Kaiede is offline  
post #42 of 103 (permalink) Old 08-10-2018, 01:40 AM Thread Starter
Planted Member
 
Kaiede's Avatar
 
PTrader: (0/0%)
Join Date: Sep 2017
Location: Seattle, WA
Posts: 246
I finished up the last issues that were preventing 0.2 from going out the door. So that's now available.

Improvements:
  • Prints details of hardware configuration on start
  • Somewhat improved error reporting when loading the configuration
  • Supports more than the Pi Zero / 1 GPIO, using a new configuration option
  • Can configure the gamma used for calculating brightness
  • Can set a channel's brightness (uses gamma) or intensity (raw light percentage) for any event in the schedule
  • Ability to set a minimum intensity for a channel


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Kaiede is offline  
post #43 of 103 (permalink) Old 08-11-2018, 01:16 AM Thread Starter
Planted Member
 
Kaiede's Avatar
 
PTrader: (0/0%)
Join Date: Sep 2017
Location: Seattle, WA
Posts: 246
0.2.1 now detects which Raspberry Pi board is being used, so most folks won't need to set the hardware configuration option. It's still there in case something does come out that breaks the detection as a workaround.

I also turned on automated builds because I could. Also did some other small cleanup/hygiene. This is mostly to make it easier to catch problems in the future, and test the waters on newer versions of Swift.

I've been poking around at libraries to calculate moon/sun position. Not a whole lot of luck. Many simpler libraries are not documented enough to fix issues that show up when porting their code. I could wrap a library like libastro, or drag out my old book on the subject and do it myself, since I only need a small subset of libastro and wrapping C libraries is hit or miss with Swift. It could be easy, or it could be hard. Not entirely sure which direction I'll go.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Kaiede is offline  
post #44 of 103 (permalink) Old 08-13-2018, 02:03 PM
Planted Tank Guru
 
PTrader: (0/0%)
Join Date: Jun 2013
Location: WI
Posts: 10,747
Still dangling my toes in Pi water...
Along w/ 3 other tanks and various COB's..

Too many choices, too many toys..

"A man with a watch knows what time it is. A man with two watches is never sure."
jeffkrol is offline  
post #45 of 103 (permalink) Old 08-14-2018, 07:23 AM Thread Starter
Planted Member
 
Kaiede's Avatar
 
PTrader: (0/0%)
Join Date: Sep 2017
Location: Seattle, WA
Posts: 246
I did some playing around with cleaning up the install a bit. Instead of unpacking the Swift compiler into /usr, it does it in /opt/swift now, behaving like a better Linux citizen. I also fixed a missing dependency needed to build/install. Right now, the install process is about as simple as it will get without starting down the route of custom SD card images.

I also put together the core of a library that will back the Lunar Cycle feature. Enough that I can start writing the feature. But I'll probably not get back to it until this next weekend. Need to be able to attack some other projects this week.

At some point I also need to split out the PCA9685 PWM interface into its own project. It should be a library that anyone can use.

Quote:
Originally Posted by jeffkrol View Post
Still dangling my toes in Pi water...
Along w/ 3 other tanks and various COB's..

Too many choices, too many toys..
Of course.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Kaiede is offline  
Reply

Tags
None

Quick Reply
Message:
Options

Register Now



In order to be able to post messages on the The Planted Tank Forum forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.

User Name:
Password
Please enter a password for your user account. Note that passwords are case-sensitive.

Password:


Confirm Password:
Email Address
Please enter a valid email address for yourself.

Email Address:
OR

Log-in










Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page
Display Modes
Linear Mode Linear Mode



Posting Rules  
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

 
For the best viewing experience please update your browser to Google Chrome