A better….Infrared remote light control system

Read below for history, but the final project is here!

This is an update to Infrared remote light control system. I never included the schematic, which is good because it was a great idea, but horribly implemented. Ten months ago I was only getting started with C, and now I know even more than before. I have updated the remote controller program and schematic to make it work even better. I used a sleep() function and the Watch Dog Timer to make it low power and to simplify the operation and construction. I’ll leave the old posting, but this is the best way to make the remote. I’ll disassemble the receiver and get a schematic out for that, someday.

An Interrupt Using an Input Pin on a PIC16F690 CCS C

This is just a short post on how I used an interrupt to make my Pickit 2 cycle through the LEDs. This is a very simple program, and sadly I tried this once before and it didn’t work. I did a little research and found that I didn’t enable the correct interrupts.  This experiment is just one of a few that may need to take place to design my POV for my CCS compiler. I have a Picaxe POV, but I want high brightness LEDs and it to be in C. I like projects, and this one (POV)  is going to be a little bit different than the Picaxe one. Enjoy the journey in developing my next toy.
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
}  }  }

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
}

CCS C and Microchip PWM – Pulse Width Modulation

Tonight I was wondering why my PWM wasn’t working. It took me a while to figure it out, but I have it working.

Start with your C file with your normal #include and #fuses. Inside your main function you’ll use 4 built in functions and the super loop While statement. That is it! I wired a high brightness LED to pin 5 of the PIC16F690 on the Pickit 2.
Continue reading