POV: Persistence of Vision with a PIC16F690

POV ImagePOV ImageOver the past two days my wife and child have been sick so I’ve had lots of home time to POV Imagework on this project. It’s pretty amazing to me that I just started this PIC16F690 POV project less than two days ago, and I already have it finished and working. I worked pretty hard to get the C files completed for this. I also drew a board with Eagle, but I just used some scrap perfboard. Nothing in the world beats point to point soldering. It was actually pretty easy since there isn’t really much to solder in this project.

Continue reading

Part 2: Going to Sleep(); An Interrupt Using an Input Pin on a PIC16F690 CCS C

This is part two of the POV design. I added a sleep function to this program. It counts up to 14. Once it hits 15 it goes to sleep, only to be awakened by MCLR and starting from the beginning of the program. Please enjoy.

#include <16f690.h>
#fuses intrc_io,mclr,put,nobrownout,nowdt
#use delay(clock=31000) //clock set to oscillator frequency
int count=0;

#INT_RB //this is the interrupt
void interruptMe(void) { count++; delay_ms(250); }

void main(void)
{
setup_oscillator(osc_31khz); //This uses less current than 4MHz
enable_interrupts(INT_RB7); //a change on RB7 triggers interrupt
enable_interrupts(GLOBAL);

while (1)   {  output_c(count);
if (count==0x0f)
{
output_a(0×00); output_b(0×00); output_c(0×00); //set all outputs to ground
sleep(); //should only wake up after MCLR
}  }  }

Another Digital Clock: PIC16F690 and Blue LEDs Make a Good Time

This is a continuation of this post Using the PIC16F690’s (and others’) Internal Timers to Keep Time

We are not using a crystal or an RTC for this digital clock!!! This is just a demonstration of the internal timers and is not intended to keep actual time.

So, since we aren’t using an RTC, and we are using just a simple internal RC oscillator embedded in our PIC16F690, what kind of accuracy are we looking at? Well, if you are a perfectionist, than stop reading!!! This will not compete with your Seiko (You’ll see why I said that soon). It can’t compete with the DS1305. What it can do is make a somewhat accurate clock at half the cost and half the soldering(maybe) and half the programming and half… I think you might see my point of why this is a cool project. We all have cell phones and computers that have Atomic timekeeping or something, but who has an Altoids clock? Or whatever you decide to do with it? If you can initial off on the  “not perfect” line, please continue. (I’ll explain how inaccurate this thing is in just a few paragraphs)
Continue reading

Using the PIC16F690′s (and others’) Internal Timers to Keep Time

This one is so easy a kid could do it. Actually, once you see how easy it is  to keep a somewhat accurate count with an internal oscillator, you’ll probably wonder why I ever spent $7 on a DS1305. If you just want a simple, somewhat inaccurate timepiece, neglecting to use an RTC can make things really simple. The $7 for a real RTC is worth it :).

The first experiment is to check if our interrupts work. We are using timer 2 to generate an interrupt every millisecond. Inside the interrupt we have a 16-bit variable counting to 1000, and then it increments the seconds variable. Then, when seconds hit ten, it starts the loop back at 0. I then output the seconds byte to port C on the Pickit 2. The LEDs show a binary count of the seconds. Tune in for the next installment. I’ll have a clock with four blue 7-segment LEDs that I’m stealing from my first clock project that kept time right, but nothing else.

#include <16f690.h>
#fuses intrc_io,nowdt,nomclr,noborownout,put
int seconds=0; int16 milliseconds=0;

#INT_TIMER2
void incrementSeconds()
{
milliseconds++;
if (milliseconds==1000)
{milliseconds==0; seconds++}
if (seconds==10) seconds=0;
}

void main(void)
{
enable_interrupts(INT_TIMER2);
enable_interrupts(GLOBAL);
setup_timer_2(timer_2_div_by_1,0×64,10); //1ms interrupt
set_timer2(0);
while (1)
{ output_c(seconds); } //binary count of seconds
}