Event listening for a counter.

Hey.
I read for the past few days about interrupts, events and counters.
All I want to do is hook an interrupt\event to a counter, so that a certain VI is called the moment the counter’s value changes?

Is this even possible?

Thanks
Itamar.

There are probably a lot more efficient ways to do what you want. What is the high level task you are trying to accomplish?

more efficient?
I don’t believe explaining the algorithm is neccessery right now. Basically, I would like to stop a motor from running the moment a microswitch is clicked.
This is normally a very easy task to accomplish, but my code has many other VIs to run and take care of, so I wanted to try using events of interrupts.
So this is not really about efficiency, it’s more about how much time it takes for the motor to stop, and I believe that by using an event the response would be immediate.

Using a limit switch input on a Jaguar is probably the fastest way to stop a motor.

-Joe

With parallel loops, it doesn’t have to run all the code before going onto the next loop, which would provide fast stopping for the motor. Just put the speeds of the motors in a global variable and ship it over to periodic tasks. You can also read the sensor in periodic tasks.

And yes, if your switch is normally closed, wiring it straight up to the jaguars is much easier (and safer!) assuming you don’t ever want to go past the limit switch (it is limiting…)

After reading your post I tried using parallel loops and it works better, but I still can’t shake the feeling it would work much better if I used events.
Interrupts and events are used all the time. are you telling me it is impossible to perform in LabVIEW? Doesn’t make much sense.

Using the Jaguar’s limit switch inputs is the fastest available way to stop a motor and it takes no resources on the cRIO.

If for some reason you are opposed to that solution, you can use the interrupt palette in LabVIEW to connect an interrupt directly to the digital input that your switch is connected to. You then put a separate parallel loop waiting for the interrupt to occur. Then do what you need to when it stops waiting.

There is an example for how to use interrupts in LabVIEW. Look at that first.

-Joe

The LabVIEW interrupt vi palette is at:
WPI Robotics Library -> Utilities -> Interrupts

I managed to use the Interrupt vis, but came across a problem.
My algorithm is consisted of two digital inputs, each performs half of the process. Firstly I used an interrupt to have immediate responses to the first digial input. it worked great. but when I added a second interrupt for the second digital input, not only that the new interrupt didn’t work, it stopped the old one from working.

Any ideas what could cause this? Is there an interrupt-limit I’m not aware of?

There is a limit of 8 interrupt inputs.

Perhaps you are putting the wait for both of your inputs in the same loop. If you do that you are waiting for both inputs, not one or the other.

-Joe