Forums

Question: Variable timing using a potentiometer & 16c84 PIC

Started by Jagrolet September 7, 2004
I am new to PICS...Can anyone point me to any assembly or pic basic
code that will do the following: (Preferably assembly)

I want to push a button to light an LED for a specific amount of time
and then turn off.
(Got this part figured out)
I also want a potentiometer included that will adjust that time delay
plus or minus a time period.

Example:

I push the button and the POT is in the middle of its range, and it
lights the LED for 10 seconds. If the POT is turned all the way up,
the time is now 15 seconds, and if the POT is turned all the way down
the time is now 5 seconds.

I am using a 16c84 or 16f84 PIC.

Any help is greatly appreciated

Thanks,

Terry Best
"Jagrolet" <jagrolet@yahoo.com> wrote in message 
news:a5fsj05e8g6o4k3u2ohbt7duq5u27pd2a7@4ax.com...
>I am new to PICS...Can anyone point me to any assembly or pic basic > code that will do the following: (Preferably assembly) > > I want to push a button to light an LED for a specific amount of time > and then turn off. > (Got this part figured out) > I also want a potentiometer included that will adjust that time delay > plus or minus a time period. > > Example: > > I push the button and the POT is in the middle of its range, and it > lights the LED for 10 seconds. If the POT is turned all the way up, > the time is now 15 seconds, and if the POT is turned all the way down > the time is now 5 seconds. > > I am using a 16c84 or 16f84 PIC. > > Any help is greatly appreciated > > Thanks, > > Terry Best
Probably better ways to do this on parts that have an analogue to digital converter or a comparator. The 16x84's have neither. The usual way would be to charge a capacitor through a resistor ( in this case pot ) using one of the port pins and then periodically change that pin to an input and measure how long it takes to flip state as the capacitor charges. Varying the pot will vary the RC time constant of the setup which can be measured by the PIC. The time from when the charge cycle starts to when the pin changes state is related to the position of the pot. The manual that comes with the PICKit 1 demo board explains the technique but unfortunately doesn't have any code examples > http://ww1.microchip.com/downloads/en/DeviceDoc/40040b.pdf ( look at tip #13 ) Better still move from the 16x84's to the better (and cheaper) 16F628. It is pretty much identical from an upward compatible view, but has a comparator built in as well as UART, more RAM, more OSC types ... etc. Colin
I have seen that tecnique described in 1 other place but they too did
not have an example of the code required to accomplish it.
I am in a steep learning curve ant many code examples exist for the
16x84 chips which I seem to be picking up on fairly well.
Also thats the chip I have on hand...
I greatly appreciate your replying to my post.
Hopefully someone can provide an example.

Terry



On Tue, 07 Sep 2004 23:07:19 GMT, Jagrolet <jagrolet@yahoo.com> wrote:

>I am new to PICS...Can anyone point me to any assembly or pic basic >code that will do the following: (Preferably assembly) > >I want to push a button to light an LED for a specific amount of time >and then turn off. >(Got this part figured out) >I also want a potentiometer included that will adjust that time delay >plus or minus a time period. > >Example: > >I push the button and the POT is in the middle of its range, and it >lights the LED for 10 seconds. If the POT is turned all the way up, >the time is now 15 seconds, and if the POT is turned all the way down >the time is now 5 seconds. > >I am using a 16c84 or 16f84 PIC. > >Any help is greatly appreciated > >Thanks, > >Terry Best
I'd like to reiterate that there are better parts for the job. What
you'll find is that you'll spend a lot of time negotiating workarounds
to the 16F84 limitations. I wrote a page on the subject:

http://www.finitesite.com/d3jsys/16F88.html

In article <5jjsj099vg29keaira5arks5kp5n1q509f@4ax.com>,
Jagrolet  <jagrolet@yahoo.com> wrote:
-I have seen that tecnique described in 1 other place but they too did
-not have an example of the code required to accomplish it.
-I am in a steep learning curve ant many code examples exist for the
-16x84 chips which I seem to be picking up on fairly well.
-Also thats the chip I have on hand...
-I greatly appreciate your replying to my post.
-Hopefully someone can provide an example.

Look at Experiment 8 here:

http://www.talkingelectronics.com/Projects/PIC_LAB-1/PicLab1_experiments-P4.html

BAJ
"Jagrolet" <jagrolet@yahoo.com> wrote in message 
news:a5fsj05e8g6o4k3u2ohbt7duq5u27pd2a7@4ax.com...
>I am new to PICS...Can anyone point me to any assembly or pic basic > code that will do the following: (Preferably assembly) > > I want to push a button to light an LED for a specific amount of time > and then turn off. > (Got this part figured out) > I also want a potentiometer included that will adjust that time delay > plus or minus a time period. > > Example: > > I push the button and the POT is in the middle of its range, and it > lights the LED for 10 seconds. If the POT is turned all the way up, > the time is now 15 seconds, and if the POT is turned all the way down > the time is now 5 seconds. > > I am using a 16c84 or 16f84 PIC. > > Any help is greatly appreciated > > Thanks, > > Terry Best
All that you need for this project is a monostable timer. Save the PIC for another day. Peter