Making Magnificent Moonlights

Got any home remedies or DIY projects? Share them here!
Problems with your tank's equipment? We can help!
Fella
Figure 8 Puffer
Posts: 215
Joined: Mon Oct 17, 2005 9:03 am

Post by Fella »

I'm still recovering from this thread.

Give me a little time, I think I'll be ok.

/lytgva;mpn;bo
User avatar
PetPirate
Gone Today, Here Tomorrow
Posts: 1230
Joined: Mon Jun 27, 2005 5:41 am
My Puffers: 3x Tetraodon Nigroviridis in full marine
Location: Shanghai, China
Contact:

Post by PetPirate »

Alright, you 'orrible dissenting lot!

Still warm in the knowledge that our circuit is working, it's time to complete it!

First of all, we need some...

user input

By that, do I mean you all get to have you two bobs' worth :?: Certainly not. I mean we need a way for us to do stuff - like set the time, set the brightness, and order pizza. :lol:

Yes, we need a button! Or, more appropriately, a push-switch.

Switches are simple, right? Push to close a circuit. If you intuitively wanted to add a switch to our project, most people would probably try to do something like this:

Image

But that ain't gonna work! In this case, what happens when the switch is pushed is that the MCU sees 5V. That's good... 5V is "1". But when the switch is open, the MCU doesn't see a "0", or 0V. Instead it sees "nothing" - neither 5V or 0V... the input is floating between the two, and could be either a "1" or a " 0 ".

That's not much good, is it? Fortunately we can fix it with a bit of ingenuity. Like so:

Image

There. Now, when the switch is *open*, the chip sees 5V, or "1". When the switch is closed, current flows down to ground, and the MCU will see 0V. The resistor is fairly large - say, 10K, to ensure that not much current flows, but it is still small enough for the MCU to clearly see 0V.

There! Done! That's our switch. :D

Here it is incorporated into our circuit:

Image

Right, now we need something else..... we need....

A display

Yup, no use having a button if we have no indication what it does. So here's where a nice, swanky LCD display comes in.

Picbasic.. and MikroBasic have built-in support for "intelligent" LCD displays based on or compatible with the Hitachi HD44780. Sounds complicated? Well, I'll admit, they do need a few wires to wire them up.... but controlling them is a breeeeeze. :D

Here are some standard LCDs I have in my rather dull collection:

Image

They come with a varying number of connection pins, but the first 14 are always the same:

Image

Now, if you're anything like me the first time I saw that, you'll be thinking .... FOURTEEN connections!!!!!!!! You're kidding, right?

Well, no... I'm not. The good news is, we don't have to use all of them. The first three are just power settings (a potentiometer is strung between +5V and ground, with the variying resistance going to the contrast pin, to allow us to fine-tune contrast). The MCU knows what to do with RS and E, and because we're not using RW, we just tie it to ground. 8)

What's more we don't need to use all eight data pins. Our MCU is Sooooo clever, that it only needs to use 4. A bit like riding a bike without holding the handlebars. Except safer. So, we only use D4 ~ D7, and leave the others unconnected.

Image

See, only SIX connections to our MCU now..... not too bad. :D

For more infor on LCD displays and PIC microcontrollers, see this

Here's our trusty old circuit diagram, with our LCD display in place:

Image
Last edited by PetPirate on Sun Nov 20, 2005 12:43 am, edited 2 times in total.
Created a User Gallery yet? Go On!

Affordable Metal Halide Lamps: http://www.petpirates.com
User avatar
PetPirate
Gone Today, Here Tomorrow
Posts: 1230
Joined: Mon Jun 27, 2005 5:41 am
My Puffers: 3x Tetraodon Nigroviridis in full marine
Location: Shanghai, China
Contact:

Post by PetPirate »

WAIDDDDAMINNIT...... What do you mean "Nearly done"? What now?


Sorry, just one more thing. In order to include a timer, and to know which day it is, we need to include... well... a clock :idea:

but can't the MCU do that???


Not really... not very well. It's so busy doing other things that it would be difficult to ge t it to accurately count the time as well. Plus, trying to do so would be a pain. It's easier to tack another bit of hardware on, and just ask it what the time is every so often. Just as in real life - it's easier (and cheaper) to ask the time than buy a watch. Or something. :?

Anyway, that piece of hardware is called a "REAL TIME CLOCK", or RTC.

Here's the one we'll be using -- the DS1302 from Dallas:

Image

As you can see, there are a few things this chip needs to live... again, a capacitor to smooth the power supply. Again, a crystal. This crystal is a bit diffrerent from the one we're using for our MCU though --- this crystal is tiiiiiiiinnnnny and accurate. 32.768Khz. Don't ask me why -- but 32,768 is always what we use for keeping time. The crystal doesn't need any added capacitors, if you get one with the right capacitance rating. 8)

The only other thing we need is a backup battery. Then, when the power goes off, the RTC can remember the time. A non-rechargeable lithium coin cell should last up to TEN YEARS or so..... so I've added in one of them! 8)

Here is Ms. Dallas added into our circuit diagram.

Image



WHAAA... THERE'S MORE??


Yep. Simple though. One button isn't going to cut it for setting the time, is it? Most digital clocks use one button for "Mode", and then a couple for "Select", don't they? Let's do the same: :P

Image

