Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

using a RTC in SF basic

MrDEB

Well-Known Member
I have a DS-1302 RTC module but how to use it?
I recall Jon Chandler made a vu meter clock but what he used for timing?
Am planning on a clock that has no hands, just LEDs but precision would be nice.
 
Unsolicited (and probably unappreciated) advice.

Look at these clock faces with 60 minute LEDs and 12 hour LEDs. What time is it? From the left:
  • 3:00
  • 3:15
  • 3:30
  • 3:45
  • Almost 3 o'clock or almost 4 o'clock?
clock face 1.jpg


In a normal analog clock display, the hour hand moves from one hour to the next as time progresses rather than being fixed at one hour until the next. This display looks more like a conventional clock. It's not ambiguous.

clock face 2.jpg


In this display, the hour LEDs increment as the hour progresses. At the top of the hour, only one LED is illuminated, incrementing again until the next hour. A more interesting, easy to interpret look.

clock face 3.jpg


Using two rings of 60 LEDs allows for options. Using only 12 LEDs for the hour ring locks you into what may be an unintelligible display.
 
"hour LEDs increment as the hour progresses" - That is how I have my display. Every 12 minutes one of the 60 LED's representing the hour advances... Instead of having an Hour counter that advances every 60 minutes, my Hour counter advances every 12 minutes. (<-- Actually more complex than that since the time is originating from the Web, and the Hour position needs to be derived based on where the minutes actually are. But for simplistic reasons, the explanation at the beginning will suffice)
 
Geez oh grief. Find an understandable video. The buttons aren't pushed randomly to get an output.

Also, post a drawing of EXACTLY what you have hooked up AND EXACTLY the sequence of buttons you are pressing.

To load data:
> Press and hold the data switch and press clock to enter a high bit.

> Press and release the clock switch to enter a low bit.

> When 8 bits have been entered in, press the latch switch to display the entered data.

Alternatively, the latch switch can be pressed after each press of the clock button to see the date move through the shift register.

 
Last edited:
One has to wonder if MrDEB got the test circuit working with a more understandable video, or if he's already moved on to drawing a schematic and laying out a circuit board.....
 
The test circuit is/was wired correctly but fails to work. WHY??
Waiting for new chips.
In the mean time trying to get a SF code to work properly (a different project from several years ago) but have been attempting to get the clock circuit laid out but could not find a RADIUS setting so just drew two circles.
 
Did you watch the video I posted? It's much clearer than what you posted.
 
The test circuit is/was wired correctly but fails to work. WHY??

Without knowing what you have wired up, or what button sequence you're pressing, how could anyone answer that question?

Once again, you have a hardware problem (wired wrong) or a software problem (not pressing buttons in the correct order). The video I posted has a clear diagram and explains the sequence of operations clearly.

If following that video doesn't solve your problems, post pictures showing your actual circuit and exactly the sequence of buttons pressed.
 
While waiting for parts, I come up with the Gerber file to assemble 5 clocks. 50 boards total = $22.60. The last shipment without shipping was $27.37 for 5 boards = 5 clocks.
Not much of a saving?
 
So you haven't got the simple test circuit to work, but you had boards made?

SMH.
 
Still waiting for chips
A bad chip is the least likely cause of your troubles. Did you watch the much clearer video I posted and follow the steps I suggested ?

Didn't think so.
 
Well the shipment of 74hc595 finally arrived late yesterday (12/20/24). Boy tlk about a slow boat from China. have yet to receive the PCB's from 3 weeks ago.
Found this bit of info that is slightly different than post #223.
Got to wonder if I used the output on pin#4-QE instead of pin #9-SQH as the overflow so I can use 5 outputs per instead of 8 per section (post#109 https://www.electro-tech-online.com/threads/using-a-rtc-in-sf-basic.166376/post-1455845
 

Attachments

  • Screenshot (72).png
    Screenshot (72).png
    1.4 MB · Views: 13
Got to wonder if I used the output on pin#4-QE instead of pin #9-SQH as the overflow so I can use 5 outputs per instead of 8 per section
Not if you want it to work. The QH' output is not the same as the QH output. Saving words that won't be read anyway, QH' is before the latch registers.
 
I think you need to step back and get a better understanding before you proceed. From your comments and the picture you just posted, you're totally missing the concept.
 
back to designing for 8 outputs per shift register.
THEN stop at 60 and return to 0
The shift register isn't a ring counter. Throw that thought away.

It's been explained in post #192, etc. but let me add some more detail.

The 74595 is a serial-in, parallel-out shift register. One byte (8 bits) of data is shifted in, and when latched, the eight output lines are set to the value of the associated bit (1 = high, 0 = low). When multiple 74595s are used, the data is moved from one to the next. In most cases, including this one, a number of bytes equal to the number of shift registers, and then the latch is strobed, displaying the new data (e.g., if you have 10 shift registers, 10 bytes will be shifted out every time an update is desired).

The diagram below shows how this works.

If you're making a clock using 10 pcb segments, with two rings of 60 LEDs each, I strongly recommend 6 LEDs for the outer ring be on the first shift register, and 6 LEDs for the inner ring be on a second shift register. Don't use the two "extra" outputs of each shift register or add some extra LEDs for decoration or other purposes. Doing it this way will keep programming much simpler – you'll have a "minutes" byte and an "hours" byte for each segment.

If this still isn't abundantly clear, it's time to put this project away.

Note: I recycled the schematic from post #192. This isn't an attempt to show you your exact arrangement. If you follow the suggested advice for a 2 ring × 60 LEDs using 10 identical pcb segments you will have 20 shift registers and you will shift out 20 bytes for each and every update.


id-shift reg.jpg
 
Last edited:
As has been said by others in MrDEB-Land, there's nothing new under the sun as this thread from 12 years ago will show.

From that thread:

You have to include the shift module:

Include "shift.bas"

The command will be either

OUT (MSB_FIRST,data,8)

Or

OUT (LSB_FIRST,data,8)

For the diagram above, the command will be either:

OUT (MSB_FIRST,data,8)

Or

OUT (LSB_FIRST,data,8)

LSB_FIRST or MSB_FIRST controls the order the bits are sent, so what's best depends on the order the LEDs are arranged.

So something like this:

Code:
For I = 0 to 19
      OUT (LSB_FIRST,LEDData(i),8)
Next

Also from the above thread:

Note, as shown in the documentation, you must define the data (out) pin and the clock pin.

I believe I have made this as clear as anybody could.... again.
 
Last edited:

New Articles From Microcontroller Tips

Back
Top