Shop OBEX P1 Docs P2 Docs Learn Events
Real time clock correction with Propeller. — Parallax Forums

Real time clock correction with Propeller.

garyggaryg Posts: 420
edited 2013-10-03 15:50 in Propeller 1
Hi
I'm starting to shut down my hydroponic garden for the year.
Before the next season, I'll be needing to set up a new timer system.
I'm planning to use a real time clock program from OBEX, but am concerned about
a system reset upon power failure.
I'm looking at the real time clock from Sparkfun, but don't know how I can integrate this into my system.
My thought is this:

Use one of the real time clock programs from OBEX.
Use Sparkfun real time clock to initialize the Propeller OBEX real time clock program.
On startup, the Propeller will get an accurate time, to approx. 1 minute from the true real time clock.
The system floods aprox 16 times per day.
I think I should be able to use the Prop to do this, but am concerned that if a power outage happens, that
I will lose my timing and thus my hydroponic plants.
The hydroponic plants need to be water cycled every hour or so no matter what, during the time of day when the
sun is in the sky.

I already have a redundant pumping system that uses even/odd hours to cycle in case of failure.
I'm currently using programmable timers available at home depot, but would like to up my game.


Any suggestions on how to set up a real time clock system that does not fail would be appreciated.

Thanks
Garyg

