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.

a little help please :)

Status
Not open for further replies.

joe2005

New Member
Hello

I recently took a small introductory course in PIC, and since I know that only actual practicing will teach me, I decided to try and build a complete circuit from scratch.

I thought that I can do a digital clock that would have all the features (alarm, 12/24 modes, time counting etc..) and I have been thinking about it for few days. Now the problem that occured to me is that the PIC will have to accuratly increment time and at the same time deal with all the other options implemented so how could this be solved??

I had few ideas, the first one was to use multiple PICs but this is so unefficient. The other idea was to write the code in such a way that whatever the PIC does between two "incrementations" it will always take exactly the same time.

By the way I really want to learn here, so please don't just give me the link of a pre-designed circuit and code because this is exactly how I will never learn :wink: ....all I want is few tips.

Thanks for everything...
 
Well, an easy way to start would be to have your pic read a real time clock, like the DS1302, etc. You could easily implement an alarm system by comparing the time it is now to when your alarms are set.
Alternatively, you could set up a timer in the micro to overflow every second. The difficulty with this way is that you have to manage the hours, days, weeks, leap years etc, yourself. If you go this route, you should think about which crystal would give you the best clock speed to divide into one second intervals.
I would divide your project into modules, and get each module working on its own, then put them all together in the end.
Best of luck with the project.
Regards,
Robert
 
joe2005 said:
By the way I really want to learn here, so please don't just give me the link of a pre-designed circuit and code because this is exactly how I will never learn :wink: ....all I want is few tips.

Actually many of us learn quite a bit by carefully examining and studying the abundant PIC project examples on the internet...

Good luck with your project... Regards, Mike
 
BeeBop said:
Alternatively, you could set up a timer in the micro to overflow every second. The difficulty with this way is that you have to manage the hours, days, weeks, leap years etc, yourself. If you go this route, you should think about which crystal would give you the best clock speed to divide into one second intervals.

I'd go for the above timer solution. It will teach you more about the PIC than using a piece of external Real Time Clock hardware.

It is impractical to calculate how long code takes to operate once it gets large and/or contains conditionals or variable length loops. That's why hardware timers are very commonly used.

The 32.768 kHz (or any 10x/tenth multiple thereof) is the clock freq needed to keep time with a timer directly.

However, this is not essential. Say you have a 1MHz clock and a 16-bit timer, which is once every 15.2587890625 sec. The timer can't be adjusted to an even 1/15th sec. But that doesn't mean you can't be exact! The timer routine keeps a hidden 1/15th of sec count, but also keeps a persistent variable to count the extra time from each cycle. Basically just over every 4th timer interrupt it will add to the 1/15th sec counter twice, the rest once. So some seconds on the display will trip slightly early or late, up to 1/15th sec. You won't notice. And the long term accuracy is counted perfectly, as accurate as the crystal used.
 
well, you could just set up the tiimer interrupt interval to be, say, 1/10th of a second and count 10 interrupts. You can compensate for interrupt latency and other over head plus prescalar reset.
 
Want a easy to build PIC clock, check out Zebra clock on my site.

Six digit Charlieplexed display, you could use other PICs including a 16F84 with a little bit of rewiring. A code sippit for the 4 digit Cricket is on my site under Updates March 2006. I used timer2 for the clock and display refresh in both projects. I've even added a serial port, you could hook it upto a GPS if you want very accurate time.

Don't forget to download the MyBlueRoom.TTF font, it's a MAN69xx seven segment display font, great for documenting your clock project.
 
Hey Bill,

Your 1-chip Zebra design looks pretty nice... I'm happy to see someone trying/testing the Charlieplexing multiplexing scheme... May I pass along some tips from my experiments this last year?

<1> Use "active low" or "active high" column driver transistors for Common Cathode or Common Anode displays, respectively, for better display brightness... This allows sinking much more than the 25-ma I/O pin current limit on those columns...

<2> Use 10 to 47 ohm segment current limit resistors when driving more than 4 digits (LED duty cycles less than 25%) for better brightness... Again, the 20/25-ma I/O pin current limit is limiting our brightness... At 14% duty cycles those LED segments would actually like to be pulsed at 40 to 80 ma...

<3> I found Common Anode displays to be brighter than Common Cathode displays because the segment driver pins will sink 25-ma to the cathode segments on CA displays compared to sourcing 20-ma to the anode segments on CC displays...

Have fun... Kind regards, Mike
 

Attachments

  • concept_-_clock___notes.jpg
    concept_-_clock___notes.jpg
    250.4 KB · Views: 488
  • concept_-_clock__1a.jpg
    concept_-_clock__1a.jpg
    55.3 KB · Views: 438
Great post Mike, I like your schematics. Especially the PWM brightness.
In an effort to keep the current levels (and heat) low I've driven the displays sans transistors and no dp. I love the look of LED vs LCD and find the HE red plenty bright now only if I could dim the little 3mm LEDs a little (I know I could use more resistors but simplicity is key)

It was your previous PICList article on Charlieplexing that I picked apart after looking at the Maxim data sheets.

Let me say thanks for your great article on the old PICLIST forums.

Question: Average current 20ma on a PIC Pin, do you know if 80ma at 25% duty is ok for a PIC? (Did you ever see that Super Probe at Mondo Technology? **broken link removed** ) He drives the display directly.
 
William At MyBlueRoom said:
Question: Average current 20ma on a PIC Pin, do you know if 80ma at 25% duty is ok for a PIC? (Did you ever see that Super Probe at Mondo Technology? **broken link removed** ) He drives the display directly.

Hi Bill,

The PIC I/O pin structure keeps us from getting more than that 20/25-ma spec' (bummer)... So you have multiple segment driver pins that want to source 20-ma but your column driver pin limits their cumulative current to 25-ma... Column driver transistors allow us to sink the cumulative segment driver currents (up to 8 segments at 20-ma each = 160-ma)... By the way, with the built-in current limiting of the I/O pin you can pretty much eliminate the segment current limiting resistors alltogether (with 4 or more displays)...

The Agilent or Fairchild low current displays (3-5 ma/segment) work extremely well with Charlieplexing, even without column driver transistors...

Yes, I've seen the Super Probe... A 'nifty' design...

That PWM brightness control doesn't work as well as I had hoped... It seems the unconventional use of NPN or PNP transistors to maintain the "active low" or "active high" signals Charlieplexing requires prevented me from fading the displays completely to black because the displays see the base-emitter current... Using two transistors for each column driver would fix the problem but throwing parts at the problem seemed kinda' silly when you can just add another chip and have a standard multiplexed display with incredible brightness and full "fade-to-black" brightness control for each column while using the same 8-pin interface (see the version 2 clock below)...

Take care... Have fun... Kind regards, Mike
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top