# AVR Digital Alarm Clock - Need Review

Status
Not open for further replies.

##### New Member
Hello,

This is my digital alarm clock I designed just for learning about microcontrollers. It is my first MCU project, and I'm pretty new to "real world" electronics in general (I'm an EE student at a university but I haven't worked on many projects yet), so I'm posting it here in hopes that any problems might be corrected before I order all my parts.

I posted a thread about the display, so I'm pretty sure that doesn't need any correction. (I only drew one of the display segments to save space but there is going to be 6).

It's going to be powered off a wall wart 13V supply, and have an LM317 voltage regulator (which I didn't include in the schematic) to convert it down to 5V for the chips to run off.

I already ordered the display, so when it comes I will measure the actual voltage drops across the segments and change the resistor values in my schematic.

I'm not sure if the connections to the MCU on the bottom left are hooked up correctly (like the ISP header).

The "bell" in the bottom right is an automatic bell (like a fire alarm or school bell). It runs on 5V DC and draws about an amp of current. Should I be worried about this drawing too much current through the LM317 when the alarm is going off?

I kind of hooked everything up to any I/O pin I could find on the MCU, could there be a more efficient way to hook things up?

Thanks!

#### marcbarker

##### New Member
Fets are all ok now

#### hjames

##### New Member
If you need to get more IO connections, you should consider using registers or latches.

A 74HC595 serial-in parallel-out shift register needs at least 3 output pins, and you can drive an arbitrary number of them chained together. On the input side, a 74HC165 parallel-in serial-out shift register will let you read an arbitrary number of inputs using 2 output pins and 1 input pin. The other benefit is that you can share these pins - using 3 output lines and 1 input line, you can add 8 outputs or 8 inputs for every additional chip.

There are a lot of other tricks you can play. Since the buttons are connected to analog inputs, you can easily encode multiple buttons per input. Alternatively there is an "obvious" way of using the decoder chip to save 2 IO lines, if wiring isn't an issue.

I vaguely remember Microchip having a lot of application notes on their site that deal with this sort of thing - it might be worthwhile to look for them.

AVR's typically have a built in ~100K pullup resistor on it's reset line, so the external resistor is useful, but not completely required.
When in reset, the AVR will tristate it's IO lines - it is possible for the segment mosfets to stay on, with the column decoder enabling one of the digits. I'd look for some way of disabling the decoder when the AVR is in reset- it has an enable line for a reason!

Otherwise, it'll probably work as-is.

BTW, If this is going to be standalone - you are going to need a 5V regulator somewhere...

##### New Member
For some reason I was kind of intimidated by serial interfaces since I've never used them before, but my current design doesn't need any more I/O pins so I think I'll be fine.

I'm going to have a LM317 for voltage regulation (I just didn't include it in the diagram)

I'm kind of confused about how the whole reset thing works. Is it only used in programming? I'm going to use the USBTinyISP, which says it provides its own power to the circuit. So, if I want to program, I will unplug the circuit from the power source and plug in the programmer, right? Even if the column decoder enables a digit, the digit won't have any power, and neither will the decoder I think. Or am I mixing something up.

#### hjames

##### New Member
The standard mode is to use ISP while all power is applied - hence the concern about peripherals turning on while in reset. It also speeds up the development process if you don't have to unplug everything each time you want to test new software. It is called "In system programming" for a reason.

The only thing that would happen in your case, if the 1A bell turns on while powered through USB, it is going to glitch the USB power supply and reset your programmer.

##### New Member
Grr...I just noticed my line-selector decoder needs to be active high (i think) and the one I have is active low. Can I replace the 2n7000 with a P-channel FET to make that work? Or should I try to find another decoder that is active-high. EDIT: nevermind, I can just use the '237 instead of the '137 decoder.

Assuming it did work though, I think I can just disable the decoder by connecting G1 to the reset pin.

Like that. Will that work?

I have a pull-down resistor on the transistor connected to the bell so it doesn't fire off when it's programming. I think the display and the bell are the only peripherals I have to worry about.

EDIT: Wait, I'm confused. If RESET goes low, won't there be a short from the +5V connected to the MCU reset pin?

EDIT2: I think I have the P-channel FET connecting to the common anode of the display inverted. (the drain and the source should be flipped I think).

Last edited:

#### mvs sarma

##### Well-Known Member
at the outset, the FET Q5 is shown connected wrongly, D&S need to be swapped.
One BS250 cant drive seven segments in case you need to display "8". no current limiter shown either at digit drive or segment drive? perhaps you need a resistor on the drain of each segment drive FET.

