Question regarding interrupts

Hello I wanted to know what is the difference between timer interrupts and pin change interrupts? And in what situations can they be used for?

what is the difference between timer interrupts and pin change interrupts?

Isn't it obvious? A timer interrupt happens because a timer triggered it. A pin change interrupt happens because a pin changes state.

And in what situations can they be used for?

Whatever situation is appropriate.

PaulS:

what is the difference between timer interrupts and pin change interrupts?

Isn't it obvious? A timer interrupt happens because a timer triggered it. A pin change interrupt happens because a pin changes state.

Could you elaborate on how the pin change interrupt works?

What more do you need to know than that an interrupt is generated when a pin changes state?

Could you elaborate on how the pin change interrupt works?

Some external circuit connected to the pin makes the pin HIGH or LOW. This may trigger the interrupt handler defined for the pin, if the correct change happens (RISING, FALLING, CHANGE).

AWOL: What more do you need to know than that an interrupt is generated when a pin changes state?

so it just changes the pin to high to low for example?

What is "it"? The interrupt? No, the interrupt doesn't do anything to the pin, just indicates that a change has occurred, in the same way a timer interrupt indicates some significant timer event has happened, or a UART interrupt indicates something has happened in the UART. The interrupt is an indication you should take some action.

AWOL: What is "it"? The interrupt? No, the interrupt doesn't do anything to the pin, just indicates that a change has occurred, in the same way a timer interrupt indicates some significant timer event has happened, or a UART interrupt indicates something has happened in the UART. The interrupt is an indication you should take some action.

When I mean "it" I mean the pin state. Sorry for sounding newbish about this I am just trying to figure out how these interrupts work. I think I'm going to have to use them for a project I am going to do.

When an input pin changes value because the applied voltage has changed, a pin change interrupt is generated, and at the end of the current machine instruction cycle, the processor is vectored to a particular place in program memory. It is up to you to decide what happens next.

AWOL: When an input pin changes value because the applied voltage has changed, a pin change interrupt is generated, and at the end of the current machine instruction cycle, the processor is vectored to a particular place in program memory. It is up to you to decide what happens next.

So when the input pin changes and the pin change interrupt starts then after that once its goes back to its to the current instruction, its goes to where it left off in program memory?

So when the input pin changes and the pin change interrupt starts then after that once its goes back to its to the current instruction, its goes to where it left off in program memory?

It really would be better if you stopped using pronouns. Again, we are left to guess what you mean by "it".

After the interrupt service returns, normal program execution resumes with the instruction after the one that was completed just before the interrupt happened.

It seems unlikely, given all you concerns about interrupts that you need to use them. Why do you think you might need to?

PaulS:

So when the input pin changes and the pin change interrupt starts then after that once its goes back to its to the current instruction, its goes to where it left off in program memory?

It really would be better if you stopped using pronouns. Again, we are left to guess what you mean by "it".

After the interrupt service returns, normal program execution resumes with the instruction after the one that was completed just before the interrupt happened.

It seems unlikely, given all you concerns about interrupts that you need to use them. Why do you think you might need to?

I apologize for not being clear using "it". The reason I think I need to use interrupts because I am working on a skittle sorting machine to sort skittles by a specific color. I also want it to sort as fast as possible and be able to keep track the the number of skittles that into their respective color bins so I will have a LCD to keep track of the time as LCDs for the count of total skittles in the specific color bin. Also, the design of the machine is a binary tree method (not letting me upload image) that basically has four levels: Top(1), Shoulder(2), Middle(4), bottom(8), those levels will have a color sensor(HDJD-S822 color sensor) at each junction that will tell a servo to move left of right depending on the color of the skittle. I would think I would need an interrupt to start/stop the timer and the sensors and servos interaction since skittles will be constantly get read no?

I would think I would need an interrupt to start/stop the timer

What does the mysterious timer have to do with sorting skittles by color?

PaulS:

I would think I would need an interrupt to start/stop the timer

What does the mysterious timer have to do with sorting skittles by color?

It keeps track of the time is takes to the sort how ever many skittles are being sorted

It keeps track of the time is takes to the sort how ever many skittles are being sorted

You don't need an interrupt for that. You note what time it is (by calling millis()) when the sorting starts, and you note what time it is when the last skittle is sorted. The difference is how long it took. No timers; no interrupts.

PaulS:

It keeps track of the time is takes to the sort how ever many skittles are being sorted

You don't need an interrupt for that. You note what time it is (by calling millis()) when the sorting starts, and you note what time it is when the last skittle is sorted. The difference is how long it took. No timers; no interrupts.

Wait so this entire system described doesn't need interrupts or just the timer??

so this entire system described doesn't need interrupts

Correct.

PaulS:

so this entire system described doesn't need interrupts

Correct.

I thought about this and using millis for the timer instead of an interrupt I understand but what I don't understand is that I can have 7 sensors and 7 servos reading skittles and moving them to the appropriate area and count the number of skittles in each of their respective bin simultaneously with no interrupts??? Also, if I dumped lets say 1800 skittles to be sorted, how can the millis note what time last time a skittle is being sorted with that substantial number of skittles being sorted??

thorobred:

PaulS:

so this entire system described doesn't need interrupts

Correct.

I thought about this and using millis for the timer instead of an interrupt I understand but what I don't understand is that I can have 7 sensors and 7 servos reading skittles and moving them to the appropriate area and count the number of skittles in each of their respective bin simultaneously with no interrupts??? Also, if I dumped lets say 1800 skittles to be sorted, how can the millis note what time last time a skittle is being sorted with that substantial number of skittles being sorted??

An Arduino might seem like a toy, but the AVR processor in it is remarkably powerful, if programmed properly.

Embedded programming is an entirely different style of computer programming. Done properly, a LOT of functionality can be gotten out of not a lot of processing power.

jfhaugh:

thorobred:

PaulS:

so this entire system described doesn’t need interrupts

Correct.

I thought about this and using millis for the timer instead of an interrupt I understand but what I don’t understand is that I can have 7 sensors and 7 servos reading skittles and moving them to the appropriate area and count the number of skittles in each of their respective bin simultaneously with no interrupts??? Also, if I dumped lets say 1800 skittles to be sorted, how can the millis note what time last time a skittle is being sorted with that substantial number of skittles being sorted??

An Arduino might seem like a toy, but the AVR processor in it is remarkably powerful, if programmed properly.

Embedded programming is an entirely different style of computer programming. Done properly, a LOT of functionality can be gotten out of not a lot of processing power.

I’m trying to wrap my head around it but I can’t see how all that can work simutaneously without interrupts