*DONE. 100% FINISHED. ALL THAT's LEFT IS TO FINISH BUILDING. And that's just a matter of plonking the components down on the board, isn't it? Watch this space!!! :arrow: :arrow:
Last edited by PetPirate on Sun Nov 20, 2005 12:55 am, edited 5 times in total.
Created a User Gallery yet? Go On!

Affordable Metal Halide Lamps: http://www.petpirates.com
puffermama
Figure 8 Puffer
Posts: 126
Joined: Mon Oct 24, 2005 12:18 pm

Post by puffermama »

Oh Well! If you're gonna edit out the proof !!!

0)



Whoa! This post was meant to be before all these other diagrams
User avatar
PetPirate
Gone Today, Here Tomorrow
Posts: 1230
Joined: Mon Jun 27, 2005 5:41 am
My Puffers: 3x Tetraodon Nigroviridis in full marine
Location: Shanghai, China
Contact:

Post by PetPirate »

puffermama wrote:Thank you Jhong for counting my vote correctly. You are so great!
No worries, Puffermama! 8)
Created a User Gallery yet? Go On!

Affordable Metal Halide Lamps: http://www.petpirates.com
User avatar
PetPirate
Gone Today, Here Tomorrow
Posts: 1230
Joined: Mon Jun 27, 2005 5:41 am
My Puffers: 3x Tetraodon Nigroviridis in full marine
Location: Shanghai, China
Contact:

Post by PetPirate »

Building time again!!! All too complicated?????


Let me put it into perspective for you: Here are the parts we're gonna need:

Image

Not all that much is it? Just a few tiiiny things.

Ready?
Created a User Gallery yet? Go On!

Affordable Metal Halide Lamps: http://www.petpirates.com
Jager

Post by Jager »

and the price just keeps on rising.........

geesh lcds too.. what you gonna display ? the sports scores between the puffers and the prawns.

Ill save you the time it was a shutout. the puffers literally ate their way through the prawn's lines.
User avatar
PetPirate
Gone Today, Here Tomorrow
Posts: 1230
Joined: Mon Jun 27, 2005 5:41 am
My Puffers: 3x Tetraodon Nigroviridis in full marine
Location: Shanghai, China
Contact:

Post by PetPirate »

ROTFL

No, I'm going to display "Jager's quotes of the day" on it :P

Cheap stuff. 2c all in. honest.
Created a User Gallery yet? Go On!

Affordable Metal Halide Lamps: http://www.petpirates.com
puffermama
Figure 8 Puffer
Posts: 126
Joined: Mon Oct 24, 2005 12:18 pm

Post by puffermama »

That GSP's blusher looks so cool, when you've finished making up quotes, you could apply some to your own cheeks to make like that's not your natural colour! 1!)
User avatar
PetPirate
Gone Today, Here Tomorrow
Posts: 1230
Joined: Mon Jun 27, 2005 5:41 am
My Puffers: 3x Tetraodon Nigroviridis in full marine
Location: Shanghai, China
Contact:

Post by PetPirate »

So, who's with me for building this thing? Anyone?
Created a User Gallery yet? Go On!

Affordable Metal Halide Lamps: http://www.petpirates.com
YBeNormal
Former Staff Member
Posts: 506
Joined: Sat Jun 04, 2005 1:19 am
Location: Northern Virginia
Contact:

Post by YBeNormal »

I plan on building one but I will either have to have you program the chip or wait a couple of weeks before ordering the programmer. The good news is that I finished building the auto-top off yesterday and I may be able to daisy chain the 12V power to support both projects.
Bred
Former Staff Member
Posts: 364
Joined: Sat Jun 04, 2005 10:42 am
Location: Toronto, Canada
Contact:

Post by Bred »

Jhong wrote:32.768Khz. Don't ask me why -- but 32,768 is always what we use for keeping time.


32768Hz is the frequency at which common quartz crystals vibrate when a current is passed through them, that's why. :D It's a perfect harmonic oscillator, way more accurate than the pendulum in a grandfather clock. Luckily for us, it's much smaller too!

Nice one - LED display... I honestly didn't see that one coming!

You've left me behind in the dust. I'll probably never make it this far, but it is a very interesting read!
User avatar
PetPirate
Gone Today, Here Tomorrow
Posts: 1230
Joined: Mon Jun 27, 2005 5:41 am
My Puffers: 3x Tetraodon Nigroviridis in full marine
Location: Shanghai, China
Contact:

Post by PetPirate »

LOL! At least you enjoy the read. It's hard to judge if I'm posting interesting info, or just waaay to many words sometimes.

I didn't realise 32.768 was the standard resonant frequency... since you can purchase crystals of almost any speed (4MHz, 10MHz, 20MHz... or 100's of MHz for the crystals on PC mainboards).

Ah well... I've already got the thing hooked up and am playing with the software to check it is all possible before I post.... my clock is about 30 secs per hour too slow! Not really an acceptable error. I expect it is induced capacitance from the stripboard, so I'm fiddling around with strips of aluminium foil trying to improve the accuracy!

j
Created a User Gallery yet? Go On!

Affordable Metal Halide Lamps: http://www.petpirates.com
YBeNormal
Former Staff Member
Posts: 506
Joined: Sat Jun 04, 2005 1:19 am
Location: Northern Virginia
Contact:

Post by YBeNormal »

Try tapping it real hard on the right side. 8-)P
Jager

Post by Jager »

if in doubt grab the big hammer
Post Reply