Need help with microcontroller

Thread Starter

alexnbk

Joined Dec 13, 2010
2
Hi,

I´m trying to do the following, I have an outlet strip with 4 outlets. Have a CTK 1C 12A 125VAC 5 legs relay and a PIC 16f628-04/P, what I nedd is someone help me program the PIC so it can act on the relay like a timer. I mean 12hr on and 12 hr off for example.


Can someone point me any direction? Yes i´m a newbie in electronics but trying to learn a little more everyday.

Tahnks in advance for those who help
 
Last edited:

retched

Joined Dec 5, 2009
5,207
You are going to have to set up a RTC (Real Time Clock) So the PIC knows what time it is.

Then it is as easy as checking the time to see when 12 hours has passed and to tell a pin to go from High (1) to Low (0) or vice versa.

Do you have a programmer device to get the code onto the PIC ?

Like a PICKit 2 or 3 ?

I would visit http://www.microchip.com and read through the datasheet for the 16F628. Look up application notes for using RTC and setting up the init strings.

Download MPLab and get started on the tutorials.

This will get you going.

I have downloaded a program called "Yenka" that allows you to simulate the PIC with relays, transistors, LEDs, and a bunch more.

Give it a try. It allows you to do the building ON SCREEN rather than blowing up you parts in real life.

Also, get the datasheet for the relay you wish to use to be sure it contains a protection diode, and to see what the coil power requirements are.

The PIC datasheet will let you know what loads the PIC can drive directly.
If the relay is a larger relay, you will need a transistor to boost the power.

If the relay doesn't contain a protection (Back EMF) diode, you will have to add one yourself.

By the way, Welcome to AAC!

Get reading! and Good luck!
 

Thread Starter

alexnbk

Joined Dec 13, 2010
2
I have the pic programmer, built one following info on the web but got stuck exactly on the RTC thing, i´ll give it a try on the datasheet and everything.

Gonna try the yenka for studying.


thx
 
Use a 32.768khz external crystal to keep accurate time on the PIC.

What programming language are you looking to use with the PIC: Assembly, C, Basic?
 

spinnaker

Joined Oct 29, 2009
7,830
I have the pic programmer, built one following info on the web but got stuck exactly on the RTC thing, i´ll give it a try on the datasheet and everything.

Gonna try the yenka for studying.


thx
If all you need is 12 hours off and 12 hours on then a simple timer will do. If you want to turn off and on at specific times then you would want RTC.

But I see no reason why you need a real RTC. You could probably just roll your own. I have not looked into RTC that closely so I am not sure of the exact advantages over just programming your own clock.

BTW A number of PICS come with their own RTC.
 
Top