Jump in and out of ISR?

Hello, for a school project we're tasked with making two robots, a follower and a leader. Part of the assignment is controlling the servos of the robots with interrupts, instead of a library. They gave us an example on how to do it with an ISR overflow. Is there any way to start/stop or jump in and out of an ISR? I want to be able to control when the robots move, but to my understanding ISRs are always running. Is there way to do it? Or some other way to use interrupts to control servos? The code below is how I am able to make a servo move with the ISR, but I need to find a way to stop/start this. The rijden 3 and 4 are values from an array that correspond with the correct timing of high and low to make the desired PWM.

ISR(TIMER1_OVF_vect)            // De functie om de servo's aan te sturen.
{
  if (servo)
  {
    servo = 0;
    digitalWrite(servoRechts, HIGH);
    TCNT1 = 65536 - rijden[4];
  }
  else
  {
    servo = 1;
    digitalWrite(servoRechts, LOW);
    TCNT1 = 65536 - rijden[3];
  }
}

No, ISRs are not always running, only when the associated interrupt occurs.

Part of the assignment is controlling the servos of the robots with interrupts, instead of a library

The Servo library uses interrupts

ISR(TIMER1_OVF_vect)            // De functie om de servo's aan te sturen.
{
if (servoEnable)
  {
    if (servo)
    {
      servo = 0;
      digitalWrite(servoRechts, HIGH);
      TCNT1 = 65536 - rijden[4];
    }
    else
    {
      servo = 1;
      digitalWrite(servoRechts, LOW);
      TCNT1 = 65536 - rijden[3];
    }
  }
}

TheMemberFormerlyKnownAsAWOL:
No, ISRs are not always running, only when the associated interrupt occurs.

As I have it setup currently, I don't have any external interrupt, or anything else really, pointing to the ISR. How would I go about doing that?

yopocho:
As I have it setup currently, I don't have any external interrupt, or anything else really, pointing to the ISR. How would I go about doing that?

By reading the Arduino documentation on this site, on attachInterrupt() listed under "interrupts". If you are a student, you would probably know to do some general internet research also.
https://www.arduino.cc/reference/en/

Your ISR just generates the servo control signal. The values stored in the array determine what the servo does (its position if a common servo, the direction and possibly speed of a continuous rotation servo).

yopocho:
As I have it setup currently, I don’t have any external interrupt, or anything else really, pointing to the ISR. How would I go about doing that?

I’m not sure I understand the question.

TheMemberFormerlyKnownAsAWOL:
I'm not sure I understand the question.

Yeah that was a bit unclear, sorry. I meant how do I set up that associated interrupt. Does that have to be a physical interrupt on a pin, or is there a way to do it in code?

yopocho:
Yeah that was a bit unclear, sorry. I meant how do I set up that associated interrupt. Does that have to be a physical interrupt on a pin, or is there a way to do it in code?

Did you follow the advice in reply #4?

yopocho:
I want to be able to control when the robots move, but to my understanding ISRs are always running.

If you want to use interrupts you need to become familiar with the Atmega 328 datasheet (assuming you are using an Uno or nano).

Every interrupt has a series of registers associated with it and for the TIMER1 bit 5 of register TIMSK1 determines whether the interrupt is active or not.

...R

aarg:
Did you follow the advice in reply #4?

I did, could only find documentation on external interrupts. I might be looking for the wrong thing though..

An interrupt is just a signal to the core of the microcontroller that it has to do something, and it has to do that thing NOW.

It can come from an external source, like the change in state of an I/O pin.

It can come from some condition a little closer to the core itself, like an overflow of a counter/timer, or a character has just been received by the UART.

It can come from the core itself (not all the following are applicable to an AVR) like an invalid instruction, a divide-by-zero, an access to non-existent memory, access to memory you don’t own, and a ton of other reasons.

Hello yopocho,
It seems to me like you have picked up a hammer from the toolbox and want to know how to use a hammer to repair your car for the sole reason that you have a hammer in your hand. In reality there are lots of other tools in your toolbox that you are ignoring, not to mention that you don't actually know anything much about how a car works.

The hammer in this case is, of course, the interrupt. Please do as others have hinted and learn the basics then you will know what tools to use. Based on what I have read the one tool I don't think you need is an interrupt.

yopocho:
I did, could only find documentation on external interrupts. I might be looking for the wrong thing though..

What about the advice in reply #2? That directly solves several of the issues that you raised in the original post.

yopocho:
I did, could only find documentation on external interrupts. I might be looking for the wrong thing though..

You need to download the Atmega 328 datasheet from the Microchip website

...R

the TO says in his initial post

Part of the assignment is controlling the servos of the robots with interrupts, instead of a library. They gave us an example on how to do it with an ISR overflow. Is there any way to start/stop or jump in and out of an ISR?

@yopocho: they gave you an example. So how about asking details to the given example?
How about a quick googling with all of the non-fillwords of the code-example?
so search for arduino TIMER1_OVF_vect
arduino TCNT1

In the forums mimimum twice a week there pops up a thread which is quickly discovered beeing a school-assigment.
Even if the TO does not explicit say that it is a school assigment.

One part of the learning at school is become more and more routine in finding the right things to learn
on your own.

That's the reason why nobody answered with a ready to use piece of code.

You have been given some tips. Now it is up to you to follow these tips.
And then come back with new questions, where the question shows that you have put some own effort into gaining knowledge
at least just a little bit. So if your next question is about any detail of the datasheet this would show you have looked up the datasheet and now have a concrete question about it.

best regards Stefan