Propeller and DS1302 question
RayNelson
Posts: 4
I'm trying to come up with some ways to incorporate a PropNIC into a Prop Pro dev board & to automatically set the DS1302 clock chip·from an internet source such as NIST.· The DS1302 object has a great way to set an initial time, but I'm working on another project (integrating Propeller with DS1302, Nixie tubes, and ethernet connection), but I'm not sure quite how to be able to do a couple things.· I do have a DS1302 wired to a board with a battery holder to provide backup power to keep the chip alive, but I'm not sure how to read the clock initially to see if it has valid data.· I'd also like to do the synchronization with the NIST source once a week, so I think I just need to keep track of a variable & reset it to 0 when the synch occurs.
I've also looked at the PropIRC code and seen where it queries NIST to set an initial 'local time' for timestamping the IRC communications, I'm just not sure how to re-write that data back to the DS1302.
This may be a wild idea, but I have the hardware already functional for the DS1302 to provide an initial time to the nixie clock but that's a fixed point when I download the program to the propeller board.
I'd post some pics & schematic of what I have done so far, but it's all still a little too rough around the edges for public consumption.
This Propeller project has been an interesting learning experience, I just would like to now draw on ideas from other folks.
Thanks,
Ray Nelson
I've also looked at the PropIRC code and seen where it queries NIST to set an initial 'local time' for timestamping the IRC communications, I'm just not sure how to re-write that data back to the DS1302.
This may be a wild idea, but I have the hardware already functional for the DS1302 to provide an initial time to the nixie clock but that's a fixed point when I download the program to the propeller board.
I'd post some pics & schematic of what I have done so far, but it's all still a little too rough around the edges for public consumption.
This Propeller project has been an interesting learning experience, I just would like to now draw on ideas from other folks.
Thanks,
Ray Nelson
Comments
1.) Which 1302 driver are you using? DS1302 or DS1302Full.
2.) Why worry what's in the clock now if you plan to sync to the NIST time anyway. You could just do that first thing whatever is in the chip.
3.) Looking at DS1302 full there is a SetDateTime function that should allow you to specify the entire date/time combo and write it to the chip. I'm not sure from what you wrote why you can set it initially but not later?
Looking at that code it should be easy to break out the setters so you can set each field individually. Once you do the initial set then most likely seconds and minutes is all you'd ever need to correct against NTP rather than always having to reset every field.
So far, I've only looked at the DS1302 object, haven't downloaded DS1302Full yet, but I'll take a look at that & maybe that'll shed some more light on my process.
Maybe having the NTP synchronize is too far fetched, this is, after all, just going to be a simple clock. I thought of adding the ethernet interface just for giggles. I haven't yet thought through what I would need to add buttons to increment the counters for minutes or hours for a manual setting.
Thanks for being patient with a "newbie" of sorts.
Ray Nelson
Post Edited (photomankc) : 10/27/2009 6:45:53 PM GMT
"I'm not sure how to read the clock initially to see if it has valid data..."
On power-up, the DS1302 time initializes to 00:00:00, 01 01 01 00 (h[noparse]:m:[/noparse]s, dow month day year). So if you read the DS1302 immediately upon prop power-up and it comes back with midnight, Jan 1st...its a good bet that the DS1302 needs to be initialized. Although per photomankc's point, if you have an internet connection, seems like it'd be easier/better to sync with NIST at every power-up of the prop regardless of whether the ds1302 time is valid or not. Maybe with a test to skip the download if no ethernet connection available...
"I'd also like to do the synchronization with the NIST source once a week..."
Maybe some kind of test that gets executed at least once per minute...if (day=Thursday) & (hr=03) & (min=00), then download update from NIST?
"I'm just not sure how to re-write that data back to the DS1302"
Writing the new time data to the ds1302 should be pretty straightforward once you've got h/m/s/dow/day/mo/yr into separate variables in hub RAM. Either of the ds1302 drivers on the obex should work fine, both have examples showing how to read and write time to the ds1302. The trickier part might be in parsing the string that comes back from the NIST server into numerical values in hub ram...but serendipity is on your side, as Kye has just uploaded a handy new string library that should fit the bill nicely: http://obex.parallax.com/objects/529/
I, too, have been thinking about exploring the wide, wide world of prop ethernet connectivity...the ybox2 kit on my desk has been patiently awaiting my attention for quite a while now. The NIST server update you mention would probably make for a good "entry-level" project in this area. So little time, so many bright, shiny objects.
photo, also thanks for the comments. Got the LAB PDFs and have been working through them as well. It's given me a lot of insight into how things work, but I guess I'm just being impatient & trying to rush things based on a few small successes I've had.
The NIST synchronization, I think, is out. Maybe just a pipe dream in the future. I've added the PropNIC to the propeller already like I stated when I was playing with PropIRC code. It was more of an afterthought than a centralizing theme for this build.
I'll look for the improved string library, been using SimpleNumbers so far, and that's been working out great for me.
I could've used a multiplexing scheme for driving the nixies, as it is I'm using 4 pins per digit (24 pins from the prop) to run each of the 74141 driver chips per tube. But I'm sure that would've increased the complexity of the code, and may be an earmark for a later refinement of the project.
I appreciate all the comments here, and plan to take them to heart to help me get to know this chip a lot better.
Thanks,
Ray
p.s. The pictures aren't pretty, but it's a work in progress. I picked up a lot of 20 of the small IN-17 nixies from Ebay a number of months back & have 50 driver chips from another auction just sitting around, figured I'd put them to good use. And what better controller to drive them with than the Propeller?
Post Edited (RayNelson) : 10/28/2009 4:06:05 AM GMT
I love nixie tubes and have a couple clocks around the house that use them, but my propeller clock will be a bit more unusual using servos and stepper motors to display time in a more analogue style.
Steve
Since the clock code is relatively light, I think I can fit the network communications in and still have plenty of room to spare.
I've built a few other Nixie clocks in the past, that was one of the reasons I have a bunch of spare tubes sitting around. This is the first time I've tried to take the hard way (design something from scratch) however.
Wife just loves my collection of "junk", but if I can produce something useful, it's allowed to 'cohabit' in the common spaces outside my workbench.
Thanks again everyone,
Ray
I'm there with ya! I'm terribly impatient and I went from blinking a few LEDs straight into making a USB battery pack with the prop as a battery monitor and status indicator, and user interface. Now I have a breadboard wired into the house HVAC system with my own 100MHz thermostat [noparse]:)[/noparse] I keep learning more along the way. I'm still quite the newb myself here but I like to help where I can. I just tacked a different clock into my project and found this interesting.
I just always recommend the PE LABS stuff because you get a basic grounding in the concepts. I then go back to it now and again when something I'm trying needs help. I learn best by getting into something and working through it rather than step by step methodical plodding and it sounds like you are the same.
I really like the Nixie Tubes. I'd never heard of them before and even my Wife agreed they look pretty neat.