Archive

Archive for the ‘PIC ideas’ Category

Interrupt in PIC16F877A

November 18, 2006 2 comments

Interupt: Well that literally means stopping you from doing something? well yes that’s precisely what an interrup signal does.When a processor keeps working on some program,You may execue a small emergency chunk of program in case you get a signal form a specified source to a pin.

This can be done by polling But will involve a lotof your processor time.Thus you dont spnd time looking for the signal all the time, instead you set that pin for an interrupt option. So your procesor will keep processing any other program without looking for the signal,But once there is a signal your program will be automatically redirected to a funcation called “INTERRUPT”.

In PIC16F877A the most basic interrupt in on Pin RB0.

The following program will make the interrupt program to execute once there is a pulse at pin RB0. The interrupt at raising edge or falling edge is configurable using software approach.

————————————————————————————-
unsigned short count,read;
char num[10];
void interrupt()
{
TRISC=0×00;
PORTC=0xFF;
INTCON.F1 = 0; /* clear the int flag */
}

void main ( )
{
count=0;
TRISB = 0xFF; /* set up port b */
PORTB = 0×03; /* turn off all and any LED’s on port b */
INTCON.f7=0×01;
OPTION_REG.F6 = 1; /* interrupt on rising edge */
INTCON.f5=0×01;
while(1);
}

————————————————————————————

NOTE: Any program here might have a problem with “X” dou to formatting on wordpress. they all are capital X.

The above program will make all pins of PORTC high once there is interrupt signal from some sensor (say) . Once the interrupt is executed ,the procesor will continue what it was working on prior to the interrupt.

Hey now this should be tried.Its fun and a very usefull tool.

Try it!

-Madan

Categories: PIC ideas, Project, Robotics

MP3 Player With PIC Microcontroller

November 10, 2006 4 comments

Well it has been one of my long wish to make a Mp3 player for myself using a PIC. I had seen projects online dealing with voice recording on PIC to one that i hit today which talks about Mp3 player using a PIC. Well i dont own one so possibly i am inclided to make one. I Think i’l feel more comfortable listening to the only song in my Home – Made MP3 player than listening to many on a branded one.

Well this guy on this page called Jesper Hansen <jesperh@telia.com>has just put up a whole site calle YAAP on his Homemade Mp3 Player . I am amused as his copyright statement on one of his earliest codes on the site dates “Copyright (C) 1989, 1991

I wonder Tehno guys just do it that fast. Alrite now i felt it was time for me to explore.
Soon i want to start working with this and come op with a beautiful INVOBOT Mp3 player!! Hmmm sounds too good already.

Well jesper has done all those with a AVR and DRAMs and since I Love PICs we’l have perfect cool PIC based MP3 player here.

Meanwhile i wanted to look into interfacing a DRAM and PIC. I found that too there and i thought i shall just pull it up here so that i don’t forget it later. I have not yet tinkered and explored those codes but its open for all. anyone try it and comment b4 me!!

Schematic

Code

I thing the code is pretty simple and you can get the explanation of this particular code and things on the site from where i hooked this up. The text is pretty small so make sure u feel comfortable reading it by pressing ctrl+”+” (i mean kepp control button pressed and press the “+” button to increase text size).

Cheers
Madan

Categories: PIC ideas, Project, Tech talks

Exact Circuit and MicroC code for stepper motor

June 29, 2006 92 comments

Well saw that people still are having quite some doubts on the stepper motor post that i had put up. so i thot to make that abstact clear i better put the exact circuit and the code here.

The exact circuit to connect the stepper motor to 16F877A is given below

In this the common is connected to the 16V supply(12 v is actually enough actually higher current drives the motor better as far as i know*). If u are new here and donot know how to find the common line in a unipolar Stepper motor then see here

The MicroC code for running the motor is as below.
void main()
{
TRISB = 0×00;
PORTB = 0×00;

//routine to move in one direction
for (i=0;i<50;i++)// increse i=50 no i=100 to cover double the distance
{
PORTB=0×80;
delay(20ms);
PORTB=0×40;
delay(20ms);
PORTB=0×20;
delay(20ms);
PORTB=0×10;
delay(20ms);
}

//routine to move in the other direction

for (i=0;i<50;i++) // increse i=50 no i=100 to cover double the distance
{
PORTB=0×10;
delay(20ms);
PORTB=0×20;
delay(20ms);
PORTB=0×40;
delay(20ms);
PORTB=0×80;
delay(20ms);
}
}

There are much easier ways to write the above code but then i am not worried about the memory it’l take nor have any pressing need to keep my code small and trim ,so i guess this will make you absolutely clear of what i’m trying to do to make my motor run.

If you din know MicroC well,let me brief. The line PORTB = 0×80 (1000000)makes my 8th pin of the PORT “B” that’s b7 pin or the 40th pin go high.The next line PORTB = 0×40(01000000) will make the 39th pin go high and all other low.

Now whenever the pin at the input of the ULN2003 goes high say pin 1 the output pin 16 drains the current throuh the motor thus completing the circuit from supplt 16V through motor to the ground in that line. When you keep doing this in series as i called it the abcd pulse the motor will rotate . When your reverse the pulse order the motor rotates in the other direction. As simple as that. For most robotic application atleast at contest level you may use this circuit uinless you go for bigger stepper motors that need more current to drive and is greater than the 500mA that the ULN2003 can sink!!
i guess i was clear about using ULN2003 to drive a sstepper motor. pl post your comments and doubts
–Madan
I like keeping all my circuits small and simple and not crowd it with resistors and capacitors.Afterall its a hobby and we need not complicate it.Cheers.

Generate video Signals using Microcontroller

May 10, 2006 1 comment

I was sweepin around the net searching for nice project ideas..This thing hit me hard. The topic in itself is so damn hi tech. I found this site at the third page of google down the bottom of the page.Damn what a thought. Now he his taking about generting video signals using PIC microcontroller. What Richard (claims 26,Engineer from sweeden) has don is that he has created the Ping Pong game that is powered by your microcontroller and the video runs on TV. and he says he has also created a tetris game. Aren’t these interesting to learn.He has given code for download but i still think the details about the working are pretty less but trust me getting hold of the concept in itself is pretty difficult.

In short let me put it this way you need to gernerate such signals levels in the form of binary and tyhen use a D/A converter to get the signal levels.Once you know how T.V works and what the signal looks like you can always generate the signeal like the ones below.

signalsignal

now as of i’m concerned it will be pretty difficult for newbies to understand this. As of i’m concerned i’m seriously hard hiot by this idea and i’l be trying to do is just to write up alphabets on screen. Below are the screen shots of the Ping Pong and Tetris games that he has created

Tetris Ping Pong

tetris………………….ping

now can you believe these are on TV screens and they are generated by a microcontroller. well check his site here

have a look and give your comments on this find.In case you people know anything on this please draft it and tell me more.

Categories: PIC ideas, Uncategorized
Follow

Get every new post delivered to your Inbox.