• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

how fast is the PIC

Not open for further replies.


New Member
i am a PIC newbie and i have some questions.plz help me

if i use the switch shown below, and connect it to a pull up resistor, the pin will see a binary 1 at the pin at most of the time. and when i press the switch and release it, the input to the pin will momentarily go to zero (since another end is connected to ground) and then high again . if i write the code like this:

if PORTA.0=0 then

can the PIC read the "momentary low signal" at the moment i press the button and release it?



If the PIC is in a tight loop and assuming the other pins to port a are low then at normal clock speeds (1,4,10,20MHz) the loop will execute much faster than your finger will press and release the button. However in normal cases you would want to detect a button change and have a small delay to "debounce" the switch in software. The segment of code takes 3 clock cycles to make the complete loop.

compare PORTA, 0
if not equal jump loop


New Member
can u plz explain in more detail how it is done. i have just started to learn PIC one month ago and everything is new to me.
assuming i want to control a small dc water pump. whenver the button is pressed and released, the water pump will pump the water from the tank and send to other place for the duration of 5 seconds and then stop.it wll wait for another button pressing and do it again.

i am using PIC basic pro.what command should i use?


New Member

U can use MPLab,

If you use 1 button then use the RB0/int pin so you can use interupt and you chip will see the puch all the time and you can do what you want then,

Just download a datasheet from the pic you use en look to interupt or RB0/int and you get the info you need, :p


New Member
i do not know how to use the Mplab and how to program in assembly language.
that is just one of the function of my system that i am going to build.
there is another fucntion which is LCD display to show the level of the water.
when i press the water pump button, the water will pump out.adn when i press another button, the LCD will show the level

how to implement this?


New Member
In MPlab you can use C or what you like you don`t need to use full assambler. :p

How to inplement depent on what for PIC you have. Some have more then 1 interupt pin so you can put more buttons on interupt.

For the display it depents on the display and the display driver. Some use 4 or 8 lines communication and some use I²C.

If you done a button make a reg with a flag and in your main you will see that and then go to a display funtcion.


New Member
I would write out first what you want to do before writing any code.
SOmething like this

1. Check Switch 1
2. If Switch 1 is ON then PUMP
3. If Swich 1 is OFF then SOMETHING ELSE
4. "do more stuff"

:?: This way you know what you need and what has a priority, and if interrupts are needed or if you are better off just checking the Port over and over.


If PortB.1 = 1 then
PortB.2 = 1
Goto Loop

Will be better than creating a interrupt. :wink:

Good Luck



New Member
How fast is the PIC?

Let's put things in perspective here. We humans can't distiguish events faster than probably 10msecs. That is, if I press a button, and if the controller responds even after 10 msecs later, we would think that the response was still immediate.

Using a 4Mhz crystal, in 10 msecs, a PIC would have executed more 10,000 instructions. That is more than the program space of a PIC16F84 chip. You would have gone through several loops of your program and still would perceive the response of the PIC as immediate.
Not open for further replies.

Latest threads

EE World Online Articles