History
I originally posted this for a Parallax customer who asked for a minimal example of getting the time from a DS1302 and the temperature from a DS1620 being displayed on a Parallax 4×20 Serial LCD Display. I already had example code for displaying the Day, Date and Temperature on a 2×16 Display in my Binary / Digital Clock project and my Digital Thermostat project.
The schematic in Figure 1 shows the connections for each IC to the BS2. Note that by sharing the clock and data lines, the total I/O pins for these two chips is four pins. Since a single SPI device normally uses three pins, that’s a savings of two pins. The 1K resistors are there to protect the I/O pins in the event of a programmer error that might cause contention.
My example was assembled on a Board of Education USB. Figure 2 shows the connections on this development board.
To use this program, run the DS1302_Demo.bs2 and set the date / time, then run the Clock_Temp.bs2 and the DS1302 will still have retained the date / time information. Figure 3 shows what the output should look like on the 4×20 Serial LCD. You can add a backup battery to the DS1302 to preserve the date / time data. See the post link below for original information.
Resources
Original Post on Parallax Forums
Binary / Digital Clock – Project
Discuss this tutorial on Savage///Chats
Released under MIT License
Copyright (c) 2013 Chris Savage – Savage///Circuits.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
PLEASE FEEL FREE TO LEAVE YOUR COMMENTS, QUESTIONS, SUGGESTIONS OR FEEDBACK ON THIS POST.
Leave a Reply
You must be logged in to post a comment.