PDA

View Full Version : Using PIC16F84A as a timer for several I/O



OptimusPrime
- 22nd March 2009, 02:49
Hello everyone,
i want to use PIC16F84A as a timer,
basically im wokring on a sun-tracking system for solar panels which use LDRs to comapre light intensity and motors to move the panel accordingly.
Now the problem is that i have to move the solar panel in both azimuth and vertical directions, so i was thinking, instead of using two separate circuits for the directions i use a timer circuit instead.

The timer circuit's function would be to turn on 2 LDRs, and the motor for vertical direction for about 1 minute, and then switches to 2 LDRs and motor for the azimuth direction

i would appreciate if anyone can help me with this issue, or pls refer me to a project in this forum of the similar nature

Thank You

paul borgmeier
- 22nd March 2009, 05:14
... lots of timer examples in the Example Code Section. See these for example:

http://www.picbasic.co.uk/forum/showthread.php?t=2129
http://www.picbasic.co.uk/forum/showthread.php?t=190
http://www.picbasic.co.uk/forum/showthread.php?t=632

there are more in that section as well.

mackrackit
- 22nd March 2009, 05:38
Do you really want the device to work on one for a minute and then the other? Or make the adjustment then wait for a minute before the other adjustment is made?

Start:
Vertical routine
pause for 1 minute
azimuth routine
pause for 1 minute
Goto Start

OptimusPrime
- 22nd March 2009, 09:55
Do you really want the device to work on one for a minute and then the other? Or make the adjustment then wait for a minute before the other adjustment is made?

Start:
Vertical routine
pause for 1 minute
azimuth routine
pause for 1 minute
Goto Start


I just want the device to work on one for a minute and then the other.
i already have a circuit which does all the tracking and movement of the motor, you see that circuit gets its input from 2 LDRs and then moves the motor in azimuth direction depending on where the sun is.

Now what i want to do is, instead making a new circuit for the vertical direction, i want to make a timer circuit using PIC16F84A. So, now 2 inputs from the tracker circuit go into the PIC for timer circuit which is then connected to 4 LDRs as outputs (2 for vertical, 2 for azimuth). Two wires (negative, positive) for the motor control coming out from the tracker circuit go into the PIC for timer circuit as inputs, and at the output there will be 4 wires (2 wires for azimuth motor, 2 from vertical motor).

Sooooo, for the first minute 2 LDRs for azimuth and motor for azimuth turns on, once thats done the trakcer circuit will do all the tracking and motor movement. After the 1 minute 2 LDRs for vertical and motor for vertical turns on... and then continues as a loop

wowwwww thts looong, sorry for that, any help would be appreciated

take care

mackrackit
- 22nd March 2009, 11:19
What about this, if I am following you.
All you want to do is turn on one circuit for a minute and then turn on another for a minute.
The circuits are all ready built and working. I will assume they are separate and if power is applied they will run. Why do you want the LDRs connected to the timing PIC?

Have the power of a tracking circuit driven by a relay or MOSFET/transistor.
Now you have two pins as out puts from the timing PIC. One for each tracker.

When a PIC pin is set either HIGH or LOW it will stay that way until it is changed.
Try it with an LED.



START:
HIGH PORT?.? ' A Tracker POWER
LOW PORT?.? ' B Tracker POWER
PAUSE 60000
LOW PORT?.? ' A Tracker
HIGH PORT?.? ' B Tracker
PAUSE 60000
GOTO START


I know...I am missing something.

Archangel
- 22nd March 2009, 17:57
I know...I am missing something.
I think he wants to switch the circuit he has from 1 motor to the other so as not to buy / build another tracking circuit. It is doable but the issue I see is when switching from 1 set of sensors to another the calibration difference may throw things out of whack. I think all you need is a simple loop to switch a relay, something like:


loop:
PortB.0 = 0
pause 60000
portb.0 = 1
pause 60000
goto loop

EDIT: Another issue came to mind, and that is how your tracking circuit will react to having its outputs go from open circuit to loaded
being switched by a relay, I am thinking some big resistors (high watt high ohm value) joining those circuits to handle the transients, or perhaps MOVs. Better yet use FETs to switch instead of relays . Damn I must be getting old . . . :D

OptimusPrime
- 23rd March 2009, 12:55
WOWWWW guys, i didnt think this would be that complicated.

Ok let me try to explain once more, u seeeee i already have the tracking circuit made, i got the 2 LDRs (FYI: these LDRs compare the light intensity and then move motor to a postion where there is equal light falling upon them) and the motor running at 12V, everything is setup, basically i have finished the tracking system for azimuth direction.

All i want to do is thaaat instead of making a whole new tracking circuit for the vertical direction, i want to use an automatic timer. so now i should have one tracking circuit, 2 LDRs for azimuth direction, motor for moving panel in azimuth direction, 2 LDRs for vertical direction, and a motor for vertical direction. All the automatic timer should do is that to switch from one motor and a pair of LDRs (azimuth direction) to the other motor and a pair of LDRs (vertical direction).

is there any project anywhere of this nature that i can refer to?

Guys i seriously appreciate all the help u have provided, i mean believe it or not, this was my first time ever posting a message in a forum, and im really glad to see the kind of respose i have recieved.

thanks once again, any furthur help would be appreciated,

take care

Dave
- 23rd March 2009, 13:29
OptimusPrime, All you need is a 4 pole double throw relay. 2 contacts for the motor output from the tracker to the motors and 2 contacts for the 2 sets of LDR's. Program the PIC for 60 second pause then toggle 1 of the outputs to drive a transistor to switch the relay... Pretty simple I think...

Dave Purola,
N8NTA