Why at all you need the Q5? Can't 2N7000 alone serve? When input is logic 1, it conducts and delivers 13V with a series resistor to the CA pin of the display, instead of Ground. I feel it should be enough. You might need a higher power device for reasons mentioned above.

In general, too costly a design with lots of MosFets.

Last edited:

##### New Member
at the outset, the FET Q5 is shown connected wrongly, D&S need to be swapped.
One BS250 cant drive seven segments in case you need to display "8". no current limiter shown either at digit drive or segment drive? perhaps you need a resistor on the drain of each segment drive FET.

Why at all you need the Q5? Can't 2N7000 alone serve? When input is logic 1, it conducts and delivers 13V with a series resistor to the CA pin of the display, instead of Ground. I feel it should be enough. You might need a higher power device for reasons mentioned above.

In general, too costly a design with lots of MosFets.

Yeah, I just realized it needs to be swapped. I forgot I put in BS250, I changed it to FQP27P06. I don't think the 2N7000 can be alone because the MCU or decoder would have to output 13 volts to turn it on. (see this thread)

Revised:

#### mvs sarma

##### Well-Known Member
Yeah, I just realized it needs to be swapped. I forgot I put in BS250, I changed it to FQP27P06. I don't think the 2N7000 can be alone because the MCU or decoder would have to output 13 volts to turn it on. (see this thread)

Revised:
After all, why you need 13V there? You can work at lower voltage like 5V unless the Vf of the LED segment is more. With a base resistor even BC547 can drive the segments. Unless you are having tonnes of 2N7000.

#### hjames

##### New Member
Yikes, too many revs.

I apologize for misreading your original schematic - I thought you had a a N-fet for Q5. That would have caused a ~1-2V drop across it if you used a good mosfet. Not great, but not the end of the world. All the polarities would've worked out as well.

The other option, if you can't get one of the '237 parts is to wire up the mosfets in a common-gate configuration (gate gets connected to +5V, low voltage input goes to source, output goes to drain).

Well I found the '237 on mouser so that's not a problem anymore (it's about twice as expensive as the '137 for some reason though, but still only $0.69 so I don't really care). I'm still confused about that RESET line though, probably because I don't really understand how it works. But if the RESET line is low, and I have a +5V source connected to it, won't there be a short circuit? Also, maybe I should have an LM317 just for the bell itself, and a separate one for the rest of the circuit? #### hjames ##### New Member The reset line of the AVR should be connected to +5V through the pull-up resistor, not shorted to it - you had the right setup on the first schematic. The idea is that the ISP programmer will pull the AVR into reset when it goes to program it. While it is doing this, it will also turn off the decoder and the display goes off. The standard way of driving LED displays is to drive them with some multiple of the max continuous current to make up for the low duty cycle - each digit spends most of it's time off. The problem is that when the AVR is being programmed, it may go away for a couple seconds, during which time your LED display will go smoke itself. #### toohyetoreply ##### New Member Oh, okay that makes more sense. At first you said that pull-up resistor wasn't completely necessary so I got a little confused there. So, I think that should be everything then (unless there are more things I haven't noticed). Thanks for all the help!! #### toohyetoreply ##### New Member Hrm, does anybody know an easy way to power this? I started looking for 13-15 V wall adapters but everything I found was around$20 . I think I might need like 1.5A max.

Is it hard to just build a power supply from scratch? I've looked into them and we covered them briefly in class but I'm kind of scared of hooking up mains voltage to my project.

#### mneary

##### New Member
When I need a small power supply I think of MPJA. I saw 12V 3A for $5.95. Item 17463 PS. or a dual output 12V and 5V 1.5A each for$2.95 Item no 16246 PS. (strange connector).

Or AllElectronics 15V 1A regulated power supply \$8.75 CAT# PS-151.

##### New Member
I wish I had those LED displays now so I can check the actual voltage drop, but I think it will be another week before it comes. If it's actually 11V like the ebay ad said, I think a 12V supply would be too little.

I'll hunt around some more though, thank you.

Last edited:

#### indragu

##### New Member
Digital Clock with Alarm Function

Thank you for your nice project.
In my blog I also design Digital Clock with Alarm Function.

Last edited by a moderator:
Status
Not open for further replies.

Replies
13
Views
14K
Replies
5
Views
3K
Replies
2
Views
2K
Replies
3
Views
3K
Replies
0
Views
3K