Go Down

Topic: // reeftank controller guidance plz (Read 1 time) previous topic - next topic


I didn't quite follow that circuit using a SPDT relay to drive the blue/white LEDs. Firstly because the diagram shows the relay in a mid position, but a conventional SPDT relay has a common contact, a normally open contact and a normally closed contact; except when the relay is in the process of switching, the common terminal is connected to either the NO or NC terminal. Secondly, I don't understand why one LED is backwards and there is another diode between them. Is there something clever going on here - if so, what?

As far as sketch design goes, I suggest that you design the sketch to be non-blocking and modular. Implement each major functional area with whatever global data it requires, and functions to be called from setup() and loop() to carry out the corresponding behaviour. These functions should be non-blocking (should not stop and wait for some external event to occur). The preferred approach to implement this is to design your code to check for events that might need to be handled, such as input arriving on a serial port, or some scheduled action being due. The 'blink without delay' example sketch demonstrates how to use this approach for simple timed activity (blinking an LED on and off at regular intervals) and I recommend that you follow a similar approach for the other things your code needs to do. In this way your code can check for and handle all the tasks that need to be performed, without any piece of the code needing to cooperate with or be aware of what any other parts are doing. The only overriding requirement is that you stay within the total available memory, and that all of your code completes quickly enough that you can complete the loop fast enough to meet your latency requirements.
I only provide help via the forum - please do not contact me for private consultancy.


you're right, i drew the led backwards...oops.. good catch.  it was late and nyquil was catching up...
and i might be wrong but the SPDT here has three conditions, blue/off/white and blue
the SPDT is the current setup on the lighting fixture.  i am going to remove that switch and put a new jack in its place to run the wires to the relay board for switching.
that way i can switch between white and blue on both runs of lights at their respective times.
i could have the fans come on when the first set of whites come on and go off when the second whites go off.
that would eliminate the need for the temp sensor.  but it would be way more efficient with it.

and i have minimal to no idea about the sketching parts you mentioned, sorry i'm just new to C++ and arduino IDE


after studying your reply, i believe i know what you are talking about as far as trying to keep it simple(KISS).
but as far as all the code language and the usage of each command and function lingo, i am lost.
i know i need an "int, include lib, or h., setup, loop the brackets and { }, and all the ;'s ()
but i don't know how when or why to use them, that is where i need the assistance i guess.
if no one here helps me, maybe this CookBook that comes in monday will. it'll just take alot longer..


Lots of good advice here.  A traditional approach for complex system development is "Stepwise Refinement".. championed by Nicholas Wirth, who created the PASCAL language.

You could write the outline of your system with Procedures for each major function like ControlPump or ReadLightSensor or ReadClock or ReadUserInput, but have those procedures at first do nothing at all.  You could define your State Machine and debug the logic it implements with long delays and outputting the State Variable to the serial monitor to see where you are.  Make your procedures put out phoney expected data to see that it is handled correctly. Leave the real-time type things until last.

See: http://playground.arduino.cc/code/FiniteStateMachine  (Thanks Alexander Brevig) and maybe the example at: http://arduino.cc/forum/index.php/topic,37153.0.html

You'll be glad you implemented a State Machine when you can find out where you are every time and Why..   

If you get your skeleton constructed properly and well controlled, you can start adding flesh.  Flesh is weak and will break, but you can handle one thing at a time.

If you can relax and get into the "Oh, that's an interesting Problem!" mode and avoid getting bent out of shape and thrashing, you may find you LIKE this stuff!

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info


I was in your position around 2 years ago when I considered making my own led controller, which over the following 12 months turned into a fully blown controller for all of my equipment i.e. return pumps, skimmer pump etc. This was initially based on a 20x4 LCD display and keypad but I am currently working on a TFT LCD with Touch screen controller.

You may find that someone else has done exactly what you require using your hardware, but the chances are slim. So, if you are going to end up with what you want then you will need to learn the programming language. Take baby steps, add one thing at a time and get that working - start with blinking a led so that you understand what you are doing.

This forum is great for answering specific questions that you may have, but you can't expect someone to teach you the language - my estimate is that my first controller would have taken in excess of 200 hours to complete, spread over 12 months but lots of that was researching how to do things.

There are quite a few threads on Reefcentral which may help get you started.

Good luck.

Go Up