Jump to content

How do I use interrupts?


Recommended Posts

Hello,

For the past few days I have been searching the web for an explanation how to use interrupts. I didn't find anything useful.

All the code bits I have seen untill now talked about a timed loop.

Is it possible to use interrupts to execute a certain VI the second a microswitch is clicked? If so, please tell me how. :thumbup1:

Many thanks,

Itamar.

P.S

I'm sorry if this is the wrong category for this... I wasn't sure which was the right one.

Link to comment

Hello,

For the past few days I have been searching the web for an explanation how to use interrupts. I didn't find anything useful.

All the code bits I have seen untill now talked about a timed loop.

Is it possible to use interrupts to execute a certain VI the second a microswitch is clicked? If so, please tell me how. :thumbup1:

Many thanks,

Itamar.

P.S

I'm sorry if this is the wrong category for this... I wasn't sure which was the right one.

Drivers should mask the hardware functions for us but what can be done is to set up a trggered acquisition :: the switch trggers the acquisition. Use a loop waiting to a read and when one appears, the switch was pressed and you can act.

Ben

Link to comment

It's been a long time since I worked with this, and I didn't have the correct hardware then so I don't have experience with it, but I remember something about some NI hardware being able do do something like this. How's that for concrete help?

The feature of the hardware is called Digital Change Detection, and it eliminates the need to poll your input lines and this KB sounds like what I vaguely remember.

Link to comment

It's been a long time since I worked with this, and I didn't have the correct hardware then so I don't have experience with it, but I remember something about some NI hardware being able do do something like this. How's that for concrete help?

The feature of the hardware is called Digital Change Detection, and it eliminates the need to poll your input lines and this KB sounds like what I vaguely remember.

... adding to the above...

In the old version of DAQ there used to be "DAQ Occurences"

Ben

Link to comment

In the old version of DAQ there used to be "DAQ Occurences"

And now we have DAQmx Events, which let you trigger an event (in an Event Structure) when a digital line changes. I haven't actually used them, but it looks easy enough.

  • Like 2
Link to comment

Be sure to check out queues and notifiers. Although they just look like fancy ways to pass data around, they are very flexible for all kinds of asyncrhonous operations, and can act very similar to an interrupt. (True hardware interrupts are not really available in LabVIEW). Generally I would have one loop waiting for a queue or notifier message, and one loop polling or waiting on the microswitch event, maybe with a DAQmx Event or a DAQmx triggered acquisition.

Link to comment

And now we have DAQmx Events, which let you trigger an event (in an Event Structure) when a digital line changes. I haven't actually used them, but it looks easy enough.

Thanks for the heads up on that one!

It is possible to get at interupts if we are dealing a widget where we know the regiser definitions addresses and functionality and are lacking a driver. The VISA driver development wizard will let us define our own interupt service routines.

Ben

Link to comment

Hello,

For the past few days I have been searching the web for an explanation how to use interrupts. I didn't find anything useful.

All the code bits I have seen untill now talked about a timed loop.

Is it possible to use interrupts to execute a certain VI the second a microswitch is clicked? If so, please tell me how. :thumbup1:

Many thanks,

Itamar.

P.S

I'm sorry if this is the wrong category for this... I wasn't sure which was the right one.

Can you give us an idea of what your target Platform will be PC, RT, FPGA?

Also what is the purpose of the interupt?

Will it start, stop, trigger...

Interrupt isn't a common term in the labview world.

Mark

Link to comment

To tell you the truth, I'm a bit lost with all of your comments... After reading Ether's comment, I'm pretty sure that what I need is an event handler.

So... is there an option to use events for a microswitch?

P.S

I'm programming an FRC robot, if you wanted to know.

Link to comment

I'm programming an FRC robot, if you wanted to know.

That's a critical piece of information - it means you're running on a cRIO with the IO controlled by the functions NI provides. No wonder you're confused; all the previous comments were based on the assumption that you're using DAQmx on a Windows machine. In your case, no, there's no way to trigger a VI to run the instant you push a switch. You'll need to poll the state of the input and when it switches (from false to true, or whatever your condition is), run your VI. You may want to have a separate loop in your code, running at a faster rate, dedicated to doing this if you absolutely need it. If you describe your goal more fully you might get more helpful hints or suggestions on an alternate approach.

Link to comment

That's a critical piece of information - it means you're running on a cRIO with the IO controlled by the functions NI provides. No wonder you're confused; all the previous comments were based on the assumption that you're using DAQmx on a Windows machine. In your case, no, there's no way to trigger a VI to run the instant you push a switch. You'll need to poll the state of the input and when it switches (from false to true, or whatever your condition is), run your VI. You may want to have a separate loop in your code, running at a faster rate, dedicated to doing this if you absolutely need it. If you describe your goal more fully you might get more helpful hints or suggestions on an alternate approach.

Where is the VI-to-be-triggered running?

If you read the microswitch on the FPGA you can generate an IRQ on the cRIO FPGA and respond to that IRQ in the Real-Time (RT) code to trigger a VI.

To do this:

Set up a loop in the FPGA code to read the value of the microswitch.

When the microswitch value changes call the Interrupt function on the FPGA (Synchronization palette) to assert a specified interrupt.

On the RT side, in a loop (assuming you want to be able to respond to a change more than once) use the Wait on IRQ method--select this on an Invoke Method (FPGA Interface Palette) with the correct FPGA VI Reference. When this method returns execute the desired RT VI. (Note there is an Acknowledge IRQ method here as well in case you want the FPGA to wait for acknowledgment before sending the next interrupt.)

(For the record, if the VI to run is on the desktop--specifically in Windows, you could, upon receipt of the interrupt in the RT code, write a value to a shared variable, and then handle the shared variable value change event in the desktop application. Of course, there will be some network latency, and shared variable value change events are only available with the DSC Module, which in turn only runs on Windows.)

Link to comment

If you read the microswitch on the FPGA you can generate an IRQ on the cRIO FPGA and respond to that IRQ in the Real-Time (RT) code to trigger a VI.

Unfortunately, no, probably not. The version of LabVIEW provided to FRC teams does not allow access to the cRIO's FPGA. Maybe it's possible in this year's beta (I have no idea), but most likely you can't modify the code running on the FPGA.

Link to comment

Unfortunately, no, probably not. The version of LabVIEW provided to FRC teams does not allow access to the cRIO's FPGA. Maybe it's possible in this year's beta (I have no idea), but most likely you can't modify the code running on the FPGA.

Yes, my suggestion applies only if the developer can write an FPGA VI.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.