Simplest way to add real time clock events to prop?
T Chap
Posts: 4,223
I am trying to avoid working on a custom software update to include a real time clock on a prop that would require an interface for clients to update the clock for years to come. The need is to set a timer to turn on a 8pm, off at 8am. A single contact closure would suffice or a 3v3 - 5V input to the prop to monitor. I was hoping for an off the shelf timer with built in contact closure to hand this, so the clients can easily update the clock or change for daylights savings etc. Any suggestions?
Comments
The Prop is fully capable of keeping a real-time clock all by itself and can directly drive some reed relays (those with a 3V coil taking less than 40mA to drive). It can handle all sorts of displays and keypads or keyboards. It can also handle an external RTC
Homedepot Wall timer for easy mounting : $20. http://www.homedepot.com/p/Woods-Digital-7-Day-Programmable-Timer-White-59018/203638986
Another idea is a Sprinkler timer. It already has a relay that drops voltage down to switch 24v, however these devices are normally 24v AC.
Finally, A hack may be to take a hose based (single port) time and modify the 'valve' actualtor to provide the signal to the prop. Sounds easy, but would be 'hacking' and not so much off-the-shelf. http://www.homedepot.com/p/Orbit-1-Port-Single-Dial-Timer-62056/100126132
I am interested in hearing what you end up using...
You should also share ground with watch.
Something a little bigger would probably be better:
http://www.amazon.com/Elgin-2-Inch-Multifunction-Alarm-Smartlite/dp/B0052EKXB0/ref=sr_1_28?ie=UTF8&qid=1375292233&sr=8-28&keywords=LED+Light+Alarm+Clock
I just completed a 24/7 Propeller set up with lead acid gel cell for back up that is trickle charge from a wall wart. For a 12 volt gel cell, you can just use a 13.5 volt wall wart, but a blocking diode should be considered.
So having that in place. I am using pfth Forth to create a cog that is a RTC that is base on Unix Epoch Time.
There is no LCD display involved. Instead I am using the serial interface to communicate via RS422 to a small notebook computer that manages setting up timers and control of relays.
If this sounds like something that would work well with your plans, let me know. The gel cell is 8AH, so the backup is very ample for running the timing for several days without charging power. And there is extra power available to actually run 12VDC devices, such as solenoid driven valves for irrigation.
The whole setup is is a 3.3 quart plastic food container that has a tight moisture seal. For now it just sits in a corner of my room. But if it works well, it may become a weather station on the roof of my building.
With the RS422 interface, you can have 4000 feet of cable between your computer an the Propeller and still monitor or revise timing controller. Or you can just have it be a programing port inside the box that the Propeller and backup power are in. In that senario, you just bring your laptop to monitor and reset timing.
Soon I hope to have a timer that will take different timing for different days of the week as will as just a 24 hour cycle. Multiple and complex on/off scheme can be easily accomoate. And you can easily override at anytime in Forth.
If 110VAC is not easy to get, a solar charger scheme for the 12V gel cell is also a good alternative.
Daylight saving and regional times zones shouldn't be any problem. Plus you can monitor the system closely from afar in the first months of use. You can even have and SDcard take data logging that can be picked up at your convience for review.
Futurelec.com has RTC timer modules that could tie into the Propeller via SPI and may even run one or two event triggers independent of the Propeller. It looks like the RTC interupt could drive a small latching relay to toggle it on and off.
http://www.futurlec.com/Mini_DS3232.shtml
https://www.sparkfun.com/products/99
I've used this module piggybacked on the EEPROM boot pins so it requires no extra Prop pins. If your system has 5V being regulatd to 3V3 for the Prop, you can run the DS1307 from the 5V rail. This module also comes with a battery and the time pre-set.
Would it be possible to post a photo of your 3.3 quart system.
The simple timer thing is bigger than most people realize.
I spend most of my summer hours in my yard or bicycle riding, but am attempting to
in some manner build or purchase a simple real time clock.
So far, I started hacking an intermatic timer - in process
I've purchased a Woods battery operated timer that will turn on a light switch via servo mechanism internal to the timer.
The Woods timer could work, but takes a very large amount of real estate.
I found some Spin program logic concerning real time clocks in the OBEX that I still need to try out.
I'm looking into possibly using PropForth as a potential easier programming method than spin, but have not as yet
done any actual PropForth programming.
I've also looked at the SparkFun real time clock module. This seems to be a good approach if I need to get complicated and accurate
timing.
It appears that all of the 110 volt ac versions of Programmable timers switch 110 volts through relay.
The relays are not isolated contacts.
I'm rambling again. Sorry!
I'm not intending to divert the intent of this thread.
comments would be very welcome by myself and I'm hoping by the originator of this thread.
I wouild be delighted to take some photos and post them.
Photos in the next 24 hours...
I am NOT using OBEX Spin code... I am using Forth and this makes the whole care and feeding of timers and automated devices much saner. It is an ideal project for Forth.
PropForth might work as well, but I am using pfth. Pfth 1.0 with SDcard is a good choice for programing and development from afar.
In pfth, you just deploy one Cog that provides a 1 sec tick and use Signed 32 bit to base your time on Unix Epoch Time of a 86400 ( 24 x 60 x 60) second day and a 365.25 year.
Then your timer routines are set up to moniter the value of the Unix Epoch time and to trigger appropriate action. This should work well untul the roll-over of Unix Epoch time in 2038.
I've also looked at the SparkFun real time clock module. This seems to be a good approach if I need to get complicated and accurate timing and want the Propeller to be off at times.
There has always been an awkward problem of reseting RTC clocks. With Unix Epoch Time, you can get a website to provide you with one 32 bit value for 'right now' and load that in as the correct time... so you avoid having to write a lot of code to load time, year, and date. You can include a Time zone adjustment and load GMT or not. You can add an hour on a certain date and subtract it on another to adust for daylight savings. You can have timer calls that are dfferent for each day of the week, or each day of the month.
While I realize this may seem larger and that Forth is an odd choice... it really is a complete system solution for automated timing and control of devises that will have to be situated far enough away to make walking back and forth really inconvenient. If I do the weather station, I can avoid climbing 5 flights of stairs to reload programs.
The only real trouble I have had so far is that my CAT5 to RS422 dongles had some bad crimping of the DIY connectors and I had to run down which were bad and replace them. I also build an RS232 to RS422 Propeller programing interface to sit by my computer. ... but with Forth properly set up, you don't need to actually reload .spin binaries.
I have used an 8VDC 9AH gell cell that I've had for a long time with a 9VDC LM7809 to trickle charge. It has already been on the charger for over 24 hours without issue.
I suspect that the 8VDC battery is hard to get, so a 12VDC gel cell might be a similar physical size and can be trickle charged directly from a 13.5VDC wall wart. One should have a blocking diode to prevent the wall wart from running down the battery if power is off, but having only 12.8 VDC for charge may do fine. Inserting voltage regulators in the box may create a heat problem that might melt the box.
At the box, I am using a home built RS422 to the Propeller Proto Board device that Peter J. provided a schematic for. And here I am just using a store bought RS232 to RS422 adapter in series with a USB to RS232 cable for the PC end.
I can confidently leave the Propeller board running and disconnect the CAT5 interface for long periods, then return and the board is still stable and running the interface. I have left the Propeller Proto Board running a prime number generator to show it is not rebooting or freezing.
PropForth does have some advantages with switching cogs via serial port, but I got started with the Unix Epoch Time project with Dave Hein and pfth, so I think I will develop the application first in that. IT WOULDN'T BE DIFFICULT TO PORT TO ANY FORTH on the Propeller.
The box is reasonably weather-tight. Cables are going through a notch cut the rim to allow the lid to close. Distance has been tested successfully with a 50 meter CAT5 cable for loading spin binaries as well as just full-duplex serial. The programer box is not shown.
Personally, I find it easier to get good communications by having the store-bought RS232/RS422 in use. I have had a bit of trouble with cross-talk or connections in my own RS422 converters.
I'm always interested in packaging of a project used outdoors in the weather.
I tend to drill holes and use grommets and silicone sealer.
The question originally asked by T Chap still remains.
It would appear that there is not a ready made consumer Programmable timer that will operate on
120Vac but have isolated relay contacts.
I've been looking for the answer to T Chap's original question for a few months.
I'm starting to believe that there is no consumer product that fits the bill of an inexpensive easily pushbutton programmed timer
that has isolated relay contacts.
The Sparkful RTC is a nice little product, but that too has issues as you have to learn to do it all in SPI and initially setting the clock is a bit tedious. If you need to suddenly reschedule events these RTC require a recompile and reload. That seems unappealing as well.
SO I opted for using Forth and having the Propeller use a cog rather than an add-on device.
The hardware is built and I am working on the software in pfth at this point.
I have a 4 x 12 amp 240VAC relay board that can be housed in a separate weather proof box, has DNS rail sockets for the relays and fuses or circuit breakers. If something needs services or replacement, the two sides are easy to separate. 120Vc/240VAC should be housed in a metal weather proof box and surplus military ammo boxes are a good choice, You could use ammo boxes for both sides... they are just impossible to get in Taiwan as even one round of ammo in your possesion is a felony.
http://www.ebay.com/itm/30-Cal-200-Cartridge-Ammo-Box-Military-Ammunition-Can-M19A1-30-Cal-/380664106076
Relays that are solid-state or mechanical can be added. I prefer mechanical as they fail to an off state. And I really like latching relays for low power use as you don't have to hold the coils on. There a two control wire latching relays that have separate pulse wires for the two different positions. That may be an advantage over ones that toggle on and off as you know exactly which state you are driving from any i/o pin of the Propeller.
Time can be a daunting topic, but I am working with Unix Epoch Time that is more than adequate for most situations. This is not about tracking stars and solar events in UTC with its leap seconds. It is a 24 hour day and a 365.25 year that is tracked with signed 32 bit from Jan 1, 1970.
My first version is an EZ_RTC that is just a 24 hour clock, not the annual calender. It does have Day of Year counted so you can go to and from Daylight savings time. After that, I will get a full RTC with complete calendar display, day of week, day of month (date), month, quarter, and leap year.
The best part is you just load a 32 bit integer to set everything. And that can be gotten from your PC or the internet.
This may not seem the simplest way to get RTC events working with a Prop, but I don't have to attach an LCD and keyboard, I don't have to program in C or Spin, and I can reach the active system at anytime to override control or to revise. So it seems the simplest way to me. But it certainly isn't the smallest. The gel cell takes up a bit of space.
http://www.epochconverter.com/
Using Unix Epoch Time does make this fairly simple. The project is to simply provide a register that is updated with a one second tick to be read whenever required.
Hours, minutes, and seconds are easy to sort out.
The harder part is to work out Date, Month, Year, and Day of week, but I've got preliminary code that seems very good for that as well. The reality is that you do have to be able to start with a value that is 'number of days since Jan 1, 1970' and extract all the other items from that. It does take having a filter to go from the 'day of the year' to an actual month and day with awareness that 2012 was the last leap year.
For years, I thought this would be hard to program, but it is rather fun. If you really dislike this kind of puzzle, C has a time library that will resolve all these details for you.
The origianl request was to have the timer set to anticipate daylight savings time in years to come. I don't see how your are going to avoid a calendar arrangement for that unless the enduser just toggles daylight saving and standard time on the day that it occurs. It that is acceptable and the timing cycle is the same for 7 days per week. The whole RTC is just a 24hour clock with spring forward an hour and fall back an hour feature.
For myself, I want the timer to be able to identify a different routine for each day of the week, and the calendar to be able to recognize holidays and other special event days.
IOW, if you really want to program a good RTC; you have deal with all of the aspects... shortcuts are limiting.
Good point, so the least-custom-effort using this, would be a Generic mains Timer + USB charger, which will give 5V 'contact' output.
User has full control, and no custom 'set time' work is needed.
Running a 24hr timer from a always-there mains signal, would need just a high-voltage 10M+ resistor (eg VR68 family) and a cap+Schmitt gate into any Prop Timer - but that has no user Set-time interface.
Depending on what is already there in user interface, assuming almost nothing, one simple fall-back could be to start the timer in fixed phase, at power-on.
If someone will always be there at 10am, (or lunchtime) for example, and you want 8am or 7am you have a fixed 2-3hour offset.
Users can daylight adjust it, or whatever, by a power cycle at that defined tine.
No, but you can use two standard consumer products to get close.
Just plus in a generic USB.Phone charger to the generic timer, and you have a usable signal.