Comments

  • jmgjmg Posts: 15,173
    edited 2013-09-26 17:07
    garyg wrote: »
    ... a real time clock system that does not fail ...

    That's a big ask. Generally, if you want more reliability, remove complexity.

    A HEF4541 or HEF4521 + Photocell would do most of what you need, and could even include 'Sun Strength' compensation of the repeat times. Saves water on cooler or cloudy days.
  • kwinnkwinn Posts: 8,697
    edited 2013-09-26 17:44
    The Propeller does a good job of keeping time when clocked with a crystal so if it has a battery backup it should be fine. If you want a timekeeping backup you could use a separate clock/calendar chip with it's own battery, or a GPS receiver. The prop could check the backup time whenever it reboots and at regular intervals.

    If the water cycling is that critical shouldn't the whole system have battery backup?
  • JonnyMacJonnyMac Posts: 9,107
    edited 2013-09-26 19:57
    Adding a real-time clock with battery back-up is very easy. I use the DS1337 with a 3v coin cell. It's I2C so you can share the pins used by the Propeller's EEPROM.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-09-27 07:32
    Jonny Mac has provided the code. The only real redundancy you need is the 3V coin cell power source that keeps the RTC running if there is a power outage. You don't need to have the software duplicate the RTC functions that are provided in silicon unless the software code is just easier to do.

    If that is not good enough for you, you might consider a connection to the internet that updates the RTC from the internet.

    On the other hand, if the Propeller has a battery powered backup, you can have the RTC in software.... as long as the Propeller doesn't reset for some reason. If it resets, it needs some reference to get the correct time.
  • LawsonLawson Posts: 870
    edited 2013-09-27 09:11
    garyg wrote: »
    Hi
    I'm starting to shut down my hydroponic garden for the year.
    Before the next season, I'll be needing to set up a new timer system.
    I'm planning to use a real time clock program from OBEX, but am concerned about
    a system reset upon power failure.
    I'm looking at the real time clock from Sparkfun, but don't know how I can integrate this into my system.
    My thought is this:

    Use one of the real time clock programs from OBEX.
    Use Sparkfun real time clock to initialize the Propeller OBEX real time clock program.
    On startup, the Propeller will get an accurate time, to approx. 1 minute from the true real time clock.
    The system floods aprox 16 times per day.
    I think I should be able to use the Prop to do this, but am concerned that if a power outage happens, that
    I will lose my timing and thus my hydroponic plants.
    The hydroponic plants need to be water cycled every hour or so no matter what, during the time of day when the
    sun is in the sky.

    I already have a redundant pumping system that uses even/odd hours to cycle in case of failure.
    I'm currently using programmable timers available at home depot, but would like to up my game.


    Any suggestions on how to set up a real time clock system that does not fail would be appreciated.

    Thanks
    Garyg

    Does anything bad happen if you water the plants too often? I.e. just initiate a watering cycle after power comes back up and shift the whole, once per hour, schedule. This doesn't help with power outages longer than an hour though, you'd need battery backup for those.

    Marty
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-09-27 09:57
    Hmmm.
    If the Propeller itself has a backup power supply, it could sense a mains failure and actually keep track of when power was down, for how long, and when power was restored.

    If the water pumping is mains dependent, the software could compensate with this data.

    +++++
    I have a Propeller here running on a very simple power backup setup.

    If you take a 12 volt gel cell as your backup battery, a 13.5Volt, 1 amp wall wart is adequate to trickle charge the gel cell. You just have to include a 1 amp or higher diode as a block diode so that a Mains power failure does have the wall wart discharge the battery.

    Then just connect the + and - of the gel cell to the Propeller or if you want the Propeller to run cooler, insert a 9 volt linear regulator between the Propeller and the 12 volt battery.

    The gel cell will at first be topped off, and after that it will trickle charge from the Mains indefinitely. If Mains power goes off, the Propeller will not notice.

    If you want the Propeller to be aware that power is down, you have to set up an I/O pin to monitor the Mains power. That can be done with an opto-isolator which has the LED side driven by the Mains (through a current limiting resistor).

    I suppose this would also offer some transient protection from lightning strikes as well. But I suspect that lightning might just blow out the wallwart and not affect anything wired past that.
  • garyggaryg Posts: 420
    edited 2013-09-27 11:54
    Thanks for all your suggestions and comments.
    I think that for starters, I'll be attempting to set up JonnyMac's suggestions.
    While I've never used a DS1337, It looks like a pretty straight forward solution to
    what i need to do.

    I also think that I'll be attempting Loopy's battery backup strategy.

    I'll keep you all informed of my progress.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-09-27 12:11
    Since you are using your own alarms, you might end up just using the DS1337 for setting the clock.

    Alarms can be handled cleaner and faster by eliminating all the synchonous serial exchanges.

    I have the gel cell and the Propeller board in a 4 quart refrigerator food storage box with that has a good sealed lid. This was intended to be used outdoors and remotely. So far, I have had it running for a month or so by my bed to make sure it runs cool and the interfaces work.

    Maybe soon, it will morph into a weather station on my roof with RS422 serial to my room. The battery is running cool and the unit has stayed in operation 24/7.

    For my own personal RTC, I am working with Forth and Unix Epoch Time. Unix Epoch Time runs on a one second tick and is very easy to set up and to manage multiple alarms. I am not finished with my Forth code for it, but have been considering an Application Note when it is working.

    It is really a great mix. The Forth allows an intereactive monitoring and over-ride, and a RTC with multiple alarms has all sorts of interesting possiblities. Add in the RS-422 and you have it all being handled from a remote terminal.
  • kwinnkwinn Posts: 8,697
    edited 2013-09-28 12:32
    garyg wrote: »
    Thanks for all your suggestions and comments.
    I think that for starters, I'll be attempting to set up JonnyMac's suggestions.
    While I've never used a DS1337, It looks like a pretty straight forward solution to
    what i need to do.

    I also think that I'll be attempting Loopy's battery backup strategy.

    I'll keep you all informed of my progress.

    The route JonnyMac suggested is a good way to go for this, and using a Propeller gives you a lot of flexibility to add to or modify the control system.

    You may want to take a look at latching solenoids for controlling water flow to the hydroponics. They draw no power in the on or off state, only to switch between the two states. A pair of “C cell” sized lithium batteries can switch a sink faucet on/off for several months in a public washroom, so a 6V 7AH battery should be able to power the propeller board and several solenoids for weeks or possibly months.

    If the water is supplied from a water main the solenoids can be connected between the main and the hydroponics. If the water is pumped from a reservoir you could place a storage tank high enough to provide a gravity feed to the hydroponics and fill the storage tank when AC power is available.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-09-30 12:57
    There are two kinds of latching solenoids.... one input wire and two input wire. Generally the ones with two input wires are constructed to switch more power.

    At first I thought the one input wire units were best suited for the Propeller as you use less pins. But the simple truth is that you don't know which state you are driving the relay to unless you construct a feedback setup that requires a second pin.

    So the two pin relays may be the simplest. You always know which state your are driving the coil to by your choice of pin.

    If one pin units are all you have, opto-isolators can confirm on and off conditions for you.
    If you are worried that all these i/o pins are going to be more than what the Propeller provides, you can use a latched shift register to create more. After all, the timing for this is not down to micro-seconds.

    Latching relays are a bit more expensive, but they conserve power and have several other handy features (they stay on even when there is a power failure, so there state doesn't have to be reintialized). Of course, you might want a few conventional relays in key positions as they do shut down in a power outage. You wouldn't likly want a water valve to remain open in a power outage of unknown duration, would you.

    Lots of pros and cons.
  • garyggaryg Posts: 420
    edited 2013-10-02 20:36
    Loopy
    Thanks for your comments, suggestions concerning latching relays.
    I will be looking at both the One pin types and the Two pin types.
    Years ago, I had experience with the Two Pin types.
    They seem simpler to use even if they take and extra pin to control them.

    With this project, my current thought is that in addition to the real time clock, I may want to use a backup
    system of some type of photo cell to detect when it's getting light outside in the morning.

    A day/night detector would maybe be useful if I can figure out how to implement it.
  • kwinnkwinn Posts: 8,697
    edited 2013-10-03 15:50
    garyg wrote: »
    Loopy
    Thanks for your comments, suggestions concerning latching relays.
    I will be looking at both the One pin types and the Two pin types.
    Years ago, I had experience with the Two Pin types.
    They seem simpler to use even if they take and extra pin to control them.

    With this project, my current thought is that in addition to the real time clock, I may want to use a backup
    system of some type of photo cell to detect when it's getting light outside in the morning.

    A day/night detector would maybe be useful if I can figure out how to implement it.

    The two input pin solenoids are simpler to use. With the common connected to V+ one input turns it on and the other one turns it off. A serial to parallel driver chip like the TPIC6595 could be used to control 4 solenoids.

    A day/night detector could be as simple as a phototransistor and resistor connected to a propeller pin.
Sign In or Register to comment.